本文整理汇总了C#中ICustomAttributeProvider.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# ICustomAttributeProvider.IsDefined方法的具体用法?C# ICustomAttributeProvider.IsDefined怎么用?C# ICustomAttributeProvider.IsDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICustomAttributeProvider
的用法示例。
在下文中一共展示了ICustomAttributeProvider.IsDefined方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTypeConverter
protected IJsonTypeConverter CreateTypeConverter(ICustomAttributeProvider provider)
{
if (provider.IsDefined(typeof(JsonConvertAttribute), false))
{
JsonConvertAttribute convAttr = (JsonConvertAttribute)provider.GetCustomAttributes(typeof(JsonConvertAttribute), false)[0];
return CreateTypeConverter(convAttr);
}
return null;
}
示例2: Process
public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, IConfiguration config)
{
if (metaData is IPropertyData)
{
IPropertyData property = (IPropertyData)metaData;
if (attributeProvider.IsDefined(typeof(XmlIgnoreAttribute), false))
property.Ignored = true;
}
}
示例3: GetIsRtimplFromCache
private static bool GetIsRtimplFromCache(ICustomAttributeProvider cap)
{
lock (_isRtimplCache)
{
if (!_isRtimplCache.ContainsKey(cap))
{
_isRtimplCache.Add(cap, cap.IsDefined(typeof(RtimplAttribute), false));
}
return _isRtimplCache[cap];
}
}
示例4: TryCreate
public static IPropertyEditor TryCreate(Type type, ICustomAttributeProvider attributes)
{
if (type.IsNullableType()) {
return new NullablePropertyEditor(type.GetGenericArguments()[0]);
}
if (attributes != null &&
type.IsClass && attributes.IsDefined(typeof(InspectorNullableAttribute), /*inherit:*/true)) {
return new NullablePropertyEditor(type);
}
return null;
}
示例5: IsByVal
public virtual bool IsByVal(ICustomAttributeProvider icap)
{
return icap.IsDefined (typeof (ByValAttribute), false);
}
示例6: IsDefined
internal static bool IsDefined (ICustomAttributeProvider obj, Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException ("attributeType");
AttributeUsageAttribute usage = null;
do {
if (IsUserCattrProvider (obj))
return obj.IsDefined (attributeType, inherit);
if (IsDefinedInternal (obj, attributeType))
return true;
object[] pseudoAttrs = GetPseudoCustomAttributes (obj, attributeType);
if (pseudoAttrs != null) {
for (int i = 0; i < pseudoAttrs.Length; ++i)
if (attributeType.IsAssignableFrom (pseudoAttrs[i].GetType ()))
return true;
}
if (usage == null) {
if (!inherit)
return false;
usage = RetrieveAttributeUsage (attributeType);
if (!usage.Inherited)
return false;
}
obj = GetBase (obj);
} while (obj != null);
return false;
}
示例7: IsDeprecated
public static bool IsDeprecated(ICustomAttributeProvider attrProvider)
{
return attrProvider.IsDefined (typeof (ObsoleteAttribute), true);
}
示例8: IsTypeHierarchyBase
private static bool IsTypeHierarchyBase(ICustomAttributeProvider type)
{
if (type.IsDefined(typeof(JoinedBaseAttribute), false))
{
return true;
}
object[] attrs = type.GetCustomAttributes(typeof(ActiveRecordAttribute), false);
if (attrs != null && attrs.Length > 0)
{
ActiveRecordAttribute att = (ActiveRecordAttribute) attrs[0];
return att.DiscriminatorColumn != null;
}
return false;
}
示例9: IsActiveRecordType
/// <summary>
/// Return true if the type has a [ActiveRecord] attribute
/// </summary>
private static bool IsActiveRecordType(ICustomAttributeProvider type)
{
return type.IsDefined(typeof(ActiveRecordAttribute), false);
}
示例10: IsNonAction
protected override bool IsNonAction(ICustomAttributeProvider action)
{
return action.IsDefined(typeof(NonActionAttribute), inherit: true);
}
示例11: IsRequired
private static bool IsRequired(ICustomAttributeProvider property)
{
return property.IsDefined(typeof(RequiredAttribute), false);
}
示例12: IsDefined
internal static bool IsDefined (ICustomAttributeProvider obj, Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException ("attributeType");
if (IsUserCattrProvider (obj))
return obj.IsDefined (attributeType, inherit);
if (IsDefinedInternal (obj, attributeType))
return true;
object[] pseudoAttrs = GetPseudoCustomAttributes (obj, attributeType);
if (pseudoAttrs != null) {
for (int i = 0; i < pseudoAttrs.Length; ++i)
if (attributeType.IsAssignableFrom (pseudoAttrs [i].GetType ()))
return true;
}
#if ONLY_1_1
if (inherit) {
AttributeUsageAttribute usage = RetrieveAttributeUsage (attributeType);
if (!usage.Inherited)
inherit = false;
}
#endif
// FIXME (bug #82431):
// on 2.0 profile we should always walk the inheritance
// chain and base the behavior on the inheritance level:
//
// 0 : return true if "attributeType" is assignable from
// any of the custom attributes
//
// > 0: return true if "attributeType" is assignable from
// any of the custom attributes and AttributeUsageAttribute
// .Inherited of the assignable attribute is true
ICustomAttributeProvider btype;
if (inherit && ((btype = GetBase (obj)) != null))
return IsDefined (btype, attributeType, inherit);
return false;
}
示例13: DescriptionOf
private static string DescriptionOf(ICustomAttributeProvider property)
{
if (property.IsDefined(typeof(DescriptionAttribute), false))
{
var attribute = (DescriptionAttribute) property.GetCustomAttributes(typeof(DescriptionAttribute), false)[0];
return attribute.Value;
}
return string.Empty;
}
示例14: CreateType
public TypeSpec CreateType (Type type, TypeSpec declaringType, ICustomAttributeProvider ca, int dynamicCursor, bool canImportBaseType)
{
TypeSpec spec;
if (import_cache.TryGetValue (type, out spec)) {
if (ca == null)
return spec;
if (type == typeof (object)) {
if (IsDynamicType (ca, dynamicCursor))
return InternalType.Dynamic;
return spec;
}
if (!spec.IsGeneric)
return spec;
#if NET_4_0
if (!ca.IsDefined (typeof (DynamicAttribute), false))
#endif
return spec;
// We've found same object in the cache but this one has a dynamic custom attribute
// and it's most likely dynamic version of same type IFoo<object> agains IFoo<dynamic>
// Do resolve the type process again in that case
}
if (type.IsGenericType && !type.IsGenericTypeDefinition) {
var type_def = type.GetGenericTypeDefinition ();
var targs = CreateGenericArguments (0, type.GetGenericArguments (), ca, dynamicCursor + 1);
if (declaringType == null) {
// Simple case, no nesting
spec = CreateType (type_def, null, null, 0, canImportBaseType);
spec = spec.MakeGenericType (targs);
} else {
//
// Nested type case, converting .NET types like
// A`1.B`1.C`1<int, long, string> to typespec like
// A<int>.B<long>.C<string>
//
var nested_hierarchy = new List<TypeSpec> ();
while (declaringType.IsNested) {
nested_hierarchy.Add (declaringType);
declaringType = declaringType.DeclaringType;
}
int targs_pos = 0;
if (declaringType.Arity > 0) {
spec = declaringType.MakeGenericType (targs.Skip (targs_pos).Take (declaringType.Arity).ToArray ());
targs_pos = spec.Arity;
} else {
spec = declaringType;
}
for (int i = nested_hierarchy.Count; i != 0; --i) {
var t = nested_hierarchy [i - 1];
spec = MemberCache.FindNestedType (spec, t.Name, t.Arity);
if (t.Arity > 0) {
spec = spec.MakeGenericType (targs.Skip (targs_pos).Take (spec.Arity).ToArray ());
targs_pos += t.Arity;
}
}
string name = type.Name;
int index = name.IndexOf ('`');
if (index > 0)
name = name.Substring (0, index);
spec = MemberCache.FindNestedType (spec, name, targs.Length - targs_pos);
if (spec.Arity > 0) {
spec = spec.MakeGenericType (targs.Skip (targs_pos).ToArray ());
}
}
// Don't add generic type with dynamic arguments, they can interfere with same type
// using object type arguments
if (!spec.HasDynamicElement) {
// Add to reading cache to speed up reading
if (!import_cache.ContainsKey (type))
import_cache.Add (type, spec);
}
return spec;
}
Modifiers mod;
MemberKind kind;
var ma = type.Attributes;
switch (ma & TypeAttributes.VisibilityMask) {
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
mod = Modifiers.PUBLIC;
break;
case TypeAttributes.NestedPrivate:
mod = Modifiers.PRIVATE;
break;
case TypeAttributes.NestedFamily:
mod = Modifiers.PROTECTED;
//.........这里部分代码省略.........
示例15: IsDefined
public static bool IsDefined(ICustomAttributeProvider provider, Type attributeType)
{
return provider.IsDefined(attributeType, true);
}