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


C# ITypeResolver.ResolveTypeFromName方法代码示例

本文整理汇总了C#中ITypeResolver.ResolveTypeFromName方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeResolver.ResolveTypeFromName方法的具体用法?C# ITypeResolver.ResolveTypeFromName怎么用?C# ITypeResolver.ResolveTypeFromName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITypeResolver的用法示例。


在下文中一共展示了ITypeResolver.ResolveTypeFromName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EntityTypeInfo

        internal EntityTypeInfo(IEdmModel edmModel, IEdmEntityType edmEntityType, ITypeResolver typeResolver)
        {
            Contract.Assert(edmModel != null);
            Contract.Assert(edmEntityType != null);
            Contract.Assert(typeResolver != null);

            _edmEntityType = edmEntityType;
            string edmTypeName = edmEntityType.FullName();
            _type = typeResolver.ResolveTypeFromName(edmTypeName);

            // Initialize DontSerializeProperties
            _dontSerializeProperties = _type.GetProperties().Where(p => p.GetCustomAttributes(typeof(IgnoreDataMemberAttribute), true).Length > 0).Select(p => p.Name).ToArray();

            //edmEntityType.DeclaredKey;
            //edmEntityType.BaseEntityType();
            var structuralProperties = new List<PropertyInfo>();
            foreach (var edmStructuralProperty in edmEntityType.StructuralProperties())
            {
                if (! _dontSerializeProperties.Contains(edmStructuralProperty.Name))
                {
                    structuralProperties.Add(_type.GetProperty(edmStructuralProperty.Name));
                }
            }

            // EF can pick up private properties (eg: those marked as navigational).  We omit them on spec.
            _structuralProperties = structuralProperties.Where(p => p != null).ToArray();

            var navigationProperties = new List<PropertyInfo>();
            var linkProperties = new List<PropertyInfo>();
            foreach (var edmNavigationProperty in edmEntityType.NavigationProperties())
            {
                if (! _dontSerializeProperties.Contains(edmNavigationProperty.Name))
                {
                    if (edmNavigationProperty.Type.IsCollection())
                    {
                        linkProperties.Add(_type.GetProperty(edmNavigationProperty.Name));
                    }
                    else
                    {
                        navigationProperties.Add(_type.GetProperty(edmNavigationProperty.Name));
                    }
                }
            }
            _navigationProperties = navigationProperties.Where(p => p != null).ToArray();
            _collectionProperties = linkProperties.Where(p => p != null).ToArray();

            // Reflect for ValidationAttributes on all properties
            var validationInfo = new List<PropertyValidationInfo>();
            InitValidationInfo(validationInfo, _structuralProperties, PropertyCategory.Structural);
            InitValidationInfo(validationInfo, _navigationProperties, PropertyCategory.Navigation);
            InitValidationInfo(validationInfo, _collectionProperties, PropertyCategory.Collection);
            _propertyValidationInfo = validationInfo.ToArray();
        }
开发者ID:entityrepository,项目名称:ODataClient,代码行数:53,代码来源:EntityTypeInfo.cs


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