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


C# AttributeCollection類代碼示例

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


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

示例1: TestNoSiblingsFound

        public void TestNoSiblingsFound()
        {
            string namespaceUri = "namespaceUri";
              string localName = "localname";
              string qualifiedName = "qualifiedname";
              Mock<IElement> parent = null;
              IList<IElement> children = new List<IElement>();
              AttributeCollection attributes = new AttributeCollection();
              Element element = new Element(namespaceUri, localName, qualifiedName, parent as IElement, children, attributes);
              Assert.IsNull(element.PreviousSibling);
              namespaceUri = "namespaceUri";
              localName = "localname";
              qualifiedName = "qualifiedname";
              parent = new Mock<IElement>();
              children = new List<IElement>();
              attributes = new AttributeCollection();
              element = new Element(namespaceUri, localName, qualifiedName, parent as IElement, children, attributes);

              IList<IElement> parentChildren = new List<IElement>();
              parent.Setup(c => c.ChildElements).Returns(parentChildren);

              var previousSiblingStub = new Mock<IElement>();
              parentChildren.Add(element);
              Assert.IsNull(element.PreviousSibling);
        }
開發者ID:hanson-andrew,項目名稱:RockSolidIoc,代碼行數:25,代碼來源:ElementFixture.cs

示例2: TestParse

        public void TestParse()
        {
            var saxHandler = new Mock<ISaxHandler>();

              using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
              {
            memoryStream.Write(new System.Text.UTF8Encoding().GetBytes(_xmlToParse), 0, _xmlToParse.Length);
            memoryStream.Position = 0;

            SaxReaderImpl saxReaderImpl = new SaxReaderImpl();
            saxReaderImpl.Parse(new System.IO.StreamReader(memoryStream), saxHandler.Object);
              }

              AttributeCollection element3Attributes = new AttributeCollection();
              Attribute attr1Attribute = new Attribute();
              attr1Attribute.LocalName = "attr1";
              attr1Attribute.QName = "attr1";
              attr1Attribute.Uri = string.Empty;
              attr1Attribute.Value = "val1";
              element3Attributes.Add("attr1", attr1Attribute);

              saxHandler.Verify(c => c.StartDocument(), Times.Exactly(1));
              saxHandler.Verify(c => c.EndDocument(), Times.Exactly(1));
              saxHandler.Verify(c => c.StartElement(string.Empty, "root", "root", new AttributeCollection()));
              saxHandler.Verify(c => c.StartElement(string.Empty, "element1", "element1", new AttributeCollection()));
              saxHandler.Verify(c => c.StartElement(string.Empty, "element2", "element2", new AttributeCollection()));
              saxHandler.Verify(c => c.StartElement(string.Empty, "element3", "element3", element3Attributes));
              saxHandler.Verify(c => c.EndElement(string.Empty, "root", "root"));
              saxHandler.Verify(c => c.EndElement(string.Empty, "element1", "element1"));
              saxHandler.Verify(c => c.EndElement(string.Empty, "element2", "element2"));
              saxHandler.Verify(c => c.EndElement(string.Empty, "element3", "element3"));
              saxHandler.Verify(c => c.Characters(It.IsAny<char[]>(), It.IsAny<int>(), It.IsAny<int>()));
        }
開發者ID:hanson-andrew,項目名稱:RockSolidIoc,代碼行數:33,代碼來源:SaxReadersImplFixture.cs

示例3: CollectionSyncProperties

        public void CollectionSyncProperties()
        {
            AttributeCollection collection = new AttributeCollection(null);

            Assert.Null(((ICollection)collection).SyncRoot);
            Assert.False(((ICollection)collection).IsSynchronized);
        }
開發者ID:ChuangYang,項目名稱:corefx,代碼行數:7,代碼來源:AttributeCollectionTests.cs

示例4: CreateFormatter

            public static IFormatter CreateFormatter(this ScriptScope scriptScope, string className,
                AttributeCollection attributes)
            {
                if (scriptScope.Engine.Setup.Names.Contains("Python")) return new PythonFormatter(className, attributes);

                return new RubyFormatter(className, attributes);
            }
開發者ID:mdrubin,項目名稱:dynamic-script-control,代碼行數:7,代碼來源:ScriptConverter.cs

示例5: SimilarityDataEdge

 /// <summary>
 /// Initialzies a new instance of Berico.LinkAnalysis.Model.Edge with
 /// the provided source and target nodes.  The source and target nodes
 /// can not be null and can not be the same.
 /// </summary>
 /// <param name="initialWeight">The precalculated weight value</param>
 /// <param name="_source">The source Node for this edge</param>
 /// <param name="_target">The target Node for this edge</param>
 /// <param name="_attributes">An existing AttributeCollection instance</param> 
 public SimilarityDataEdge(double initialWeight, INode _sourceNode, INode _targetNode, AttributeCollection _attributes)
     : base(_sourceNode, _targetNode, _attributes)
 {
     // Set the initial weight.  This will be the similarity value that
     // was calculated before this edge was created
     this.weight = initialWeight;
 }
開發者ID:senfo,項目名稱:snaglV2,代碼行數:16,代碼來源:SimilarityDataEdge.cs

示例6: importFile

        private PolicyDocumentEntity importFile(baseData vData,string title, string filepath)
        {
            AttributeCollection acoll = new AttributeCollection();
            acoll.GetMulti(AttributeFields.Name == "Literal");
            if (acoll.Count == 0)
                throw new Exception("can't find literal attribute");
            m_literalAttribute = acoll[0];

            XmlDocument doc = new XmlDocument();
            doc.Load(filepath);

            PolicyDocumentEntity pde = new PolicyDocumentEntity();
            pde.LibraryId = vData.Library.Id;
            pde.Name = title;

            PolicyLinkEntity ple = new PolicyLinkEntity();
            ple.Policy = new PolicyEntity();
            ple.Policy.LibraryId = pde.LibraryId;
            pde.PolicyLink = ple;

            XmlNode policySet = doc.SelectSingleNode("policy-set");
            if (policySet != null)
                loadPolicySet(1,title,ple,policySet);
            else
            {
                XmlNode policy = doc.SelectSingleNode("policy");
                loadPolicy(1,title,ple,policy);
            }

            pde.Save(true);

            return pde;
        }
開發者ID:habibvirji,項目名稱:Webinos-Platform,代碼行數:33,代碼來源:importController.cs

示例7: FetchAll

 public AttributeCollection FetchAll()
 {
     AttributeCollection coll = new AttributeCollection();
     Query qry = new Query(Attribute.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
開發者ID:89sos98,項目名稱:dashcommerce-3,代碼行數:7,代碼來源:AttributeController.cs

示例8: Rule

        internal Rule( string name )
        {
            Check.IsNotNullOrWhitespace ( name, () => Name );
            Name = name;

            _attributes = new AttributeCollection ();
        }
開發者ID:divyang4481,項目名稱:REM,代碼行數:7,代碼來源:Rule.cs

示例9: ObjectProperty

 /// <summary> 表示一個可以獲取或者設置其內容的對象屬性
 /// </summary>
 /// <param name="property">屬性信息</param>
 public ObjectProperty(PropertyInfo property)
 {
     Field = false;
     MemberInfo = property; //屬性信息
     OriginalType = property.PropertyType;
     var get = property.GetGetMethod(true); //獲取屬性get方法,不論是否公開
     var set = property.GetSetMethod(true); //獲取屬性set方法,不論是否公開
     if (set != null) //set方法不為空
     {
         CanWrite = true; //屬性可寫
         Static = set.IsStatic; //屬性是否為靜態屬性
         IsPublic = set.IsPublic;
     }
     if (get != null) //get方法不為空
     {
         CanRead = true; //屬性可讀
         Static = get.IsStatic; //get.set隻要有一個靜態就是靜態
         IsPublic = IsPublic || get.IsPublic;
     }
     ID = System.Threading.Interlocked.Increment(ref Literacy.Sequence);
     UID = Guid.NewGuid();
     Init();
     TypeCodes = TypeInfo.TypeCodes;
     Attributes = new AttributeCollection(MemberInfo);
     var mapping = Attributes.First<IMemberMappingAttribute>();
     if (mapping != null)
     {
         MappingName = mapping.Name;
     }
 }
開發者ID:Skycweb,項目名稱:blqw-Faller,代碼行數:33,代碼來源:ObjectProperty.cs

示例10: TestTextlessConstructor

        public void TestTextlessConstructor()
        {
            string namespaceUri = "namespaceUri";
              string localName = "localname";
              string qualifiedName = "qualifiedname";
              var parent = new Mock<IElement>();
              List<IElement> children = new List<IElement>();
              AttributeCollection attributes = new AttributeCollection();
              Element element = new Element(namespaceUri, localName, qualifiedName, parent.Object, children, attributes);

              for (int i = 0; i < 10; i++)
              {
            children.Add(new Mock<IElement>() as IElement);
              }

              IList<IElement> parentChildren = new List<IElement>();
              parent.Setup(c => c.ChildElements).Returns(parentChildren);

              var previousSiblingStub = new Mock<IElement>();
              parentChildren.Add(previousSiblingStub.Object);
              parentChildren.Add(element);

              Assert.AreEqual(element.Attributes, attributes);
              Assert.AreEqual(element.ChildElements, children);
              Assert.AreEqual(element.FirstElement, children[0]);
              Assert.IsTrue(element.HasChildNodes);
              Assert.AreEqual(element.LastElement, children[9]);
              Assert.AreEqual(element.LocalName, localName);
              Assert.AreEqual(element.Name, qualifiedName);
              Assert.AreEqual(element.NamespaceUri, namespaceUri);
              Assert.AreEqual(element.ParentElement, parent.Object);
              Assert.AreEqual(element.PreviousSibling, previousSiblingStub.Object);
              Assert.AreEqual(element.TextContent, string.Empty);
        }
開發者ID:hanson-andrew,項目名稱:RockSolidIoc,代碼行數:34,代碼來源:ElementFixture.cs

示例11: TestAddingExistingAttribute

        public void TestAddingExistingAttribute()
        {
            bool exceptionThrown;
            AttributeCollection attributes = new AttributeCollection();
            AttributeValue newAttributeValue = new AttributeValue("Test Value");

            // Add attribute and attribute value
            attributes.Add("Test", newAttributeValue);

            Assert.AreEqual<string>(newAttributeValue.Value, attributes["Test"].Value);

            AttributeValue existingAttributeValue = new AttributeValue("Test Value");

            try
            {
                attributes.Add("Test", existingAttributeValue);
                exceptionThrown = false;
            }
            catch (ArgumentException)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }
開發者ID:senfo,項目名稱:snaglV2,代碼行數:25,代碼來源:AttributeCollectionTests.cs

示例12: Element

        public Element(string name, string text, params IAttribute[] attributes)
        {
            this._Name = name;
            this._Attributes = new AttributeCollection(attributes);
            this._Children = new NodeCollection(new Text(text));

            
        }
開發者ID:rportela,項目名稱:com.eixox.csharp.core,代碼行數:8,代碼來源:Element.cs

示例13: Merge

	public static AttributeCollection Merge(this AttributeCollection left, AttributeCollection right) {
		var result = new AttributeCollection {
			Base = left.Base.Merge(right.Base),
			Mult = left.Mult.Merge(right.Mult)
		};

		return result;
	}
開發者ID:dangerozov,項目名稱:globalgamejam2016,代碼行數:8,代碼來源:AttributeCollection.cs

示例14: Apply

	public static AttributeCollection Apply(AttributeCollection attributes) {
		AttributeCollection result =  new AttributeCollection().Merge(attributes);

		foreach (var formula in _formulas) {
			result.Base [formula.Key] = result.Base.TryGetValue (formula.Key).GetValueOrDefault (0) + formula.Value (result);
		}

		return result;
	}
開發者ID:dangerozov,項目名稱:globalgamejam2016,代碼行數:9,代碼來源:AttributeFormulas.cs

示例15: EnsureAttributes

		private void EnsureAttributes ()
		{
			if (attributes == null) {
				attrBag = new StateBag (true);
				if (IsTrackingViewState)
					attrBag.TrackViewState ();
				attributes = new AttributeCollection (attrBag);
			}
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:9,代碼來源:UserControl.cs


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