本文整理汇总了C#中ICustomTypeDescriptor.GetClassName方法的典型用法代码示例。如果您正苦于以下问题:C# ICustomTypeDescriptor.GetClassName方法的具体用法?C# ICustomTypeDescriptor.GetClassName怎么用?C# ICustomTypeDescriptor.GetClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICustomTypeDescriptor
的用法示例。
在下文中一共展示了ICustomTypeDescriptor.GetClassName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDisplayName
/// <summary>
/// Gets the display name for a class. Looks for the <see cref="DisplayNameAttribute"/>
/// attribute, and falls back to the class's name by default.
/// </summary>
/// <param name="descriptor">The class's type descriptor</param>
/// <returns>The display name of the class</returns>
internal static string GetDisplayName(ICustomTypeDescriptor descriptor)
{
var displayNameAttribute = descriptor.GetAttribute<DisplayNameAttribute>();
if (displayNameAttribute != null && !String.IsNullOrEmpty(displayNameAttribute.DisplayName)) {
return displayNameAttribute.DisplayName;
}
return descriptor.GetClassName().Split('.', '+').Last();
}
示例2: SimpleTableProvider
public SimpleTableProvider(DataModelProvider modelProvider, ICustomTypeDescriptor descriptor)
: base(modelProvider) {
if (descriptor == null) {
throw new ArgumentNullException("descriptor");
}
_descriptor = descriptor;
Name = descriptor.GetClassName();
DataContextPropertyName = String.Empty;
InitializeColumns(descriptor.GetProperties());
}
示例3: BuildDataObject
internal static object BuildDataObject(object dataObject, ICustomTypeDescriptor typeDescriptor, IDictionary inputParameters) {
Dictionary<string, Exception> convertOrValidateExceptions = null;
PropertyDescriptorCollection props = typeDescriptor.GetProperties();
foreach (DictionaryEntry de in inputParameters) {
string propName = (de.Key == null ? String.Empty : de.Key.ToString());
PropertyDescriptor property = props.Find(propName, /*ignoreCase*/true);
// NOTE: No longer throws when a property is not found or is read only. This makes
// Delete, Insert and Update operations more optimistic, allowing scenarios such as:
// 1) Deletes and Updates after projecting data in the Selecting event.
// 2) Deletes and Updates after selecting children of the data object type in the
// Selecting event.
if ((property != null) && (!property.IsReadOnly)) {
try {
object value = BuildObjectValue(de.Value, property.PropertyType, propName);
property.SetValue(dataObject, value);
}
catch (Exception e) {
if (convertOrValidateExceptions == null) {
convertOrValidateExceptions = new Dictionary<string, Exception>(
StringComparer.OrdinalIgnoreCase);
}
convertOrValidateExceptions[property.Name] = e;
}
}
}
// package up conversion or dlinq validation exceptions into single exception.
if (convertOrValidateExceptions != null) {
// Include the text of the first exception as part of the full exception,
// to make it less cryptic in scenarios where it gets shown.
throw new LinqDataSourceValidationException(String.Format(CultureInfo.InvariantCulture,
"AtlasWeb.LinqDataSourceView_ValidationFailed", typeDescriptor.GetClassName(), convertOrValidateExceptions.Values.First().Message),
convertOrValidateExceptions);
}
return dataObject;
}
示例4: ExtractTypeName
private static string ExtractTypeName(ICustomTypeDescriptor typeDescriptor)
{
string name = typeDescriptor.GetClassName();
if (string.IsNullOrEmpty(name))
{
return name;
}
int lastDot = name.LastIndexOf(".");
return (lastDot >= 0) ? name.Substring(lastDot + 1) : name;
}