• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ICustomAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Visit

 public override void Visit(ICustomAttribute attribute)
 {
     Visit(attribute.Type); // For some reason the base visitor doesn't visit the attribute type
     base.Visit(attribute);
 }
开发者ID:dsgouda,项目名称:buildtools,代码行数:5,代码来源:AssemblyReferenceTraverser.cs


示例17: Visit

 /// <summary>
 /// Performs some computation with the given custom attribute.
 /// </summary>
 public void Visit(ICustomAttribute customAttribute)
 {
     if (customAttribute.Constructor is Dummy)
       this.ReportError(MetadataError.IncompleteNode, customAttribute, "Constructor");
     else if (customAttribute.Type is Dummy)
       this.ReportError(MetadataError.IncompleteNode, customAttribute, "Type");
     else {
       if (!TypeHelper.TypesAreEquivalent(customAttribute.Constructor.ContainingType, customAttribute.Type))
     this.ReportError(MetadataError.CustomAttributeTypeIsNotConstructorContainer, customAttribute);
       if (customAttribute.Constructor.ResolvedMethod != Dummy.Method) {
     if (!customAttribute.Constructor.ResolvedMethod.IsConstructor)
       this.ReportError(MetadataError.CustomAttributeConstructorIsBadReference, customAttribute);
     if (!IteratorHelper.EnumerableHasLength(customAttribute.Arguments, customAttribute.Constructor.ResolvedMethod.ParameterCount)) {
       if (this.validator.currentSecurityAttribute == null || customAttribute.Constructor.ResolvedMethod.ParameterCount != 1 ||
     IteratorHelper.EnumerableIsNotEmpty(customAttribute.Arguments))
     this.ReportError(MetadataError.EnumerationCountIsInconsistentWithCountProperty, customAttribute, "Arguments");
     }
     //TODO: check that args match the types of the construtor param
       }
     }
     if (!IteratorHelper.EnumerableHasLength(customAttribute.NamedArguments, customAttribute.NumberOfNamedArguments))
       this.ReportError(MetadataError.EnumerationCountIsInconsistentWithCountProperty, customAttribute, "NamedArguments");
     //TODO: check that named args match the types of the attribute field/property.
 }
开发者ID:rasiths,项目名称:visual-profiler,代码行数:27,代码来源:Validator.cs


示例18: Include

 public virtual bool Include(ICustomAttribute attribute)
 {
     return true;
 }
开发者ID:dsgouda,项目名称:buildtools,代码行数:4,代码来源:AttributeMarkedFilter.cs


示例19: Visit

 /// <summary>
 /// Performs some computation with the given custom attribute.
 /// </summary>
 public virtual void Visit(ICustomAttribute customAttribute)
 {
 }
开发者ID:rasiths,项目名称:visual-profiler,代码行数:6,代码来源:Visitors.cs


示例20: TraverseChildren

 /// <summary>
 /// Traverses the children of the custom attribute.
 /// </summary>
 public virtual void TraverseChildren(ICustomAttribute customAttribute)
 {
     Contract.Requires(customAttribute != null);
       this.Traverse(customAttribute.Arguments);
       if (this.stopTraversal) return;
       this.Traverse(customAttribute.Constructor);
       if (this.stopTraversal) return;
       this.Traverse(customAttribute.NamedArguments);
 }
开发者ID:rasiths,项目名称:visual-profiler,代码行数:12,代码来源:Visitors.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICustomAttributeProvider类代码示例发布时间:2022-05-24
下一篇:
C# ICurve类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap