本文整理汇总了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);
}
}
示例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();
}
}
示例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);
}
}
}