当前位置: 首页>>代码示例>>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;未经允许,请勿转载。