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


C# XElement.Attr方法代码示例

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


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

示例1: FromXml

 private static IconDef FromXml(XElement xml, PackagePart part)
 {
     var icon = xml.Attr<string>("icon");
     if (icon != null)
         icon = part.GetRelationship(icon).TargetUri.OriginalString;
     return new IconDef { Icon = icon, Pattern = xml.Attr<string>("pattern")};
 }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:7,代码来源:IconDef.cs

示例2: LoadFromXml

        public static PropertyDef LoadFromXml(XElement xml)
        {
            var name = xml.Attr<string>("name");

            string kindStr = xml.Attr("textKind", "Free");
            PropertyTextKind kind;
            switch (kindStr)
            {
                case "Free":
                    kind = PropertyTextKind.FreeText;
                    break;
                case "Enum":
                    kind = PropertyTextKind.Enumeration;
                    break;
                case "Tokens":
                    kind = PropertyTextKind.Tokens;
                    break;
                default:
                    throw new InvalidFileFormatException(
                        string.Format("Unknown value '{0}' for textKind attribute (Property = {1})",
                                      kindStr, name));
            }

            return new PropertyDef
                       {
                           Name = name,
                           Type = xml.Attr<PropertyType>("type"),
                           IgnoreText = xml.Attr<bool>("ignoreText"),
                           TextKind = kind,
                           Hidden = xml.Attr<bool>("hidden")
                       };
        }
开发者ID:0M3G4,项目名称:OCTGN,代码行数:32,代码来源:PropertyDef.cs

示例3: ReadPackage

        private LoadPackage ReadPackage(XElement pkge) {
            var result = new LoadPackage {Code = pkge.Attr("code")};
            var level = pkge.Attr("level");
            if (!string.IsNullOrWhiteSpace(level)) {
                result.Level = (LoadLevel) Enum.Parse(typeof (LoadLevel), level, true);
            }

            result.Arm = pkge.Attr("arm","default");
            result.Command = pkge.Attr("command", "");
               

            var deps = pkge.Elements("uses");
            foreach (var dep in deps) {
                result.Dependency.Add(dep.Attr("code"));
            }
            foreach (var item in pkge.Elements("load")) {
                result.Items.Add(ReadItem(item));
            }
            foreach (var item in pkge.Elements("widget")) {
                ReadWidget(result, item);
            }


            return result;
        }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:25,代码来源:LoadPackageReader.cs

示例4: BoolToAttribute

        public void BoolToAttribute() {
            var el = new XElement("data");
            el.Attr("foo", true);
            el.Attr("bar", false);

            Assert.That(el.Attribute("foo").Value, Is.EqualTo("true"));
            Assert.That(el.Attribute("bar").Value, Is.EqualTo("false"));
        }
开发者ID:RasterImage,项目名称:Orchard,代码行数:8,代码来源:XmlHelperTests.cs

示例5: LoadFromXml

 internal static DeckSectionDef LoadFromXml(XElement xml)
 {
     return new DeckSectionDef
                {
                    Name = xml.Attr<string>("name"),
                    Group = xml.Attr<string>("group")
                };
 }
开发者ID:rexperalta,项目名称:OCTGN,代码行数:8,代码来源:DeckDef.cs

示例6: LoadFromXml

 internal static new At LoadFromXml(XElement xml)
 {
     return new At
       {
     group = xml.Attr<string>("group"),
     position = xml.Attr<string>("position")
       };
 }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:8,代码来源:CardFilters.cs

示例7: LoadFromXml

        internal static CardDef LoadFromXml(XElement xml, PackagePart part)
        {
            var backUri = xml.Attr<string>("back");
            if (backUri != null) backUri = part.GetRelationship(backUri).TargetUri.OriginalString;

            var frontUri = xml.Attr<string>("front");
            if (frontUri != null) frontUri = part.GetRelationship(frontUri).TargetUri.OriginalString;

            var cd = new CardDef
                       {
                           back = backUri,
                           front = frontUri,
                           Width = xml.Attr<int>("width"),
                           Height = xml.Attr<int>("height"),
                           CornerRadius = xml.Attr<int>("cornerRadius"),
                           //Properties = xml.Elements(Defs.XmlnsOctgn + "property")
                           //    //.Select(PropertyDef.LoadFromXml)
                           //    .ToDictionary(x => x.Name)
                       };
            var list = xml.Elements(Defs.XmlnsOctgn + "property");
            var proplist = new Dictionary<string,PropertyDef>();
            foreach (var l in list)
            {
                var name = l.Attr<string>("name");

                string kindStr = l.Attr("textKind", "Free");
                PropertyTextKind kind;
                switch (kindStr)
                {
                    case "Free":
                        kind = PropertyTextKind.FreeText;
                        break;
                    case "Enum":
                        kind = PropertyTextKind.Enumeration;
                        break;
                    case "Tokens":
                        kind = PropertyTextKind.Tokens;
                        break;
                    default:
                        throw new InvalidFileFormatException(
                            string.Format("Unknown value '{0}' for textKind attribute (Property = {1})",
                                          kindStr, name));
                }

                var prop = new PropertyDef
                {
                    Name = name,
                    Type = l.Attr<PropertyType>("type"),
                    IgnoreText = l.Attr<bool>("ignoreText"),
                    TextKind = kind,
                    Hidden = l.Attr<bool>("hidden")
                };
                proplist.Add(name,prop);
            }
            cd.Properties = proplist;
            return cd;
        }
开发者ID:voidbeast,项目名称:OCTGN,代码行数:57,代码来源:CardDef.cs

示例8: XsltTask

 public XsltTask(IBSharpProject project, XElement definition)
 {
     this.Project = project;
     this.TemplateUri = new Uri(definition.Attr("template"));
     this.ClassSelector = new Uri(definition.Attr("selector"));
     this.Batch = definition.Attr("batch").ToBool();
     this.OutputPath = new Uri(definition.Attr("output"));
     this.NoXml = definition.Attr("noxml").ToBool();
     this._resolver = new ProjectUriResolver(project);
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:10,代码来源:XsltTask.cs

示例9: ContextSwitch

        public void ContextSwitch()
        {
            var el = new XElement("data");
            el.With(new {foo = "bar"})
                .ToAttr(o => o.foo)
                .With(new {bar = "baz"})
                .ToAttr(o => o.bar);

            Assert.That(el.Attr<string>("foo"), Is.EqualTo("bar"));
            Assert.That(el.Attr<string>("bar"), Is.EqualTo("baz"));
        }
开发者ID:gokhandisikara,项目名称:Coevery-Framework,代码行数:11,代码来源:XmlHelperTests.cs

示例10: LoadFromXml

 internal static new AddMarker LoadFromXml(XElement xml)
 {
     var res = new AddMarker
       {
     markerId = xml.Attr<Guid?>("id", null),
     markerName = xml.Attr<string>("name"),
     quantity = xml.Attr<string>("qty", "1")
       };
       res.LoadBaseFromXml(xml);
       return res;
 }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:11,代码来源:ScriptActions.cs

示例11: Execute

		public override void Execute(XElement el){
			string[] codes = Split
				                 ? el.Attr("code").SmartSplit(false, true, ',', '/', ';', ' ').ToArray()
				                 : new[]{el.Attr("code")};
			string value = el.Value;
			foreach (string code in codes){
				lock (_project.Global){
					_project.Global.Set(code, value);
				}
			}
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:11,代码来源:PushToGlobalOperation.cs

示例12: LoadFromXml

 internal new static ActionDef LoadFromXml(XElement xml)
 {
     return new ActionDef
                {
                    Name = xml.Attr<string>("menu"),
                    DefaultAction = xml.Attr<bool>("default"),
                    Shortcut = xml.Attr<string>("shortcut"),
                    Execute = xml.Attr<string>("execute"),
                    BatchExecute = xml.Attr<string>("batchExecute")
                };
 }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:11,代码来源:ActionDef.cs

示例13: Resource

 internal Resource(ResourceSet parent, XElement xe)
 {
     ParentSet = parent;
     Path = xe.Attr<string>(SchemaConstants.Resource.Path);
     Mode = xe.Attr(SchemaConstants.Resource.Mode, Default.Resource.Mode);
     ForwardCookie = xe.Attr(SchemaConstants.Resource.ForwardCookie,
         Default.Resource.ForwardCookie);
     Minifier = ParentSet.Type == ResourceType.JS
         ? ModelUtils.LoadMinifier(xe, SchemaConstants.Resource.MinifierRef, ParentSet.Minifier.Name, ParentSet.Settings.JSMinifierMap)
         : ModelUtils.LoadMinifier(xe, SchemaConstants.Resource.MinifierRef, ParentSet.Minifier.Name, ParentSet.Settings.CssMinifierMap);
     if (Mode == ResourceMode.Static && ForwardCookie)
         throw new XmlSchemaException("ForwardCookie must not be True when Mode is Static");
 }
开发者ID:sithy,项目名称:Raid-Points-System-.NET,代码行数:13,代码来源:Resource.cs

示例14: RenameElement

 private void RenameElement(XElement gj, XElement e, XElement[] selection)
 {
     var targetattr = gj.Attr("targetattr");
     var newname = gj.Attr("newname");
     foreach(var s in selection)
     {
         if (!string.IsNullOrWhiteSpace(targetattr))
         {
             s.SetAttributeValue(targetattr, s.Name.LocalName);
         }
         s.Name = newname;
     }
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:13,代码来源:UniversalJsonBuilder.cs

示例15: ReadWidget

 private void ReadWidget(LoadPackage result, XElement item) {
     var level = LoadLevel.Guest;
     var levele = item.Attr("level");
     if (!string.IsNullOrWhiteSpace(levele))
     {
         level = (LoadLevel)Enum.Parse(typeof(LoadLevel), levele, true);
     }
     var code = item.Attr("code");
     var command = item.Attr("command");
     result.Items.Add(new LoadItem {Level = level, Command=command, Type = LoadItemType.Script, Value = code + ".js"});
     result.Items.Add(new LoadItem { Level = level, Command=command, Type = LoadItemType.Style, Value = code + ".css" });
     result.Items.Add(new LoadItem { Level = level, Command = command, Type = LoadItemType.Template, Value = code + ".tpl.html" });
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:13,代码来源:LoadPackageReader.cs


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