本文整理汇总了C#中System.Reflection.PropertyInfo.Any方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.Any方法的具体用法?C# PropertyInfo.Any怎么用?C# PropertyInfo.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.Any方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckForFocusProperty
public static void CheckForFocusProperty(string focusPropertyName, PropertyInfo[] properties, FrameworkElement control)
{
if (properties.Any(x => x.Name.Equals(focusPropertyName, StringComparison.InvariantCultureIgnoreCase)))
{
SetBindingOnFocusAttachedBehavior(focusPropertyName, control);
}
}
示例2: IsInitialKeys
/// <summary>
/// check any default value in key members.
/// </summary>
/// <param name="entity"></param>
/// <param name="keyProps"></param>
/// <returns></returns>
internal bool IsInitialKeys(object entity, PropertyInfo[] keyProps)
{
return !keyProps.Any(p => !p.GetValue(entity).Equals(Activator.CreateInstance(p.PropertyType)));
}
示例3: GetOrCreateEdmTypeInternal
private EdmTypeCacheValue GetOrCreateEdmTypeInternal(IEdmStructuredType edmBaseType, Type type, PropertyInfo[] keyProperties, bool isEntity, bool? hasProperties)
{
Debug.Assert(type != null, "type != null");
Debug.Assert(keyProperties != null, "keyProperties != null");
EdmTypeCacheValue cachedEdmType;
lock (this.clrToEdmTypeCache)
{
this.clrToEdmTypeCache.TryGetValue(type, out cachedEdmType);
}
if (cachedEdmType == null)
{
Type collectionType;
bool isOpen = false;
if (EdmStructuredSchemaElements != null && EdmStructuredSchemaElements.Any())
{
IEdmStructuredType edmStructuredType = EdmStructuredSchemaElements.FirstOrDefault(et => et.Name == ClientTypeUtil.GetServerDefinedTypeName(type)) as IEdmStructuredType;
if (edmStructuredType != null)
{
isOpen = edmStructuredType.IsOpen;
}
}
if (PrimitiveType.IsKnownNullableType(type))
{
PrimitiveType primitiveType;
PrimitiveType.TryGetPrimitiveType(type, out primitiveType);
Debug.Assert(primitiveType != null, "primitiveType != null");
cachedEdmType = new EdmTypeCacheValue(primitiveType.CreateEdmPrimitiveType(), hasProperties);
}
else if ((collectionType = ClientTypeUtil.GetImplementationType(type, typeof(ICollection<>))) != null && ClientTypeUtil.GetImplementationType(type, typeof(IDictionary<,>)) == null)
{
// Collection Type
Type elementType = collectionType.GetGenericArguments()[0];
IEdmType itemType = this.GetOrCreateEdmType(elementType);
// Note that
// 1. throw here because collection of a collection is not allowed
// 2. will also throw during SaveChanges(), validated by unit test case 'SerializationOfCollection'in CollectionTests.cs.
if ((itemType.TypeKind == EdmTypeKind.Collection))
{
throw new ODataException(Strings.ClientType_CollectionOfCollectionNotSupported);
}
cachedEdmType = new EdmTypeCacheValue(new EdmCollectionType(itemType.ToEdmTypeReference(ClientTypeUtil.CanAssignNull(elementType))), hasProperties);
}
else
{
Type enumTypeTmp = null;
if (isEntity)
{
Action<EdmEntityTypeWithDelayLoadedProperties> delayLoadEntityProperties = (entityType) =>
{
// Create properties without modifying the entityType.
// This will leave entityType intact in case of an exception during loading.
List<IEdmProperty> loadedProperties = new List<IEdmProperty>();
List<IEdmStructuralProperty> loadedKeyProperties = new List<IEdmStructuralProperty>();
foreach (PropertyInfo property in ClientTypeUtil.GetPropertiesOnType(type, /*declaredOnly*/edmBaseType != null).OrderBy(p => p.Name))
{
IEdmProperty edmProperty = this.CreateEdmProperty((EdmStructuredType)entityType, property);
loadedProperties.Add(edmProperty);
if (edmBaseType == null && keyProperties.Any(k => k.DeclaringType == type && k.Name == property.Name))
{
Debug.Assert(edmProperty.PropertyKind == EdmPropertyKind.Structural, "edmProperty.PropertyKind == EdmPropertyKind.Structural");
Debug.Assert(edmProperty.Type.TypeKind() == EdmTypeKind.Primitive, "edmProperty.Type.TypeKind() == EdmTypeKind.Primitive");
loadedKeyProperties.Add((IEdmStructuralProperty)edmProperty);
}
}
// Now add properties to the entityType.
foreach (IEdmProperty property in loadedProperties)
{
entityType.AddProperty(property);
}
entityType.AddKeys(loadedKeyProperties);
};
// Creating an entity type
Debug.Assert(edmBaseType == null || edmBaseType.TypeKind == EdmTypeKind.Entity, "baseType == null || baseType.TypeKind == EdmTypeKind.Entity");
bool hasStream = GetHasStreamValue((IEdmEntityType)edmBaseType, type);
cachedEdmType = new EdmTypeCacheValue(
new EdmEntityTypeWithDelayLoadedProperties(CommonUtil.GetModelTypeNamespace(type), CommonUtil.GetModelTypeName(type), (IEdmEntityType)edmBaseType, c.PlatformHelper.IsAbstract(type), isOpen, hasStream, delayLoadEntityProperties),
hasProperties);
}
else if ((enumTypeTmp = Nullable.GetUnderlyingType(type) ?? type) != null
&& enumTypeTmp.IsEnum())
{
Action<EdmEnumTypeWithDelayLoadedMembers> delayLoadEnumMembers = (enumType) =>
{
#if DNXCORE50
foreach (FieldInfo tmp in enumTypeTmp.GetFields().Where(fieldInfo => fieldInfo.IsStatic))
#else
foreach (FieldInfo tmp in enumTypeTmp.GetFields(BindingFlags.Static | BindingFlags.Public))
#endif
{
object memberValue = Enum.Parse(enumTypeTmp, tmp.Name, false);
enumType.AddMember(new EdmEnumMember(enumType, tmp.Name, new EdmIntegerConstant((long)Convert.ChangeType(memberValue, typeof(long), CultureInfo.InvariantCulture.NumberFormat))));
//.........这里部分代码省略.........
示例4: GetOrCreateEdmTypeInternal
private EdmTypeCacheValue GetOrCreateEdmTypeInternal(IEdmStructuredType edmBaseType, Type type, PropertyInfo[] keyProperties, bool isEntity, bool? hasProperties)
{
EdmTypeCacheValue value2;
Action<MetadataProviderEdmEntityType> action3 = null;
Action<MetadataProviderEdmComplexType> action4 = null;
lock (this.clrToEdmTypeCache)
{
this.clrToEdmTypeCache.TryGetValue(type, out value2);
}
if (value2 == null)
{
if (PrimitiveType.IsKnownNullableType(type))
{
PrimitiveType type3;
PrimitiveType.TryGetPrimitiveType(type, out type3);
value2 = new EdmTypeCacheValue(type3.CreateEdmPrimitiveType(), hasProperties);
}
else
{
Type type2;
if (((type2 = ClientTypeUtil.GetImplementationType(type, typeof(ICollection<>))) != null) && (ClientTypeUtil.GetImplementationType(type, typeof(IDictionary<,>)) == null))
{
Type type4 = type2.GetGenericArguments()[0];
value2 = new EdmTypeCacheValue(new EdmCollectionType(this.GetOrCreateEdmTypeInternal(type4).EdmType.ToEdmTypeReference(ClientTypeUtil.CanAssignNull(type4))), hasProperties);
}
else if (isEntity)
{
if (action3 == null)
{
action3 = delegate (MetadataProviderEdmEntityType entityType) {
List<IEdmProperty> list = new List<IEdmProperty>();
List<IEdmStructuralProperty> list1 = new List<IEdmStructuralProperty>();
using (IEnumerator<PropertyInfo> enumerator = (from p in ClientTypeUtil.GetPropertiesOnType(type, edmBaseType != null)
orderby p.Name
select p).GetEnumerator())
{
Func<PropertyInfo, bool> predicate = null;
while (enumerator.MoveNext())
{
PropertyInfo property = enumerator.Current;
IEdmProperty item = this.CreateEdmProperty(entityType, property);
list.Add(item);
if (edmBaseType == null)
{
if (predicate == null)
{
predicate = k => (k.DeclaringType == type) && (k.Name == property.Name);
}
if (keyProperties.Any<PropertyInfo>(predicate))
{
list1.Add((IEdmStructuralProperty) item);
}
}
}
}
foreach (IEdmProperty property2 in list)
{
entityType.AddProperty(property2);
}
entityType.AddKeys(list1);
};
}
Action<MetadataProviderEdmEntityType> propertyLoadAction = action3;
value2 = new EdmTypeCacheValue(new MetadataProviderEdmEntityType(CommonUtil.GetModelTypeNamespace(type), CommonUtil.GetModelTypeName(type), (IEdmEntityType) edmBaseType, type.IsAbstract(), false, propertyLoadAction), hasProperties);
}
else
{
if (action4 == null)
{
action4 = delegate (MetadataProviderEdmComplexType complexType) {
List<IEdmProperty> list = new List<IEdmProperty>();
foreach (PropertyInfo info in from p in ClientTypeUtil.GetPropertiesOnType(type, edmBaseType != null)
orderby p.Name
select p)
{
IEdmProperty item = this.CreateEdmProperty(complexType, info);
list.Add(item);
}
foreach (IEdmProperty property2 in list)
{
complexType.AddProperty(property2);
}
};
}
Action<MetadataProviderEdmComplexType> action2 = action4;
value2 = new EdmTypeCacheValue(new MetadataProviderEdmComplexType(CommonUtil.GetModelTypeNamespace(type), CommonUtil.GetModelTypeName(type), (IEdmComplexType) edmBaseType, type.IsAbstract(), action2), hasProperties);
}
}
IEdmType edmType = value2.EdmType;
ClientTypeAnnotation orCreateClientTypeAnnotation = this.GetOrCreateClientTypeAnnotation(edmType, type);
edmType.SetClientTypeAnnotation(orCreateClientTypeAnnotation);
if ((edmType.TypeKind == EdmTypeKind.Entity) || (edmType.TypeKind == EdmTypeKind.Complex))
{
IEdmStructuredType edmStructuredType = edmType as IEdmStructuredType;
this.SetMimeTypeForProperties(edmStructuredType);
}
lock (this.clrToEdmTypeCache)
{
EdmTypeCacheValue value3;
if (this.clrToEdmTypeCache.TryGetValue(type, out value3))
//.........这里部分代码省略.........