本文整理汇总了C#中System.Reflection.PropertyInfo.Select方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.Select方法的具体用法?C# PropertyInfo.Select怎么用?C# PropertyInfo.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.Select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArraySort
public static PropertyInfo[] ArraySort(PropertyInfo[] properties)
{
properties = properties.Select(x => new { Property = x })
.OrderBy(x => x.Property.Name != null ? x.Property.Name : Constants.NotApplicable)
.Select(x => x.Property)
.ToArray();
return properties;
}
示例2: RequireAll
public static PropertySet[] RequireAll(ComponentModel model, PropertyInfo[] properties,
PropertySetBuilder propertySetBuilder)
{
return properties.Select(p => propertySetBuilder(p, false)).ToArray();
}
示例3: BuildRegistration
public IResourceTypeRegistration BuildRegistration(Type type, string resourceTypeName = null,
Func<ParameterExpression, string, BinaryExpression> filterByIdFactory = null,
Func<ParameterExpression, Expression> sortByIdFactory = null,
PropertyInfo[] includeRelationships = null)
{
if (resourceTypeName == null)
resourceTypeName = _namingConventions.GetResourceTypeNameForType(type);
var fieldMap = new Dictionary<string, ResourceTypeField>();
var idProperty = CalculateIdProperty(type);
if (idProperty == null)
throw new InvalidOperationException(String.Format(
"Unable to determine Id property for type `{0}`.", type.Name));
var props = type.GetProperties().OrderBy(p => p.Name);
foreach (var prop in props)
{
if (prop == idProperty) continue;
var ignore = prop.CustomAttributes.Any(c => c.AttributeType == typeof (JsonIgnoreAttribute));
if (ignore) continue;
var property = CreateResourceTypeField(prop);
var jsonKey = property.JsonKey;
if (jsonKey == "id")
throw new InvalidOperationException(
String.Format(
"Failed to register type `{0}` because it contains a non-id property that would serialize as \"id\".",
type.Name));
if (jsonKey == "type")
throw new InvalidOperationException(
String.Format(
"Failed to register type `{0}` because it contains a property that would serialize as \"type\".",
type.Name));
if (fieldMap.ContainsKey(jsonKey))
throw new InvalidOperationException(
String.Format(
"Failed to register type `{0}` because contains multiple properties that would serialize as `{1}`.",
type.Name, jsonKey));
fieldMap[jsonKey] = property;
}
if (filterByIdFactory == null)
{
filterByIdFactory = (param, id) =>
{
var propertyExpr = Expression.Property(param, idProperty);
var idExpr = Expression.Constant(id);
return Expression.Equal(propertyExpr, idExpr);
};
}
if (sortByIdFactory == null)
{
sortByIdFactory = param => Expression.Property(param, idProperty);
}
var allincludeRelationships = new List<string>();
if (includeRelationships != null)
{
allincludeRelationships.AddRange(includeRelationships.Select(CreateResourceTypeField).Select(property => property.JsonKey));
}
return new ResourceTypeRegistration(type, idProperty, resourceTypeName, fieldMap, filterByIdFactory,
sortByIdFactory, allincludeRelationships.ToArray());
}
示例4: Default
public static PropertySet[] Default(ComponentModel model, PropertyInfo[] properties,
PropertySetBuilder propertySetBuilder)
{
return properties.Select(p => propertySetBuilder(p, true)).ToArray();
}
示例5: Line
private string Line(PropertyInfo[] properties, Object item)
{
return String.Join("\t", properties.Select(prop => prop.GetValue(item, null)));
}
示例6: Header
private string Header(PropertyInfo[] properties)
{
return String.Join("\t", properties.Select(prop => prop.Name));
}
示例7: GetPropertyExpressions
private IEnumerable<Expression> GetPropertyExpressions(PropertyInfo[] properties)
{
return properties.Select(this.GetPropertyExpression);
}
示例8: AssignListParameter
/// <summary>
/// If command has a ListParameter, assign unmatched values from <c>numbered</c> to it.
/// </summary>
/// <param name="cmd">The command</param>
/// <param name="properties">The command properties</param>
/// <param name="numbered">Unmatched parameteres from ExtractParameters call</param>
private void AssignListParameter(ICommand cmd, PropertyInfo[] properties, string[] numbered)
{
var listProperty = properties.FirstOrDefault(p => CommandInspector.GetListParameter(p) != null);
if (listProperty == null)
return;
var numberedParameters = properties.Select(CommandInspector.GetNumberedParameter)
.Where(p => p != null)
.Select(p => p.Number);
int numberedParametersToSkip = (numberedParameters.Any()) ? numberedParameters.Max() + 1 : 0;
var list = numbered.Skip(numberedParametersToSkip).ToList();
list = (from element in list
select Parser.PerformSubstitution(_context, element)).ToList();
#if NET45
listProperty.SetValue(cmd, list);
#else
listProperty.SetValue(cmd, list, null);
#endif
}
示例9: GetChainName
public static string GetChainName(PropertyInfo[] chain)
{
return String.Join (".", chain.Select (p => p.Name));
}