当前位置: 首页>>代码示例>>C#>>正文


C# ICustomAttributeProvider.IsDefined方法代码示例

本文整理汇总了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;
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:9,代码来源:TypeConverterAttributeProcessor.cs

示例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;
     }
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:9,代码来源:XmlIgnoreAttributeProcessor.cs

示例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];
            }
        }
开发者ID:xeno-by,项目名称:elf4b,代码行数:12,代码来源:ReflectionHelper.cs

示例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;
        }
开发者ID:JoeYarnall,项目名称:something-new,代码行数:13,代码来源:NullablePropertyEditor.cs

示例5: IsByVal

 public virtual bool IsByVal(ICustomAttributeProvider icap)
 {
     return icap.IsDefined (typeof (ByValAttribute), false);
 }
开发者ID:shana,项目名称:cppinterop,代码行数:4,代码来源:Attributes.cs

示例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;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:34,代码来源:MonoCustomAttrs.cs

示例7: IsDeprecated

 public static bool IsDeprecated(ICustomAttributeProvider attrProvider)
 {
     return attrProvider.IsDefined (typeof (ObsoleteAttribute), true);
 }
开发者ID:ermshiperete,项目名称:dbus-sharp,代码行数:4,代码来源:Mapper.cs

示例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;
		}
开发者ID:joshrobb,项目名称:Castle.ActiveRecord,代码行数:18,代码来源:ActiveRecordStarter.cs

示例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);
		}
开发者ID:joshrobb,项目名称:Castle.ActiveRecord,代码行数:7,代码来源:ActiveRecordStarter.cs

示例10: IsNonAction

 protected override bool IsNonAction(ICustomAttributeProvider action)
 {
     return action.IsDefined(typeof(NonActionAttribute), inherit: true);
 }
开发者ID:brettveenstra,项目名称:MvcCodeRouting,代码行数:4,代码来源:MvcControllerInfo.cs

示例11: IsRequired

 private static bool IsRequired(ICustomAttributeProvider property)
 {
     return property.IsDefined(typeof(RequiredAttribute), false);
 }
开发者ID:rh,项目名称:optional,代码行数:4,代码来源:Option.cs

示例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;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:43,代码来源:MonoCustomAttrs.Original.cs

示例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;
 }
开发者ID:rh,项目名称:optional,代码行数:9,代码来源:Option.cs

示例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;
//.........这里部分代码省略.........
开发者ID:davidwaters,项目名称:mono,代码行数:101,代码来源:import.cs

示例15: IsDefined

 public static bool IsDefined(ICustomAttributeProvider provider, Type attributeType)
 {
     return provider.IsDefined(attributeType, true);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:CustomAttribute.cs


注:本文中的ICustomAttributeProvider.IsDefined方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。