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


C# XElement.SetAttributeValue方法代码示例

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


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

示例1: InitializeXml

        /// <summary>
        /// Initializes the xml descriptor for this effect.
        /// </summary>
        private void InitializeXml()
        {
            xml = new XDocument();
            var effect = new XElement("Effect");
            xml.Add(effect);

            var customEffectTypeInfo = customEffectType.GetTypeInfo();

            // Add 
            var customEffectAttribute = Utilities.GetCustomAttribute<CustomEffectAttribute>(customEffectTypeInfo, true);
            effect.Add(CreateXmlProperty("DisplayName", "string", customEffectAttribute != null ? customEffectAttribute.DisplayName : customEffectTypeInfo.Name));
            effect.Add(CreateXmlProperty("Author", "string", customEffectAttribute != null ? customEffectAttribute.Author : string.Empty));
            effect.Add(CreateXmlProperty("Category", "string", customEffectAttribute != null ? customEffectAttribute.Category : string.Empty));
            effect.Add(CreateXmlProperty("Description", "string", customEffectAttribute != null ? customEffectAttribute.Description : string.Empty));

            var inputs = new XElement("Inputs");
            var inputAttributes = Utilities.GetCustomAttributes<CustomEffectInputAttribute>(customEffectTypeInfo, true);
            foreach(var inputAttribute in inputAttributes) {
                var inputXml = new XElement("Input");
                inputXml.SetAttributeValue("name", inputAttribute.Input);
                inputs.Add(inputXml);
            }
            effect.Add(inputs);

            // Add custom properties
            foreach(var binding in Bindings) {
                var property = CreateXmlProperty(binding.PropertyName,  binding.TypeName);

                property.Add(CreateXmlProperty("DisplayName", "string", binding.PropertyName));
                property.Add(CreateXmlProperty("Min", binding.TypeName, binding.Attribute.Min != null ? binding.Attribute.Min.ToString() : string.Empty));
                property.Add(CreateXmlProperty("Max", binding.TypeName, binding.Attribute.Max != null ? binding.Attribute.Max.ToString() : string.Empty));
                property.Add(CreateXmlProperty("Default", binding.TypeName, binding.Attribute.Default != null ? binding.Attribute.Default.ToString() : string.Empty));

                effect.Add(property);
            }
        }
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:39,代码来源:CustomEffectFactory.cs

示例2: CreatingXElementsFromNewDev10Types

        public void CreatingXElementsFromNewDev10Types(object t, Type type)
        {
            XElement e = new XElement("e1", new XElement("e2"), "text1", new XElement("e3"), t);
            e.Add(t);
            e.FirstNode.ReplaceWith(t);

            XNode n = e.FirstNode.NextNode;
            n.AddBeforeSelf(t);
            n.AddAnnotation(t);
            n.ReplaceWith(t);

            e.FirstNode.AddAfterSelf(t);
            e.AddFirst(t);
            e.Annotation(type);
            e.Annotations(type);
            e.RemoveAnnotations(type);
            e.ReplaceAll(t);
            e.ReplaceAttributes(t);
            e.ReplaceNodes(t);
            e.SetAttributeValue("a", t);
            e.SetElementValue("e2", t);
            e.SetValue(t);

            XAttribute a = new XAttribute("a", t);
            XStreamingElement se = new XStreamingElement("se", t);
            se.Add(t);

            Assert.Throws<ArgumentException>(() => new XDocument(t));
            Assert.Throws<ArgumentException>(() => new XDocument(t));
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:30,代码来源:RegressionTests.cs

示例3: CreateXmlProperty

        private static XElement CreateXmlProperty(string name, string type, string value = null)
        {
            var property = new XElement("Property");
            property.SetAttributeValue("name", name);
            property.SetAttributeValue("type", type);
            if (value != null)
                property.SetAttributeValue("value", value);

            return property;
        }
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:10,代码来源:CustomEffectFactory.cs


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