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


C# XElement.GetValue方法代码示例

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


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

示例1: FillObjectData

        /// <summary>
        /// Fills the object data.
        /// </summary>
        /// <param name="xml">The XML.</param>
        protected override void FillObjectData(XElement xml)
        {
            base.FillObjectData(xml);

            this.Event =xml.GetValue( nodeName_Event);
            this.EventKey =xml.GetValue( nodeName_EventKey);
        }
开发者ID:supertigerzou,项目名称:TigerArtStudio,代码行数:11,代码来源:EventMessage.cs

示例2: FillObjectData

        /// <summary>
        /// Fills the object data.
        /// </summary>
        /// <param name="xml">The XML.</param>
        protected override void FillObjectData(XElement xml)
        {
            base.FillObjectData(xml);

            this.Url = xml.GetValue(nodeName_Url);
            this.Title = xml.GetValue(nodeName_Title);
            this.Description = xml.GetValue(nodeName_Description);
        }
开发者ID:supertigerzou,项目名称:TigerArtStudio,代码行数:12,代码来源:LinkMessage.cs

示例3: FromXml

        public static Argument FromXml(XElement container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return new Argument
            {
                Name = container.GetValue(uPnpNamespaces.svc + "name"),
                Direction = container.GetValue(uPnpNamespaces.svc + "direction"),
                RelatedStateVariable = container.GetValue(uPnpNamespaces.svc + "relatedStateVariable")                
            };
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:14,代码来源:Argument.cs

示例4: MetaListItemInfo

        public MetaListItemInfo(XElement node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            _path = node.GetValue("id");
            _parent = node.GetValue("parent_id");
            _modified = node.GetValue("updated_time");
            _isDir = node.GetValue("type") == "folder";

            Title = node.GetValue("name");
            Notes = GetRelativeTime(_modified);
            Icon = ThemeData.GetImage(_isDir
                ? "folder" : "entry");
        }
开发者ID:rgmills,项目名称:7Pass,代码行数:15,代码来源:MetaListItemInfo.cs

示例5: MakeReportNode

        public static bool MakeReportNode(XElement source, bool? compatibleValue=false)
        {
            if ((source.GetValue("Compatible")!=null && compatibleValue==null) ||
                (source.GetValue("Compatible") == compatibleValue.ToString().ToLowerInvariant()))
            {
                source.Elements().Where(e => e.Name != "Parameter" && e.Name != "Accessor").Remove();
                return true;
            }

            if (!source.HasElements)
                return false;

            source.Elements().Where(e => !MakeReportNode(e,compatibleValue)).Remove();
            return source.HasElements;
        }
开发者ID:vlad-zapp,项目名称:AssemblyChecker,代码行数:15,代码来源:Report.cs

示例6: Create

        public static uBaseObject Create(XElement container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return new uBaseObject
            {
                Id = container.GetAttributeValue(uPnpNamespaces.Id),
                ParentId = container.GetAttributeValue(uPnpNamespaces.ParentId),
                Title = container.GetValue(uPnpNamespaces.title),
                IconUrl = container.GetValue(uPnpNamespaces.Artwork),
                UpnpClass = container.GetValue(uPnpNamespaces.uClass)
            };
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:16,代码来源:UpnpContainer.cs

示例7: AreCompatible

        //One generic compatibility check for all. Needed for reports and stuff
        public static bool AreCompatible(XElement first, XElement second)
        {
            //get method parameters
            IEnumerable<string> params1 = first.Elements("Parameter").Select(m => m.Attribute("Type").Value).ToArray();
            IEnumerable<string> params2 = second.Elements("Parameter").Select(m => m.Attribute("Type").Value).ToArray();

            //TODO: optimization?
            return
                //whatever: check tag names
                first.Name.LocalName == second.Name.LocalName &&
                //whatever: check names
                first.GetValue("Name") == second.GetValue("Name") &&
                //whatever: static or not
                first.GetValue("Static") == second.GetValue("Static") &&
                //classes: path
                first.GetValue("Path") == second.GetValue("Path") &&
                //classes: abstract or not
                first.GetValue("Abstract") == second.GetValue("Abstract") &&
                //fields&properties: check type
                first.GetValue("Type") == second.GetValue("Type") &&
                //methods: check return type
                first.GetValue("ReturnType") == second.GetValue("ReturnType") &&
                //enums: check value
                first.GetValue("Value") == second.GetValue("Value") &&
                //methods: check parameters
                Enumerable.SequenceEqual(params1, params2) &&
                //Check properties Accessors
                first.Elements("Accessor").All(m => second.Elements("Accessor").Any(n => AreCompatible(m, n)));
        }
开发者ID:vlad-zapp,项目名称:AssemblyChecker,代码行数:30,代码来源:Check.cs

示例8: Empty_value_returns_default_type

        public void Empty_value_returns_default_type()
        {
            var element = new XElement("foo", "");

            int expected = 0;
            var actual = element.GetValue<int>();

            Assert.AreEqual(expected, actual);
        }
开发者ID:paulkearney,项目名称:brnkly,代码行数:9,代码来源:XElementExtensionsTests.cs

示例9: Value_of_element_is_returned_of_type_according_to_generic_invocation

        public void Value_of_element_is_returned_of_type_according_to_generic_invocation()
        {
            var element = new XElement("foo", "42");

            double expected = 42;
            var actual = element.GetValue<double>();

            Assert.AreEqual(expected, actual);
        }
开发者ID:paulkearney,项目名称:brnkly,代码行数:9,代码来源:XElementExtensionsTests.cs

示例10: Create

        public static uBaseObject Create(XElement container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return new uBaseObject
            {
                Id = container.Attribute(uPnpNamespaces.Id).Value,
                ParentId = container.Attribute(uPnpNamespaces.ParentId).Value,
                Title = container.GetValue(uPnpNamespaces.title),
                IconUrl = container.GetValue(uPnpNamespaces.Artwork),
                SecondText = "",
                Url = container.GetValue(uPnpNamespaces.Res),
                ProtocolInfo = GetProtocolInfo(container),
                MetaData = container.ToString()
            };
        }
开发者ID:Tensre,项目名称:MediaBrowser,代码行数:19,代码来源:uBaseObject.cs

示例11: FromXml

        public static StateVariable FromXml(XElement container)
        {
            var allowedValues = new List<string>();
            var element = container.Descendants(uPnpNamespaces.svc + "allowedValueList")
                .FirstOrDefault();
            
            if (element != null)
            {
                var values = element.Descendants(uPnpNamespaces.svc + "allowedValue");

                allowedValues.AddRange(values.Select(child => child.Value));
            }

            return new StateVariable
            {
                Name = container.GetValue(uPnpNamespaces.svc + "name"),
                DataType = container.GetValue(uPnpNamespaces.svc + "dataType"),
                AllowedValues = allowedValues
            };
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:20,代码来源:StateVariable.cs

示例12: MetaListItemInfo

        public MetaListItemInfo(XElement node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            _path = node.GetValue("id");
            _parent = node.GetValue("parent_id");
            _modified = node.GetValue("updated_time");
            var type = node.GetValue("type");
            if(string.IsNullOrEmpty(type))
            {
                type = "file";
            }
            _isDir = "folder|album".Contains(type); // Show folder icon in case of folder/album
            int.TryParse(node.GetValue("size"), out _size);

            Title = node.GetValue("name") ?? "";
            Notes = GetRelativeTime(_modified);
            string iconStr = "";
            iconStr = Title.EndsWith(".kdbx",StringComparison.InvariantCultureIgnoreCase) // If its keepass database
                ? "keepasslogo"
                : (_isDir
                    ? "folder"
                    : "entry");

            Icon = ThemeData.GetImage(iconStr);
        }
开发者ID:gkardava,项目名称:WinPass,代码行数:27,代码来源:MetaListItemInfo.cs

示例13: ApplyPatch

        public static void ApplyPatch(XElement source, XElement patch)
        {
            if (patch == null)
                return;

            source.SetAttributeValue("Compatible", patch.GetValue("Compatible"));

            foreach (XElement element in source.Elements().ExceptAccessorsAndParameters())
            {
                ApplyPatch(element, patch.Elements(element.Name.LocalName).
                                        ExceptAccessorsAndParameters().SingleOrDefault(e => Check.AreCompatible(element, e)));

            }
        }
开发者ID:vlad-zapp,项目名称:AssemblyChecker,代码行数:14,代码来源:Dump.cs

示例14: FromXml

        public static ServiceAction FromXml(XElement container)
        {
            var argumentList = new List<Argument>();

            foreach (var arg in container.Descendants(uPnpNamespaces.svc + "argument"))
            {
                argumentList.Add(Argument.FromXml(arg));
            }
            
            return new ServiceAction
            {
                Name = container.GetValue(uPnpNamespaces.svc + "name"),

                ArgumentList = argumentList
            };
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:16,代码来源:ServiceAction.cs

示例15: MetaListItemInfo

        public MetaListItemInfo(XElement node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            _path = node.GetValue("id");
            _parent = node.GetValue("parent_id");
            _modified = node.GetValue("updated_time");
            _isDir = "folder|album".Contains(node.GetValue("type")); // Show folder icon in case of folder/album
            int.TryParse(node.GetValue("size"), out _size);

            Title = node.GetValue("name");
            Notes = GetRelativeTime(_modified);
            string iconStr = "";
            iconStr = Title.EndsWith(".kdbx") // If its keepass database
                ? "keepasslogo"
                : (_isDir
                    ? "folder"
                    : "entry");

            Icon = ThemeData.GetImage(iconStr);
        }
开发者ID:oldlaurel,项目名称:WinPass,代码行数:22,代码来源:MetaListItemInfo.cs


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