1

I have custom html helper which getting IEnumerable model from view and generates html table with headers and body

please advice how can get matadata from this model

thanks


After you have installed Xcode 4.5 you need to follow these instructions in order to install the command line tools. Once you've done that successfully then you should see that svn is installed:

$ which svn
/usr/bin/svn
$ svn --version
svn, version 1.6.18 (r1303927)
   compiled Aug  4 2012, 19:46:53

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

$ 
4

2 に答える 2

1

あなたが正しくやろうとしていることを私が理解している場合、以下は最小限の反射で機能するはずです:

public static MvcHtmlString MakeTable<TModel, TValue>(this HtmlHelper<TModel> html, IEnumerable<TValue> table)
{
    var modelMetaData = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(TValue));

    foreach (TValue row in table)
    {
        //write out table
    }
}
于 2012-09-21T14:21:34.273 に答える
-1

プロパティを取得するには:

YourModel.GetType().GetProperties();

プロパティの名前を取得するには:

property.Name;

プロパティの値を取得するには:

var result = YourModel.GetType().InvokeMember("NameOfProperty", BindingFlags.GetProperty, null, YourModel, null);

よく開発されたいくつかの例は、GitHub のこのファイルにあります: https://github.com/jamestharpe/Rolcore/blob/master/src/Rolcore/Reflection/ObjectExtensions.cs

于 2012-09-21T14:14:14.807 に答える