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


C# AttributeList.Add方法代码示例

本文整理汇总了C#中AttributeList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeList.Add方法的具体用法?C# AttributeList.Add怎么用?C# AttributeList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AttributeList的用法示例。


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

示例1: VisitAttributeList

 public override AttributeList VisitAttributeList(AttributeList attributes)
 {
     AttributeList list = new AttributeList();
     for (int i = 0; i < attributes.Count; i++)
     {
         AttributeNode a = attributes[i];
         list.Add(VisitAttributeNode(a));
     }
     return list;
 }
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:10,代码来源:ZReplacer.cs

示例2: GetTag

		public Tag GetTag()
		{
			AttributeList attributes = new AttributeList();

			foreach(Attribute x in List)
			{
				attributes.Add((Attribute)x.Clone());
			}

            Tag retVal = new Tag(m_tag, attributes);

			return(retVal);
		}
开发者ID:hamoji,项目名称:sprajax,代码行数:13,代码来源:ParseHTML.cs

示例3: NewField

 private Field NewField(Identifier name, TypeNode type, Anonymity anon){
   AttributeList attrs = null;
   if (anon != Anonymity.Unknown && anon != Anonymity.None){
     attrs = new AttributeList(1);
     MemberBinding cons = new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor());
     TypeNode tn = SystemTypes.AnonymityEnum;
     AttributeNode attr = new AttributeNode(cons, new ExpressionList(new NamedArgument(idAnonymity, new Literal(anon, SystemTypes.AnonymityEnum))));
     attrs.Add(attr);
   }
   return new Field(null, attrs, FieldFlags.Public, name, type, null);
 }
开发者ID:dbremner,项目名称:specsharp,代码行数:11,代码来源:Resolver.cs

示例4: CreateAttributeList

 static AttributeList CreateAttributeList(TypeNode[] attributeTypes, AttributeTargets target){
   AttributeList list = new AttributeList(1);
   foreach (TypeNode t in attributeTypes){
     if (t != null){
       InstanceInitializer ctor = t.GetConstructor();
       if (ctor != null){
         list.Add(new AttributeNode(new MemberBinding(null, ctor), null, target));
       }
     }
   }
   return list;
 }
开发者ID:dbremner,项目名称:specsharp,代码行数:12,代码来源:Resolver.cs

示例5: ParseAttributes

 private AttributeList ParseAttributes(Namespace ns, TokenSet followers){
   if (this.currentToken != Token.LeftBracket) return null;
   AttributeList attributes = new AttributeList();
   bool allowGlobalAttributes = ns != null && ns.Name == Identifier.Empty &&
     (ns.NestedNamespaces == null || ns.NestedNamespaces.Count == 0) && (ns.Types == null || ns.Types.Count == 0);
   while(this.currentToken == Token.LeftBracket){
     SourceContext sctx = this.scanner.CurrentSourceContext;
     this.GetNextToken();
     AttributeTargets flags = (AttributeTargets)0;
     Identifier id = this.scanner.GetIdentifier();
     SourceContext attrCtx = this.scanner.CurrentSourceContext;
     switch(this.currentToken){
       case Token.Event:
       case Token.Identifier:
       case Token.Return:
         this.GetNextToken();
         if (this.currentToken == Token.Colon){
           this.GetNextToken();
           int key = id.UniqueIdKey;
           if (key == Parser.assemblyId.UniqueIdKey)
             flags = AttributeTargets.Assembly;
           else if (key == Parser.eventId.UniqueIdKey)
             flags = AttributeTargets.Event;
           else if (key == Parser.fieldId.UniqueIdKey)
             flags = AttributeTargets.Field;
           else if (key == Parser.methodId.UniqueIdKey)
             flags = AttributeTargets.Method|AttributeTargets.Constructor;
           else if (key == Parser.moduleId.UniqueIdKey)
             flags = AttributeTargets.Module;
           else if (key == Parser.paramId.UniqueIdKey)
             flags = AttributeTargets.Parameter;
           else if (key == Parser.propertyId.UniqueIdKey)
             flags = AttributeTargets.Property;
           else if (key == Parser.returnId.UniqueIdKey)
             flags = AttributeTargets.ReturnValue;
           else if (key == Parser.typeId.UniqueIdKey)
             flags = AttributeTargets.Class|AttributeTargets.Delegate|AttributeTargets.Enum|AttributeTargets.Interface|AttributeTargets.Struct;
           else{
             flags = (AttributeTargets)int.MaxValue;
             this.HandleError(Error.InvalidAttributeLocation, id.ToString());
           }
           id = this.scanner.GetIdentifier();
           this.SkipIdentifierOrNonReservedKeyword();
         }
         break;
       default:
         this.SkipIdentifierOrNonReservedKeyword();
         break;
     }
     for(;;){
       AttributeNode attr = new AttributeNode();
       attr.SourceContext = attrCtx;
       attr.Target = flags;
       if (this.currentToken == Token.DoubleColon){
         Identifier prefix = id;
         this.GetNextToken();
         id = this.scanner.GetIdentifier();
         id.Prefix = prefix;
         id.SourceContext.StartPos = prefix.SourceContext.StartPos;
         this.SkipIdentifierOrNonReservedKeyword();
       }
       if (this.sink != null) this.sink.StartName(id);
       if (this.currentToken == Token.Dot)
         attr.Constructor = this.ParseQualifiedIdentifier(id, followers|Token.Comma|Token.LeftParenthesis|Token.RightBracket);
       else
         attr.Constructor = id;
       this.ParseAttributeArguments(attr, followers|Token.Comma|Token.RightBracket);
       if (flags != (AttributeTargets)int.MaxValue){
         if (allowGlobalAttributes && (flags == AttributeTargets.Assembly || flags == AttributeTargets.Module)){
           if (ns.Attributes == null) ns.Attributes = new AttributeList();
           ns.Attributes.Add(attr);
         }else
           attributes.Add(attr);
       }
       if (this.currentToken != Token.Comma) break;
       this.GetNextToken();
       if (this.currentToken == Token.RightBracket) break;
       id = this.scanner.GetIdentifier();
       this.SkipIdentifierOrNonReservedKeyword();
     }
     this.ParseBracket(sctx, Token.RightBracket, followers, Error.ExpectedRightBracket);
   }
   this.SkipTo(followers);
   return attributes;
 }
开发者ID:dbremner,项目名称:specsharp,代码行数:85,代码来源:Parser.cs

示例6: Init

		public bool Init(DbHolder holder) {
			try {
				if (!File.Exists(_file)) return false;

				string dbRawName = Path.GetFileNameWithoutExtension(_file);
				string dbName = _toDbName(dbRawName.Replace("_db", ""));
				string[] lines = File.ReadAllLines(_file);
				string[] itemsRaw = null;
				bool waitOne = false;

				foreach (string line in lines) {
					string t = line;

					string[] raw = t.Replace("[,", ",[").Replace("{,", ",{").Split(',');

					if (waitOne && raw.Length <= 1) break;

					if (waitOne) {
						raw[0] = raw[0].TrimStart('/', ' ', '\t');
						itemsRaw = itemsRaw.Concat(raw).ToArray();
					}
					else {
						itemsRaw = raw;
					}

					if (itemsRaw.Length > 1) {
						int end = itemsRaw.Length - 1;
						itemsRaw[end] = itemsRaw[end].Contains("//") ? itemsRaw[end].Substring(0, itemsRaw[end].IndexOf("//", StringComparison.Ordinal)) : itemsRaw[end];
						waitOne = true;
					}
				}

				if (itemsRaw == null || itemsRaw.Length <= 1) return false;

				Dictionary<int, string> comments = new Dictionary<int, string>();

				foreach (string line in lines) {
					if (!line.StartsWith("//")) break;

					string bufLine = line.Trim('/', ' ');

					if (bufLine.Length > 2 && bufLine[2] == '.') {
						int ival;

						if (Int32.TryParse(bufLine.Substring(0, 2), out ival)) {
							string t = bufLine.Substring(3).Trim(' ', '\t');

							int index = t.LastIndexOf("  ", StringComparison.Ordinal);

							if (index > -1) {
								t = t.Substring(index);
							}
							else {
								index = t.LastIndexOf("\t\t", StringComparison.Ordinal);

								if (index > -1) {
									t = t.Substring(index);
								}
							}

							comments[ival] = t.Trim(' ', '\t');
						}
					}
				}

				List<string> items = itemsRaw.ToList();

				items[0] = items[0].TrimStart('/', ' ');
				items = items.ToList().Select(p => p.Trim(' ')).ToList();
				HashSet<int> variable = new HashSet<int>();

				if (items.Any(p => p == "...")) {
					// Find the longest line

					if (_hasLogic(items, variable)) { }
					else {
						int itemIndex = items.IndexOf("...");
						List<int> count = lines.Select(line => line.Split(',').Length).ToList();

						int missingArguments = count.Max(p => p) - items.Count;

						if (missingArguments == 0) {
							items[itemIndex] = "Unknown";
						}
						else if (missingArguments < 0) {
							items.RemoveAt(itemIndex);
						}
						else {
							items.RemoveAt(itemIndex);

							for (int i = 0; i < missingArguments; i++) {
								items.Insert(itemIndex, "Variable");
								variable.Add(itemIndex + i);
							}
						}
					}
				}

				if (items.Any(p => p.Contains('[')) || items.Any(p => p.Contains('{'))) {
					bool begin = false;
//.........这里部分代码省略.........
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:101,代码来源:DbMaker.cs

示例7: GetCustomAttributesFor

        private AttributeList/*!*/ GetCustomAttributesFor(int parentIndex)
        {
            CustomAttributeRow[] customAttributes = this.tables.CustomAttributeTable;
            AttributeList attributes = new AttributeList();
            try
            {
                int i = 0, n = customAttributes.Length, j = n - 1;
                if (n == 0) return attributes;
                bool sorted = (this.sortedTablesMask >> (int)TableIndices.CustomAttribute) % 2 == 1;
                if (sorted)
                {
                    while (i < j)
                    {
                        int k = (i + j) / 2;
                        if (customAttributes[k].Parent < parentIndex)
                            i = k + 1;
                        else
                            j = k;
                    }
                    while (i > 0 && customAttributes[i - 1].Parent == parentIndex) i--;
                }
                for (; i < n; i++)
                    if (customAttributes[i].Parent == parentIndex)
                        attributes.Add(this.GetCustomAttribute(i));
                    else if (sorted)
                        break;
            }
            catch (Exception e)
            {
                if (this.module == null) return attributes;
                if (this.module.MetadataImportErrors == null) this.module.MetadataImportErrors = new ArrayList();
                this.module.MetadataImportErrors.Add(e);
            }

            return attributes;
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:36,代码来源:Reader.cs

示例8: NoDefaultExpose

 static AttributeList NoDefaultExpose() {
   AttributeList list = new AttributeList(2);
   if (SystemTypes.NoDefaultContractAttribute != null) {
     list.Add(new AttributeNode(new Literal(SystemTypes.NoDefaultContractAttribute, SystemTypes.Type), null, AttributeTargets.Method));
   }
   return list;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:7,代码来源:Looker.cs

示例9: GetDelegateAttributes

  /// <summary>
  /// Get the attributes of a delegate
  /// DIEGO-TODO: Include code to try to get the attributes from the type itself
  /// </summary>
  /// <param name="v"></param>
  /// <returns></returns>
    protected AttributeList GetDelegateAttributes(Variable v) {
      Nodes ns = this.Values(v);
      AttributeList res = new AttributeList();
      
      // Obtain the set of fields or variables that may refer to the 
      // nodes pointed by v
      Set<Variable> vs = this.MayPoint(ns);
      Set<Node> VarOrFields = this.pointsToGraph.GetReferences(ns);
      foreach (Node vof in VarOrFields) {
        if (vof is Parameter) {
          Parameter p = (Parameter)vof;
          foreach (AttributeNode attr in p.Attributes)
            res.Add(attr);
          }
        // If it is a closure with get the attribute from the enclosing method
        if (vof is Field) {
          Field f = (Field)vof;
          if (PointsToAnalysis.IsCompilerGenerated(this.Method)) {
            PointsToState pts = this.pta.EnclosingState(this.Method.DeclaringType);
            if (pts != null) {
              Variable v1 = pts.GetVariableByName(f.Name.Name);
              if (v1 is Parameter) {
                Parameter p = (Parameter)v1;
                foreach (AttributeNode attr in p.Attributes)
                  res.Add(attr);
                }
              }
            }
          }

        }
      return res;
      }
开发者ID:hesam,项目名称:SketchSharp,代码行数:39,代码来源:PointsToAnalysis.cs

示例10: GetFilteredAttributes

 public virtual AttributeList GetFilteredAttributes(TypeNode attributeType)
 {
     if(attributeType == null)
         return this.Attributes;
     AttributeList attributes = this.Attributes;
     AttributeList filtered = new AttributeList();
     for(int i = 0, n = attributes == null ? 0 : attributes.Count; i < n; i++)
     {
         AttributeNode attr = attributes[i];
         if(attr == null)
             continue;
         MemberBinding mb = attr.Constructor as MemberBinding;
         if(mb != null)
         {
             if(mb.BoundMember != null && mb.BoundMember.DeclaringType == attributeType)
                 continue;
             filtered.Add(attr);
             continue;
         }
         Literal lit = attr.Constructor as Literal;
         if(lit != null && (lit.Value as TypeNode) == attributeType)
             continue;
         filtered.Add(attr);
     }
     return filtered;
 }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:26,代码来源:Nodes.cs

示例11: GetAttributes

 public virtual AttributeList GetAttributes(TypeNode attributeType, int maxCount)
 {
     AttributeList foundAttributes = new AttributeList();
     if(attributeType == null)
         return foundAttributes;
     AttributeList attributes = this.Attributes;
     for(int i = 0, count = 0, n = attributes == null ? 0 : attributes.Count; i < n && count < maxCount; i++)
     {
         AttributeNode attr = attributes[i];
         if(attr == null)
             continue;
         MemberBinding mb = attr.Constructor as MemberBinding;
         if(mb != null)
         {
             if(mb.BoundMember == null)
                 continue;
             if(mb.BoundMember.DeclaringType != attributeType)
                 continue;
             foundAttributes.Add(attr);
             count++;
             continue;
         }
         Literal lit = attr.Constructor as Literal;
         if(lit == null)
             continue;
         if((lit.Value as TypeNode) != attributeType)
             continue;
         foundAttributes.Add(attr);
         count++;
     }
     return foundAttributes;
 }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:32,代码来源:Nodes.cs

示例12: ParseAttributeList

        private void ParseAttributeList(AttributeList list, char term)
        {
            char ch = _current.SkipWhitespace();
            while (ch != term)
            {
                if (ch == '%')
                {
                    Entity e = ParseParameterEntity(_parameterEntityTerm);
                    PushEntity(_current.ResolvedUri, e);

                    ParseAttributeList(list, Entity.EOF);

                    PopEntity();
                    ch = _current.SkipWhitespace();
                }
                else if (ch == '-')
                {
                    ch = ParseDeclarationComments();
                }
                else
                {
                    AttributeDefinition a = ParseAttributeDefinition(ch);
                    list.Add(a);
                }
                ch = _current.SkipWhitespace();
            }
        }
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:27,代码来源:SgmlDtd.cs

示例13: VisitAttributeList

        public override AttributeList VisitAttributeList(AttributeList attributes)
        {
            if (attributes == null) return null;

            AttributeList rval = new AttributeList();

            for (int i = 0, n = attributes.Count; i < n; i++)
            {
                rval.Add(this.VisitAttributeNode(attributes[i]));
            }

            return rval;
        }
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:13,代码来源:ZChecker.cs

示例14: VisitAttributeList

 public virtual Differences VisitAttributeList(AttributeList list1, AttributeList list2,
   out AttributeList changes, out AttributeList deletions, out AttributeList insertions){
   changes = list1 == null ? null : list1.Clone();
   deletions = list1 == null ? null : list1.Clone();
   insertions = list1 == null ? new AttributeList() : list1.Clone();
   //^ assert insertions != null;
   Differences differences = new Differences();
   for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
     //^ assert list2 != null;
     AttributeNode nd2 = list2[j];
     if (nd2 == null) continue;
     insertions.Add(null);
   }
   TrivialHashtable savedDifferencesMapFor = this.differencesMapFor;
   this.differencesMapFor = null;
   TrivialHashtable matchedNodes = new TrivialHashtable();
   for (int i = 0, k = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     AttributeNode nd1 = list1[i]; 
     if (nd1 == null) continue;
     Differences diff;
     int j;
     AttributeNode nd2 = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out diff, out j);
     if (nd2 == null || diff == null){Debug.Assert(nd2 == null && diff == null); continue;}
     matchedNodes[nd1.UniqueKey] = nd1;
     matchedNodes[nd2.UniqueKey] = nd2;
     changes[i] = diff.Changes as AttributeNode;
     deletions[i] = diff.Deletions as AttributeNode;
     insertions[i] = diff.Insertions as AttributeNode;
     insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
     Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
     differences.NumberOfDifferences += diff.NumberOfDifferences;
     differences.NumberOfSimilarities += diff.NumberOfSimilarities;
   }
   //Find deletions
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     AttributeNode nd1 = list1[i]; 
     if (nd1 == null) continue;
     if (matchedNodes[nd1.UniqueKey] != null) continue;
     changes[i] = null;
     deletions[i] = nd1;
     insertions[i] = null;
     differences.NumberOfDifferences += 1;
   }
   //Find insertions
   for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
     //^ assert list2 != null;
     AttributeNode nd2 = list2[j]; 
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     insertions[n+j] = nd2;  //Records nd2 as an insertion into list1, along with its position in list2
     differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
   }
   if (differences.NumberOfDifferences == 0){
     changes = null;
     deletions = null;
     insertions = null;
   }
   this.differencesMapFor = savedDifferencesMapFor;
   return differences;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:62,代码来源:Comparer.cs

示例15: GetPermissionAttributes

 private AttributeList GetPermissionAttributes(int blobIndex, System.Security.Permissions.SecurityAction action)
 {
     AttributeList result = new AttributeList();
     int blobLength;
     MemoryCursor sigReader = this.tables.GetBlobCursor(blobIndex, out blobLength);
     if (blobLength == 0) return null;
     byte header = sigReader.ReadByte();
     if (header != (byte)'*')
     {
         if (header == (byte)'<') return null;
         if (header == (byte)'.') return this.GetPermissionAttributes2(blobIndex, action);
         HandleError(this.module, ExceptionStrings.BadSecurityPermissionSetBlob);
         return null;
     }
     sigReader.ReadInt32(); //Skip over the token for the attribute target
     sigReader.ReadInt32(); //Skip over the security action
     int numAttrs = sigReader.ReadInt32();
     for (int i = 0; i < numAttrs; i++)
         result.Add(this.GetPermissionAttribute(sigReader));
     return result;
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:21,代码来源:Reader.cs


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