本文整理汇总了C#中Type.GetRuntimeProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetRuntimeProperties方法的具体用法?C# Type.GetRuntimeProperties怎么用?C# Type.GetRuntimeProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.GetRuntimeProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
public IEnumerable<PropertyInfo> GetProperties(
Type type,
bool declaredOnly,
IEnumerable<PropertyInfo> explicitlyMappedProperties = null,
IEnumerable<Type> knownTypes = null,
bool includePrivate = false)
{
DebugCheck.NotNull(type);
explicitlyMappedProperties = explicitlyMappedProperties ?? Enumerable.Empty<PropertyInfo>();
knownTypes = knownTypes ?? Enumerable.Empty<Type>();
ValidatePropertiesForModelVersion(type, explicitlyMappedProperties);
var propertyInfos
= from p in declaredOnly ? type.GetDeclaredProperties() : type.GetRuntimeProperties()
where !p.IsStatic() && p.IsValidStructuralProperty()
let m = p.Getter()
where (includePrivate || (m.IsPublic || explicitlyMappedProperties.Contains(p) || knownTypes.Contains(p.PropertyType)))
&& (!declaredOnly || type.BaseType().GetInstanceProperties().All(bp => bp.Name != p.Name))
&& (EdmV3FeaturesSupported || (!IsEnumType(p.PropertyType) && !IsSpatialType(p.PropertyType)))
&& (Ef6FeaturesSupported || !p.PropertyType.IsNested)
select p;
return propertyInfos;
}
示例2: GetDisplayNameForProperty
private static string GetDisplayNameForProperty(Type containerType, string propertyName)
{
var property = containerType.GetRuntimeProperties()
.SingleOrDefault(
prop =>
IsPublic(prop) &&
string.Equals(propertyName, prop.Name, StringComparison.OrdinalIgnoreCase) &&
!prop.GetIndexParameters().Any());
if (property == null)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
SR.Common_PropertyNotFound, containerType.FullName, propertyName));
}
var attributes = CustomAttributeExtensions.GetCustomAttributes(property, true);
var display = attributes.OfType<DisplayAttribute>().FirstOrDefault();
if (display != null)
{
return display.GetName();
}
return propertyName;
}
示例3: TryCreateMembers
private bool TryCreateMembers(
Type type, StructuralType cspaceType, StructuralType ospaceType, List<Action> referenceResolutionListForCurrentType)
{
var clrProperties = (cspaceType.BaseType == null
? type.GetRuntimeProperties()
: type.GetDeclaredProperties()).Where(p => !p.IsStatic());
// required properties scalar properties first
if (!TryFindAndCreatePrimitiveProperties(type, cspaceType, ospaceType, clrProperties))
{
return false;
}
if (!TryFindAndCreateEnumProperties(type, cspaceType, ospaceType, clrProperties, referenceResolutionListForCurrentType))
{
return false;
}
if (!TryFindComplexProperties(type, cspaceType, ospaceType, clrProperties, referenceResolutionListForCurrentType))
{
return false;
}
if (!TryFindNavigationProperties(type, cspaceType, ospaceType, clrProperties, referenceResolutionListForCurrentType))
{
return false;
}
return true;
}