当前位置: 首页>>代码示例>>C#>>正文


C# Type.GetRuntimeProperties方法代码示例

本文整理汇总了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;
        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:26,代码来源:PropertyFilter.cs

示例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;
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:24,代码来源:CompareAttribute.cs

示例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;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:30,代码来源:OSpaceTypeFactory.cs


注:本文中的Type.GetRuntimeProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。