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


C# ICustomAttribute类代码示例

本文整理汇总了C#中ICustomAttribute的典型用法代码示例。如果您正苦于以下问题:C# ICustomAttribute类的具体用法?C# ICustomAttribute怎么用?C# ICustomAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ICustomAttribute类属于命名空间,在下文中一共展示了ICustomAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Include

        public override bool Include(ICustomAttribute attribute)
        {
            if (_attributeDocIds.Contains(attribute.DocId()))
                return false;

            return base.Include(attribute);
        }
开发者ID:TerabyteX,项目名称:buildtools,代码行数:7,代码来源:ExcludeAttributesFilter.cs

示例2: PrintAttribute

 public virtual void PrintAttribute(IReference target, ICustomAttribute attribute, bool newLine, string targetType) {
   this.sourceEmitterOutput.Write("[", newLine);
   if (targetType != null) {
     this.sourceEmitterOutput.Write(targetType);
     this.sourceEmitterOutput.Write(": ");
   }
   this.PrintTypeReferenceName(attribute.Constructor.ContainingType);
   if (attribute.NumberOfNamedArguments > 0 || IteratorHelper.EnumerableIsNotEmpty(attribute.Arguments)) {
     this.sourceEmitterOutput.Write("(");
     bool first = true;
     foreach (var argument in attribute.Arguments) {
       if (first)
         first = false;
       else
         this.sourceEmitterOutput.Write(", ");
       this.Traverse(argument);
     }
     foreach (var namedArgument in attribute.NamedArguments) {
       if (first)
         first = false;
       else
         this.sourceEmitterOutput.Write(", ");
       this.Traverse(namedArgument);
     }
     this.sourceEmitterOutput.Write(")");
   }
   this.sourceEmitterOutput.Write("]");
   if (newLine) this.sourceEmitterOutput.WriteLine("");
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:29,代码来源:AttributeSourceEmitter.cs

示例3: ScriptAttribute

        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        /// <param name="type">The attribute type.</param>
        /// <param name="attribute">The CCI attribute.</param>
        internal ScriptAttribute(ICustomAttribute attribute)
        {
            if (attribute == null)
                throw new InvalidOperationException();

            var typeRef = attribute.Type as INamedTypeReference;

            if (typeRef == null)
            {
                throw new InvalidOperationException("Attribute type must be a named type.");
            }

            var type = ScriptDomain.CurrentDomain.ResolveType(typeRef);

            if (type == null)
            {
                throw new InvalidOperationException("Unable to resolve type for attribute: " + typeRef.Name);
            }

            _type = type;
            _cciAttribute = attribute;

            _arguments = _cciAttribute.Arguments
                .Select(a => GetConstantValue(a)).ToArray();

            _namedArgs = _cciAttribute.NamedArguments.ToDictionary(a =>
                a.ArgumentName.Value, a => GetConstantValue(a));
        }
开发者ID:JimmyJune,项目名称:blade,代码行数:33,代码来源:ScriptAttribute.cs

示例4: GetCustomAttributes

 /// <summary>
 /// 
 /// </summary>
 /// <param name="customAttributeData"></param>
 /// <returns></returns>
 public IEnumerable<ICustomAttribute> GetCustomAttributes(IList<CustomAttributeData> customAttributeData) {
   int n = customAttributeData.Count;
   ICustomAttribute[] customAttributes = new ICustomAttribute[n];
   for (int i = 0; i < n; i++)
     customAttributes[i] = this.GetCustomAttribute(customAttributeData[i]);
   return IteratorHelper.GetReadonly(customAttributes);
 }
开发者ID:RUB-SysSec,项目名称:Probfuscator,代码行数:12,代码来源:Mapper.cs

示例5: Include

        public virtual bool Include(ICustomAttribute attribute)
        {
            if (this.ExcludeAttributes)
                return false;

            // Always return the custom attributes if ExcludeAttributes is not set
            // the PublicOnly mainly concerns the types and members.
            return true;
        }
开发者ID:pgavlin,项目名称:ApiTools,代码行数:9,代码来源:PublicOnlyCciFilter.cs

示例6: Include

        public bool Include(ICustomAttribute attribute)
        {
            string typeId = attribute.DocId();
            string removeUsages = "RemoveUsages:" + typeId;

            if (_docIds.Contains(removeUsages))
                return false;

            return _docIds.Contains(typeId);
        }
开发者ID:agocke,项目名称:buildtools,代码行数:10,代码来源:DocIdWhitelistFilter.cs

示例7: GetPropertyString

		static string GetPropertyString (ICustomAttribute attribute, string name)
		{
			if (!attribute.HasProperties)
				return String.Empty;

			foreach (var namedArg in attribute.Properties) {
				if (namedArg.Name == name) {
					return (namedArg.Argument.Value as string);
				}
			}
			return String.Empty;
		}
开发者ID:boothead,项目名称:mono-tools,代码行数:12,代码来源:SuppressMessageEngine.cs

示例8: TryGetPropertyArgument

		static bool TryGetPropertyArgument (ICustomAttribute attribute, string name, out CustomAttributeArgument argument)
		{
			foreach (var namedArg in attribute.Properties) {
				if (namedArg.Name == name) {
					argument = namedArg.Argument;
					return true;
				}
			}

			argument = default (CustomAttributeArgument);
			return false;
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:12,代码来源:SuppressMessageEngine.cs

示例9: Include

        public bool Include(ICustomAttribute attribute)
        {
            string typeId = attribute.DocId();
            string removeUsages = "RemoveUsages:" + typeId;

            // special case: attribute usage can be removed without removing 
            //               the attribute itself
            if (_docIds.Contains(removeUsages))
                return false;

            // include so long as it isn't in the exclude list.
            return !_docIds.Contains(typeId);
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:13,代码来源:DocIdExcludeListFilter.cs

示例10: GetTokenList

        public IEnumerable<SyntaxToken> GetTokenList(ICustomAttribute attribute, int indentLevel = -1)
        {
            EnsureTokenWriter();

            _tokenizer.ClearTokens();

            if (indentLevel != -1)
                _tokenizer.IndentLevel = indentLevel;

            _tokenWriter.WriteAttribute(attribute);

            return _tokenizer.ToTokenList();
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:13,代码来源:CSDeclarationHelper.cs

示例11: GetString

        public string GetString(ICustomAttribute attribute, int indentLevel = -1)
        {
            EnsureStringWriter();

            _string.Clear();

            if (indentLevel != -1)
                _stringWriter.SyntaxtWriter.IndentLevel = indentLevel;

            _stringWriter.WriteAttribute(attribute);

            return _string.ToString();
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:13,代码来源:CSDeclarationHelper.cs

示例12: TryGetAttributeByName

        /// <summary>
        /// Tries to find an attribue by name
        /// </summary>
        /// <param name="attributes"></param>
        /// <param name="attributeName"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static bool TryGetAttributeByName(
            IEnumerable<ICustomAttribute> attributes,
            string attributeName,
            out ICustomAttribute attribute)
        {
            Contract.Requires(!String.IsNullOrEmpty(attributeName));
            Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out attribute) != null);

            if (attributes == null) { attribute = null; return false; }
            foreach (var a in attributes)
            {
                if (AttributeMatchesByName(a, attributeName))
                {
                    attribute = a;
                    return true;
                }
            }
            attribute = null;
            return false;
        }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:27,代码来源:CcsHelper.cs

示例13: WriteAttribute

        public void WriteAttribute(ICustomAttribute attribute, string prefix = null, SecurityAction action = SecurityAction.ActionNil)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                Write(prefix);
                WriteSymbol(":");
            }
            WriteTypeName(attribute.Constructor.ContainingType, noSpace: true); // Should we strip Attribute from name?

            if (attribute.NumberOfNamedArguments > 0 || attribute.Arguments.Any() || action != SecurityAction.ActionNil)
            {
                WriteSymbol("(");
                bool first = true;

                if (action != SecurityAction.ActionNil)
                {
                    Write("System.Security.Permissions.SecurityAction." + action.ToString());
                    first = false;
                }

                foreach (IMetadataExpression arg in attribute.Arguments)
                {
                    if (!first) WriteSymbol(",", true);
                    WriteMetadataExpression(arg);
                    first = false;
                }

                foreach (IMetadataNamedArgument namedArg in attribute.NamedArguments)
                {
                    if (!first) WriteSymbol(",", true);
                    WriteIdentifier(namedArg.ArgumentName);
                    WriteSymbol("=");
                    WriteMetadataExpression(namedArg.ArgumentValue);
                    first = false;
                }
                WriteSymbol(")");
            }
        }
开发者ID:pgavlin,项目名称:ApiTools,代码行数:38,代码来源:CSDeclarationWriter.Attributes.cs

示例14: Include

        public virtual bool Include(ICustomAttribute attribute)
        {
            if (this.ExcludeAttributes)
                return false;

            // Ignore attributes not visible outside the assembly
            var attributeDef = attribute.Type.GetDefinitionOrNull();
            if (attributeDef != null && !attributeDef.IsVisibleOutsideAssembly())
                return false;

            // Ignore attributes with typeof argument of a type invisible outside the assembly
            foreach(var arg in attribute.Arguments.OfType<IMetadataTypeOf>())
            {
                var typeDef = arg.TypeToGet.GetDefinitionOrNull();
                if (typeDef == null)
                    continue;

                if (!typeDef.IsVisibleOutsideAssembly())
                    return false;
            }

            return true;
        }
开发者ID:ChadNedzlek,项目名称:buildtools,代码行数:23,代码来源:PublicOnlyCciFilter.cs

示例15: TraverseChildren

 public override void TraverseChildren(ICustomAttribute customAttribute) {
   // Different uses of custom attributes must print them directly based on context
   //base.TraverseChildren(customAttribute);
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:4,代码来源:ExpressionSourceEmitter.cs


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