當前位置: 首頁>>代碼示例>>C#>>正文


C# AttributeTargets類代碼示例

本文整理匯總了C#中AttributeTargets的典型用法代碼示例。如果您正苦於以下問題:C# AttributeTargets類的具體用法?C# AttributeTargets怎麽用?C# AttributeTargets使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AttributeTargets類屬於命名空間,在下文中一共展示了AttributeTargets類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetAttributeUsage

		private void GetAttributeUsage()
		{
			if (analyzedType.HasCustomAttributes) {
				foreach (CustomAttribute ca in analyzedType.CustomAttributes) {
					TypeReference t = ca.AttributeType;
					if (t.Name == "AttributeUsageAttribute" && t.Namespace == "System") {
						this.usage = (AttributeTargets)ca.ConstructorArguments[0].Value;
						if (ca.ConstructorArguments.Count > 1) {
							this.allowMutiple = (bool)ca.ConstructorArguments[1].Value;
							this.inherited = (bool)ca.ConstructorArguments[2].Value;
						}
						if (ca.HasProperties) {
							foreach (var namedArgument in ca.Properties) {
								switch (namedArgument.Name) {
									case "AllowMultiple":
										this.allowMutiple = (bool)namedArgument.Argument.Value;
										break;
									case "Inherited":
										this.inherited = (bool)namedArgument.Argument.Value;
										break;
								}
							}
						}
					}
				}
			}
		}
開發者ID:FaceHunter,項目名稱:ILSpy,代碼行數:27,代碼來源:AnalyzedAttributeAppliedToTreeNode.cs

示例2: AttributeGen

		internal AttributeGen(AttributeTargets target, AttributeType attributeType, object[] args)
		{
			if (args != null)
			{
				foreach (object arg in args)
				{
					CheckValue(arg);
				}
			}

			// TODO: target validation

			this.attributeType = attributeType;

			Operand[] argOperands;
			if (args == null || args.Length == 0)
			{
				this.args = EmptyArray<object>.Instance;
				argOperands = Operand.EmptyArray;
			}
			else
			{
				this.args = args;
				argOperands = new Operand[args.Length];
				for (int i = 0; i < args.Length; i++)
				{
					argOperands[i] = GetOperand(args[i]);
				}
			}

			this.ctor = TypeInfo.FindConstructor(attributeType, argOperands);
		}
開發者ID:amithasan,項目名稱:Framework-Class-Library-Extension,代碼行數:32,代碼來源:AttributeGen.cs

示例3: GetAttributeUsage

		void GetAttributeUsage() {
			if (analyzedType.HasCustomAttributes) {
				foreach (CustomAttribute ca in analyzedType.CustomAttributes) {
					ITypeDefOrRef t = ca.AttributeType;
					if (t != null && t.Name == "AttributeUsageAttribute" && t.Namespace == "System" &&
						ca.ConstructorArguments.Count > 0 &&
						ca.ConstructorArguments[0].Value is int) {
						usage = (AttributeTargets)ca.ConstructorArguments[0].Value;
						if (ca.ConstructorArguments.Count > 2) {
							if (ca.ConstructorArguments[1].Value is bool)
								allowMutiple = (bool)ca.ConstructorArguments[1].Value;
							if (ca.ConstructorArguments[2].Value is bool)
								inherited = (bool)ca.ConstructorArguments[2].Value;
						}
						foreach (var namedArgument in ca.Properties) {
							switch (namedArgument.Name) {
							case "AllowMultiple":
								if (namedArgument.Argument.Value is bool)
									allowMutiple = (bool)namedArgument.Argument.Value;
								break;
							case "Inherited":
								if (namedArgument.Argument.Value is bool)
									inherited = (bool)namedArgument.Argument.Value;
								break;
							}
						}
					}
				}
			}
		}
開發者ID:manojdjoshi,項目名稱:dnSpy,代碼行數:30,代碼來源:AttributeAppliedToNode.cs

示例4: AttributeBlockNode

 public AttributeBlockNode(Token token,
                           AttributeTargets location,
                           ParseNodeList attributes)
     : base(ParseNodeType.AttributeBlock, token) {
     _location = location;
     _attributes = GetParentedNodeList(attributes);
 }
開發者ID:fugaku,項目名稱:scriptsharp,代碼行數:7,代碼來源:AttributeBlockNode.cs

示例5: AttributeUsageAttribute

 internal AttributeUsageAttribute(AttributeTargets validOn, bool allowMultiple, bool inherited)
 {
     this.m_attributeTarget = AttributeTargets.All;
     this.m_inherited = true;
     this.m_attributeTarget = validOn;
     this.m_allowMultiple = allowMultiple;
     this.m_inherited = inherited;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:8,代碼來源:AttributeUsageAttribute.cs

示例6: AttributeUsageTest

 public AttributeUsageTest(MemberInfo member,
                           AttributeTargets validOn,
                           bool allowMultiple,
                           bool inherited)
     : base(member)
 {
     ValidOn = validOn;
     AllowMultiple = allowMultiple;
     Inherited = inherited;
 }
開發者ID:KarlDirck,項目名稱:cavity,代碼行數:10,代碼來源:AttributeUsageTest.cs

示例7: AttributeCanBeAppliedToCodeElementsSupportedBySubstituteAttributeRelay

 public void AttributeCanBeAppliedToCodeElementsSupportedBySubstituteAttributeRelay(AttributeTargets expectedTarget)
 {
     // Fixture setup
     var attributeUsage = typeof(SubstituteAttribute).GetCustomAttributes(false)
         .OfType<AttributeUsageAttribute>().Single();
     // Exercise system
     Assert.Equal(expectedTarget, attributeUsage.ValidOn & expectedTarget);
     // Verify outcome
     // Teardown
 }
開發者ID:RyanLiu99,項目名稱:AutoFixture,代碼行數:10,代碼來源:SubstituteAttributeTest.cs

示例8: AttributeUsageInfo

        internal AttributeUsageInfo(AttributeTargets validTargets, bool allowMultiple, bool inherited)
        {
            // NOTE: VB allows AttributeUsageAttribute with no valid target, i.e. <AttributeUsageAttribute(0)>, and doesn't generate any diagnostics.
            // We use use PackedAttributeUsage.Initialized field to differentiate between uninitialized AttributeUsageInfo and initialized AttributeUsageInfo with no valid targets.
            flags = (PackedAttributeUsage)validTargets | PackedAttributeUsage.Initialized;
            
            if (allowMultiple)
            {
                flags |= PackedAttributeUsage.AllowMultiple;
            }

            if (inherited)
            {
                flags |= PackedAttributeUsage.Inherited;
            }
        }
開發者ID:modulexcite,項目名稱:pattern-matching-csharp,代碼行數:16,代碼來源:AttributeUsageInfo.cs

示例9: AttributeUsageAttribute

		public AttributeUsageAttribute (AttributeTargets validOn)
		{
			valid_on = validOn;
		}
開發者ID:runefs,項目名稱:Marvin,代碼行數:4,代碼來源:AttributeUsageAttribute.cs

示例10: GetAttributeTargetName

 public virtual string GetAttributeTargetName(AttributeTargets targets) {
   if (this.ErrorHandler == null) return "";
   return this.ErrorHandler.GetAttributeTargetName(targets);
 }
開發者ID:hesam,項目名稱:SketchSharp,代碼行數:4,代碼來源:Checker.cs

示例11: AttributeUsageAttribute

 public AttributeUsageAttribute(AttributeTargets validOn)
 {
     this.validOn = validOn;
 }
開發者ID:davidleon,項目名稱:MOSA-Project,代碼行數:4,代碼來源:Core.cs

示例12: AttributeUsageAttribute

 public AttributeUsageAttribute(AttributeTargets validOn) { }
開發者ID:ehsansajjad465,項目名稱:roslyn,代碼行數:1,代碼來源:aacorlib.v15.0.3928.cs

示例13: InvalidAttributeTarget

 public static CompilerError InvalidAttributeTarget(Node node, Type attrType, AttributeTargets validOn)
 {
     return new CompilerError("BCE0153", SafeLexicalInfo(node), attrType, validOn);
 }
開發者ID:w4x,項目名稱:boolangstudio,代碼行數:4,代碼來源:CompilerErrorFactory.cs

示例14: ParseAttributeUsageAttribute

 [System.Security.SecurityCritical]  // auto-generated
 private static void ParseAttributeUsageAttribute(
     ConstArray ca, out AttributeTargets targets, out bool inherited, out bool allowMultiple)
 {
     int _targets;
     _ParseAttributeUsageAttribute(ca.Signature, ca.Length, out _targets, out inherited, out allowMultiple);
     targets = (AttributeTargets)_targets;
 }
開發者ID:enavro,項目名稱:coreclr,代碼行數:8,代碼來源:CustomAttribute.cs

示例15: NonInheritedAttribute

			public NonInheritedAttribute(Type type, string str, int i, AttributeTargets e):
				this(type, str)
			{
			}
開發者ID:MajidSafari,項目名稱:bltoolkit,代碼行數:4,代碼來源:GenerateAtributeTest.cs


注:本文中的AttributeTargets類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。