本文整理汇总了C#中System.Reflection.PropertyInfo.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.HasAttribute方法的具体用法?C# PropertyInfo.HasAttribute怎么用?C# PropertyInfo.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.HasAttribute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldSerialize
static bool ShouldSerialize(PropertyInfo pi)
{
var ts = pi.GetCustomAttribute<InTypeScriptAttribute>();
if (ts != null)
{
var v = ts.GetInTypeScript();
if (v.HasValue)
return v.Value;
}
if (pi.HasAttribute<HiddenPropertyAttribute>() || pi.HasAttribute<ExpressionFieldAttribute>())
return false;
return true;
}
示例2: createParameter
public static Parameter createParameter(PropertyInfo propertyInfo, IRouteDefinition route)
{
var parameter = new Parameter
{
name = propertyInfo.Name,
dataType = propertyInfo.PropertyType.Name,
paramType = "post",
allowMultiple = false,
required = propertyInfo.HasAttribute<RequiredAttribute>(),
description = propertyInfo.GetAttribute<DescriptionAttribute>(a => a.Description),
defaultValue = propertyInfo.GetAttribute<DefaultValueAttribute>(a => a.Value.ToString()),
allowableValues = getAllowableValues(propertyInfo)
};
if (route.Input.RouteParameters.Any(r => r.Name == propertyInfo.Name))
parameter.paramType = "path";
if (route.Input.QueryParameters.Any(r => r.Name == propertyInfo.Name))
parameter.paramType = "query";
return parameter;
}
示例3: Matches
public override bool Matches(PropertyInfo property)
{
return property.HasAttribute<ConnectionStringAttribute>();
}
示例4: Matches
public bool Matches(PropertyInfo property)
{
return property.HasAttribute<MapFromWebPathAttribute>();
}
示例5: Matches
public override bool Matches(PropertyInfo property)
{
return property.HasAttribute<MapWebToPhysicalPathAttribute>();
}
示例6: InspectedProperty
/// <summary>
/// Initializes a new instance of the <see cref="InspectedProperty"/> class.
/// </summary>
/// <param name="type">
/// The inspected type.
/// </param>
/// <param name="propertyInfo">
/// The property info.
/// </param>
/// <exception cref="ArgumentNullException">
/// If <paramref name="type"/> is null.
/// </exception>
/// <exception cref="ArgumentNullException">
/// If <paramref name="propertyInfo"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// If <paramref name="propertyInfo"/> 's declaring type has not been set.
/// </exception>
internal InspectedProperty(Type type, PropertyInfo propertyInfo)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
if (propertyInfo == null)
{
throw new ArgumentNullException("propertyInfo");
}
if (propertyInfo.DeclaringType == null)
{
throw new ArgumentException("fieldInfo declaring type has not been set");
}
this.Name = propertyInfo.SerializableName();
this.InspectedType = type;
this.PropertyType = propertyInfo.PropertyType;
this.IsNotNullableValueType = this.PropertyType.IsNotNullableValueType();
if (propertyInfo.DeclaringType != propertyInfo.ReflectedType)
{
propertyInfo = propertyInfo.DeclaringType.GetProperty(propertyInfo.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
try
{
this.Getter = DelegateFactory.CreateGetter(propertyInfo);
this.Setter = DelegateFactory.CreateSetter(propertyInfo);
}
catch (Exception exception)
{
Logging.TraceException(exception);
}
this.Member = propertyInfo;
#if!HT4O_SERIALIZATION
this.IdAttribute = propertyInfo.GetAttribute<IdAttribute>();
#endif
this.IsTransient = propertyInfo.HasAttribute<TransientAttribute>() || propertyInfo.HasAttribute<IgnoreDataMemberAttribute>();
this.Ignore = propertyInfo.HasAttribute<IgnoreAttribute>();
}
示例7: Matches
public bool Matches(PropertyInfo property)
{
return property.HasAttribute<BindingAttribute>();
}
示例8: Matches
public bool Matches(PropertyInfo property)
{
return property.HasAttribute<ExpandEnvironmentVariablesAttribute>();
}
示例9: ShouldBeIncluded
bool ShouldBeIncluded(PropertyInfo info)
{
return info.HasAttribute<ArgumentAttribute>();
}
示例10: CreateValueProvider
public static IValueProvider CreateValueProvider(object editableObject, PropertyInfo propertyInfo)
{
IValueProvider result = null;
if (propertyInfo.HasAttribute<PropertyGridCustomValueProvider>())
{
var attribute = propertyInfo.GetAttribute<PropertyGridCustomValueProvider>();
var derivedType = attribute.CustomValueProviderType;
var instance = (PropertyValue)Activator.CreateInstance(derivedType);
instance.Property = propertyInfo;
instance.Parent = editableObject;
instance.Type = propertyInfo.PropertyType;
return instance;
}
else if (propertyInfo.PropertyType.HasInterface<IValueProvider>()
&& (result = (IValueProvider)propertyInfo.GetValue(editableObject, null)) != null)
{
return result;
}
else
{
return new PropertyValue(propertyInfo, editableObject);
}
}
示例11: HasDoNotWireAttribute
private static bool HasDoNotWireAttribute(PropertyInfo property)
{
return property.HasAttribute<DoNotWireAttribute>();
}
示例12: IsDecoratedWithDoNotNotifyChangesAttribute
private static bool IsDecoratedWithDoNotNotifyChangesAttribute(PropertyInfo propertyInfo)
{
return (propertyInfo != null && propertyInfo.HasAttribute<DoNotNotifyChangesAttribute>());
}