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