本文整理汇总了C#中System.Reflection.PropertyInfo.Where方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.Where方法的具体用法?C# PropertyInfo.Where怎么用?C# PropertyInfo.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.Where方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAttachedModelProperty
public PropertyInfo FindAttachedModelProperty(PropertyInfo queryProperty, PropertyInfo[] modelProperties)
{
var queryPropertyName = queryProperty.Name;
if (queryProperty.PropertyType != typeof (string)) return null;
if (!queryPropertyName.EndsWith(Suffix)) return null;
return
modelProperties.Where(o => o.PropertyType == typeof (string))
.FirstOrDefault(modelProperty => queryPropertyName == modelProperty.Name + Suffix);
}
示例2: MapIdentifier
private IdentifierMap MapIdentifier(PropertyInfo[] properties)
{
PropertyInfo id = properties.Where(x => x.Name.Equals(DefaultIdentifier)).FirstOrDefault();
if (id == null)
{
throw new MappingException("Entity does not contain an identifier [Id].");
}
return new IdentifierMap(id, id.Name, id.PropertyType);
}
示例3: GetEnumerableIndexablePropertyInfos
protected virtual PropertyInfo[] GetEnumerableIndexablePropertyInfos(PropertyInfo[] properties, IStructureProperty parent = null, ICollection<string> nonIndexablePaths = null, ICollection<string> indexablePaths = null)
{
if (properties.Length == 0)
return new PropertyInfo[0];
var filteredProperties = properties.Where(p =>
!p.PropertyType.IsSimpleType() &&
p.PropertyType.IsEnumerableType() &&
!p.PropertyType.IsEnumerableBytesType());
if (nonIndexablePaths != null && nonIndexablePaths.Any())
filteredProperties = filteredProperties.Where(p => !nonIndexablePaths.Contains(
PropertyPathBuilder.BuildPath(parent, p.Name)));
if (indexablePaths != null && indexablePaths.Any())
filteredProperties = filteredProperties.Where(p => indexablePaths.Contains(
PropertyPathBuilder.BuildPath(parent, p.Name)));
return filteredProperties.ToArray();
}
示例4: GetAuditedProperties
/// <summary>
///
/// </summary>
/// <param name="properties"></param>
/// <returns></returns>
private static IEnumerable<PropertyInfo> GetAuditedProperties(PropertyInfo[] properties)
{
return properties.Where(x => x.GetCustomAttribute<ParentAuditedAttribute>(false) != null);
}
示例5: RequireBase
public static PropertySet[] RequireBase(ComponentModel model, PropertyInfo[] properties,
PropertySetBuilder propertySetBuilder)
{
return properties.Where(p => p.DeclaringType != model.Implementation)
.Select(p => propertySetBuilder(p, false)).ToArray();
}
示例6: GetPropertyNames
private List<string> GetPropertyNames(PropertyInfo[] properties)
{
List<string> result = new List<string>();
List<PropertyInfo> props = properties.Where(p => p.Name.EndsWith("RepetitionsUsed")).ToList();
foreach (PropertyInfo p in props)
result.Add(p.Name.Remove(p.Name.IndexOf("RepetitionsUsed")));
return result;
}
示例7: Prune
private void Prune(IContentTypeBase contentType, Type documentClrType, PropertyInfo[] tabProperties, IEnumerable<PropertyInfo> propertiesOfRoot)
{
bool modified = false;
var propertiesToKeep = propertiesOfRoot.Where(x =>
{
var attr = x.DeclaringType.GetCodeFirstAttribute<CodeFirstCommonBaseAttribute>(false);
return x.DeclaringType == documentClrType || attr != null;
}).Select(x => x.GetCodeFirstAttribute<ContentPropertyAttribute>().Alias)
.Union(tabProperties.Where(x =>
{
var attr = x.DeclaringType.GetCodeFirstAttribute<CodeFirstCommonBaseAttribute>(false);
return x.DeclaringType == documentClrType || attr != null;
}).SelectMany(x =>
{
return x.PropertyType.GetProperties().Where(y =>
{
return (y.DeclaringType == x.PropertyType || y.DeclaringType.GetCodeFirstAttribute<CodeFirstCommonBaseAttribute>(false) != null) && y.GetCodeFirstAttribute<ContentPropertyAttribute>() != null;
}).Select(y =>
{
var attr = y.GetCodeFirstAttribute<ContentPropertyAttribute>();
var tabAttr = x.GetCodeFirstAttribute<ContentTabAttribute>();
return attr.AddTabAliasToPropertyAlias ? attr.Alias + "_" + tabAttr.Name.Replace(" ", "_") : attr.Alias;
});
})).ToList();
propertiesToKeep.AddRange(documentClrType.GetCustomAttributes<DoNotRemovePropertyAttribute>(true).Select(x => x.PropertyAlias));
//loop through all the properties on the ContentType to see if they should be removed.
var existingUmbracoProperties = contentType.PropertyTypes.ToArray();
int length = contentType.PropertyTypes.Count();
for (int i = 0; i < length; i++)
{
if (!propertiesToKeep.Any(x => x.Equals(existingUmbracoProperties[i].Alias, StringComparison.InvariantCultureIgnoreCase)))
{
if (contentType.PropertyTypeExists(existingUmbracoProperties[i].Alias))
{
modified = true;
//remove the property
contentType.RemovePropertyType(existingUmbracoProperties[i].Alias);
var alias = existingUmbracoProperties[i].Alias;
var children = GetChildren(contentType);
//TODO is this needed? I reckon it shouldn't be
RemovePropertyFromChildren(alias, children);
}
}
}
if (modified)
{
contentType.ResetDirtyProperties(false);
Save(contentType);
}
}