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


C# PropertyInfo.Name方法代码示例

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


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

示例1: ProcessArrayOrCollectionAsNestedObject

        private void ProcessArrayOrCollectionAsNestedObject(EntityContextInfo entityInfo, ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter, PropertyInfo prop, bool createPropertyMappings)
        {
            elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(prop.Name().ToLower(MapToLowerCase));
            TraceProvider.Trace(TraceEventType.Verbose, "ElasticsearchMapping: BEGIN ARRAY or COLLECTION: {0} {1}", prop.Name().ToLower(MapToLowerCase), elasticsearchCrudJsonWriter.JsonWriter.Path);
            var typeOfEntity = prop.GetValue(entityInfo.Document).GetType().GetGenericArguments();
            if (typeOfEntity.Length > 0)
            {
                var child = GetDocumentType(typeOfEntity[0]);
                var parent = GetDocumentType(entityInfo.EntityType);

                if (!SerializedTypes.Contains(child + parent))
                {
                    SerializedTypes.Add(parent + child);
                    TraceProvider.Trace(TraceEventType.Verbose,
                        "ElasticsearchMapping: SerializedTypes type ok, BEGIN ARRAY or COLLECTION: {0}", typeOfEntity[0]);
                    TraceProvider.Trace(TraceEventType.Verbose, "ElasticsearchMapping: SerializedTypes new Type added: {0}",
                        GetDocumentType(typeOfEntity[0]));
                    MapCollectionOrArray(prop, entityInfo, elasticsearchCrudJsonWriter, createPropertyMappings);
                }
                else
                {
                    elasticsearchCrudJsonWriter.JsonWriter.WriteRawValue("null");
                }
            }
            else
            {
                TraceProvider.Trace(TraceEventType.Verbose, "ElasticsearchMapping: BEGIN ARRAY or COLLECTION NOT A GENERIC: {0}",
                    prop.Name().ToLower(MapToLowerCase));
                // Not a generic
                MapCollectionOrArray(prop, entityInfo, elasticsearchCrudJsonWriter, createPropertyMappings);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:32,代码来源:ElasticSearchMapping.cs

示例2: ProcessSingleObjectAsNestedObject

        private void ProcessSingleObjectAsNestedObject(EntityContextInfo entityInfo, ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter, PropertyInfo prop, bool createPropertyMappings)
        {
            elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(prop.Name().ToLower(MapToLowerCase));
            elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

            if (createPropertyMappings)
            {
                // "properties": {
                elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName("properties");
                elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
            }
            // Do class mapping for nested type
            var entity = prop.GetValue(entityInfo.Document);
            var routingDefinition = new RoutingDefinition {ParentId = entityInfo.Id};
            var child = new EntityContextInfo { Document = entity, RoutingDefinition = routingDefinition, EntityType = entity.GetType(), DeleteDocument = entityInfo.DeleteDocument };

            MapEntityValues(child, elasticsearchCrudJsonWriter, false, createPropertyMappings);
            elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();

            if (createPropertyMappings)
            {

                elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:25,代码来源:ElasticSearchMapping.cs

示例3: ProcessArrayOrCollection

        private void ProcessArrayOrCollection(EntityContextInfo entityInfo, ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter, PropertyInfo prop, bool createPropertyMappings)
        {
            TraceProvider.Trace(TraceEventType.Verbose, "ElasticsearchMapping: IsPropertyACollection: {0}", prop.Name().ToLower(MapToLowerCase));

            if (createPropertyMappings && prop.GetValue(entityInfo.Document) == null)
            {
                if (prop.PropertyType.IsArray)
                {
                    prop.SetValue(entityInfo.Document, Array.CreateInstance(prop.PropertyType.GetElementType(), 0));
                }
                else
                {
                    prop.SetValue(entityInfo.Document, Activator.CreateInstance(prop.PropertyType));
                }
            }

            if (prop.GetValue(entityInfo.Document) != null && SaveChildObjectsAsWellAsParent)
            {
                if (ProcessChildDocumentsAsSeparateChildIndex)
                {
                    ProcessArrayOrCollectionAsChildDocument(entityInfo, elasticsearchCrudJsonWriter, prop, createPropertyMappings);
                }
                else
                {
                    ProcessArrayOrCollectionAsNestedObject(entityInfo, elasticsearchCrudJsonWriter, prop, createPropertyMappings);
                }
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:28,代码来源:ElasticSearchMapping.cs


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