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


C# XElement.GetAttributeValue方法代码示例

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


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

示例1: GetDefinitionColors

        private ColorPair GetDefinitionColors(XElement fontElement)
        {
            var foreColor = Color.FromName(fontElement.GetAttributeValue("foreColor"));
            var backColor = Color.FromName(fontElement.GetAttributeValue("backColor"));

            return new ColorPair(foreColor, backColor);
        }
开发者ID:thomasjo,项目名称:highlight,代码行数:7,代码来源:XmlConfiguration.cs

示例2: Configure

        public void Configure(XElement xml)
        {
            EventLogSource = xml.GetAttributeValue("EventLogSource");

            EntryFormatter =
                ConstructOrDefault<IEntryConverter<string>>(xml.GetAttributeValue("Formatter", "EntryFormatter"));
        }
开发者ID:ajayanandgit,项目名称:Logging-1,代码行数:7,代码来源:EventLogLogger.cs

示例3: UpdateTreeViewItem

        public static void UpdateTreeViewItem(this TreeViewItem treeViewItem, XElement xElement)
        {
            treeViewItem.DataContext = xElement;
            var head = new StackPanel {Orientation = Orientation.Horizontal};

            var text = new TextBlock();
            // ScriptType->Type->type->_Type
            var icon = xElement.GetIconType();
            var name = xElement.GetAttributeValue(Constants.NAME);
            var description = xElement.GetAttributeValue("Description");
            var height = text.FontSize;
            if (!string.IsNullOrWhiteSpace(icon))
            {
                AddIcon(head, icon, description, height);
            }
            var maturity = xElement.GetAttributeValue("Maturity");
            if (!string.IsNullOrEmpty(maturity))
            {
                AddIcon(head, maturity,"",height);
            }

            text.Text = name;
            text.Margin = new Thickness(1, 0, 1, 0);
            text.ToolTip = new ToolTip {Content = xElement.GetSimpleDescriptionFromXElement()};

            head.Children.Add(text);

            treeViewItem.Header = head;
        }
开发者ID:bperreault,项目名称:autox,代码行数:29,代码来源:TreeViewExt.cs

示例4: Configure

        public void Configure(XElement xml)
        {
            EntryFormatter =
                ConstructOrDefault<IEntryConverter<string>>(xml.GetAttributeValue("EntryFormatter", "Formatter"));

            var cap = xml.GetAttributeValue("cap") ?? xml.GetAttributeValue("capacity");
            Capacity = Attempt.Get<int?>(() => int.Parse(cap)).Value;
        }
开发者ID:ajayanandgit,项目名称:Logging-1,代码行数:8,代码来源:MemoryTarget.cs

示例5: GetDefinition

        private Definition GetDefinition(XElement definitionElement)
        {
            var name = definitionElement.GetAttributeValue("name");
            var patterns = GetPatterns(definitionElement);
            var caseSensitive = Boolean.Parse(definitionElement.GetAttributeValue("caseSensitive"));
            var style = GetDefinitionStyle(definitionElement);

            return new Definition(name, caseSensitive, style, patterns);
        }
开发者ID:thomasjo,项目名称:highlight,代码行数:9,代码来源:XmlConfiguration.cs

示例6: InitFromConfig

 public IContentProvider InitFromConfig(XElement element){
     var resourceAssembly = element.GetAttributeValue("resourceAssembly", false);
     if (resourceAssembly != null)
         _resourceAssembly = AppDomain.CurrentDomain.GetOrLoadAssembly(resourceAssembly);
     _rootNameSpace = element.GetAttributeValue("rootNameSpace", false) ?? _rootNameSpace;
     if (_resourceAssembly == null) throw new TemplateConfigurationException("{0}: attribute resourceAssembly is required and not allowed null".FormatWith(element));
     if (_rootNameSpace == null) throw new TemplateConfigurationException("{0}: attribute rootNameSpace is required and not allowed null".FormatWith(element));
     return this;
 }
开发者ID:jrnail23,项目名称:RazorMachine,代码行数:9,代码来源:EmbeddedResourceContentProvider.cs

示例7: ShouldGetAttributeValue

        public void ShouldGetAttributeValue()
        {
            var element = new XElement("root");

            element.GetAttributeValue("id").ShouldBe(null);
            element.GetAttributeValue("id", "default").ShouldBe("default");

            element.SetAttributeValue("id", "1234");
            element.GetAttributeValue("id").ShouldBe("1234");
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:10,代码来源:XExtensions.Test.cs

示例8: GetBlockPattern

        private BlockPattern GetBlockPattern(XElement patternElement)
        {
            var name = patternElement.GetAttributeValue("name");
            var style = GetPatternStyle(patternElement);
            var beginsWith = patternElement.GetAttributeValue("beginsWith");
            var endsWith = patternElement.GetAttributeValue("endsWith");
            var escapesWith = patternElement.GetAttributeValue("escapesWith");

            return new BlockPattern(name, style, beginsWith, endsWith, escapesWith);
        }
开发者ID:thomasjo,项目名称:highlight,代码行数:10,代码来源:XmlConfiguration.cs

示例9: LoadUserData

        internal void LoadUserData(XElement node)
        {
            bool tryParseBool;

            if (bool.TryParse(node.GetAttributeValue("showMessages"), out tryParseBool))
                this.buttonMessages.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("showWarnings"), out tryParseBool))
                this.buttonWarnings.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("showErrors"), out tryParseBool))
                this.buttonErrors.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("showCore"), out tryParseBool))
                this.buttonCore.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("showEditor"), out tryParseBool))
                this.buttonEditor.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("showGame"), out tryParseBool))
                this.buttonGame.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("autoClear"), out tryParseBool))
                this.checkAutoClear.Checked = tryParseBool;
            if (bool.TryParse(node.GetAttributeValue("pauseOnError"), out tryParseBool))
                this.buttonPauseOnError.Checked = tryParseBool;

            this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.SourceCore, this.buttonCore.Checked);
            this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.SourceEditor, this.buttonEditor.Checked);
            this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.SourceGame, this.buttonGame.Checked);
            this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.TypeMessage, this.buttonMessages.Checked);
            this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.TypeWarning, this.buttonWarnings.Checked);
            this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.TypeError, this.buttonErrors.Checked);
        }
开发者ID:BraveSirAndrew,项目名称:duality,代码行数:28,代码来源:LogView.cs

示例10: CustomizedFeedProperty

        public CustomizedFeedProperty(XElement nodeDecl, XElement entry)
        {
            this.entry = entry;
            this.node = nodeDecl;

            this.fcTargetPath = nodeDecl.GetAttributeValue("m:FC_TargetPath", ODataNamespaceManager.Instance);
            this.fc_KeepInContent = nodeDecl.GetAttributeValue("m:FC_KeepInContent", ODataNamespaceManager.Instance);
            if (string.IsNullOrEmpty(fc_KeepInContent))
            {
                this.fc_KeepInContent = "true"; // default setting
            }
            this.fc_ContentKind = nodeDecl.GetAttributeValue("m:FC_ContentKind", ODataNamespaceManager.Instance);
            if (string.IsNullOrEmpty(this.fc_ContentKind))
            {
                this.fc_ContentKind = "text";    //default setting
            }

            string target;
            this.isAtomSpecific = AtomTargetMapping.TryGetTarget(this.fcTargetPath, out target);

            if (isAtomSpecific)
            {
                this.targetPath = target.Split('/');
                this.nsResolver = ODataNamespaceManager.Instance;
                extraNamespaceDecl = string.Empty;
            }
            else
            {
                this.targetPath = fcTargetPath.Split('/');

                string fc_NsPrefix = nodeDecl.GetAttributeValue("m:FC_NsPrefix", ODataNamespaceManager.Instance);
                string fc_NsUri = nodeDecl.GetAttributeValue("m:FC_NsUri", ODataNamespaceManager.Instance);
                if (string.IsNullOrEmpty(fc_NsPrefix))
                {
                    fc_NsPrefix = "ioftNs_wfnqpz"; //just make up a random one
                }
                this.AddNsPrefixToTarget(fc_NsPrefix);

                // a custom resolver is needed sice there is non standard namespace definition
                this.nsResolver = CreateCustomNSResolver(fc_NsPrefix, fc_NsUri);
                this.extraNamespaceDecl = string.Format(@"xmlns:{0}=""{1}""", fc_NsPrefix, fc_NsUri);
            }

            this.isAttributeTarget = IsAttributeTarget(this.targetPath[this.targetPath.Length - 1]);

            this.ProcessPropertyInContent();
            this.ProcessPropertyInTarget();
        }
开发者ID:RongfangWang,项目名称:ValidationTool,代码行数:48,代码来源:CustomizedFeedProperty.cs

示例11: GetItemFromXElement

        private static TreeViewItem GetItemFromXElement(XElement element, string parentId)
        {
            var guid = element.GetAttributeValue(Constants._ID);
            if (string.IsNullOrEmpty(guid))
            {
                guid = Guid.NewGuid().ToString();
                element.SetAttributeValue(Constants._ID, guid);
            }
            var rootPart = element.GetRootPartElement();
            rootPart.SetAttributeValue(Constants.PARENT_ID, parentId);

            if (!DBFactory.GetData().Save(rootPart))
            {
                MessageBox.Show("update Tree item Failed.");
            }
            else
            {
                var itself = rootPart.GetTreeViewItemFromXElement();

                foreach (XElement kid in element.Descendants())
                {
                    itself.Items.Add(GetItemFromXElement(kid, guid));
                }
                return itself;
            }

            return null;
        }
开发者ID:bperreault,项目名称:autox,代码行数:28,代码来源:MainWindow.BackActions.xaml.cs

示例12: GetAttributeValue_Throws_OnNullObjects

 public void GetAttributeValue_Throws_OnNullObjects()
 {
     typeof(NullReferenceException).ShouldBeThrownBy(() => ((XElement) null).GetAttributeValue(null));
     //attribute not exist
     var elem = new XElement("elem", "This is a test");
     typeof(NullReferenceException).ShouldBeThrownBy(() => elem.GetAttributeValue("MissingAttributeName"));
 }
开发者ID:saturn72,项目名称:Saturn72.Extensions,代码行数:7,代码来源:XElementExtensionsTests.cs

示例13: PublishXml

        public void PublishXml(XElement xml)
        {
            _contentType = xml.GetAttributeValue(Common.ContentTypes.AttribName);

            // Change the button image to correspond to the type of content for this field
            string buttonImageUri = null;

            switch (_contentType)
            {
                case Common.ContentTypes.URL:
                    buttonImageUri = "/Expanz.ThinRIA.Core.Silverlight;component/Images/Globe.png";
                    break;
                case Common.ContentTypes.EmailAddress:
                    buttonImageUri = "/Expanz.ThinRIA.Core.Silverlight;component/Images/Envelope.png";
                    break;
            }

            if (buttonImageUri != null)
            {
                Image image = new Image();
                image.Stretch = Stretch.None;
                image.Source = new BitmapImage(new Uri(buttonImageUri, UriKind.RelativeOrAbsolute));

                this.Content = image;
            }
        }
开发者ID:expanz,项目名称:expanz-Microsoft-XAML-SDKs,代码行数:26,代码来源:LaunchURLButton.cs

示例14: Construct

        public Target Construct(string typeName, XElement config)
        {
            if (config == null) throw new ArgumentNullException(nameof(config));
            try
            {
                // make sure that a type name is present (explicitly passed in or through config)
                if (string.IsNullOrWhiteSpace(typeName))
                {
                    typeName = config.GetAttributeValue("type");
                    if (string.IsNullOrWhiteSpace(typeName))
                        throw new ArgumentNullException(nameof(typeName));
                }

                // find the target type
                var targetType = FindTargetTypeInfo(typeName);

                if (targetType == null)
                    throw new LoggingConfigurationException("Could not find a target type by the name " + typeName);

                // construct target
                var target = (Target)Activator.CreateInstance(targetType.TargetType);
                target.ConfigureInternal(config);
                return target;
            }
            catch (Exception ex)
            {
                throw new TargetConstructionException("Target construction failed", ex);
            }
        }
开发者ID:Core-Techs,项目名称:Logging,代码行数:29,代码来源:TargetConstructor.cs

示例15: FindUIObject

 public void FindUIObject(XElement uiObj)
 {
     if (uiObj == null)
         return;
     XPath = uiObj.GetAttributeValue("XPath");
     UIObject = Browser.GetWebElement(uiObj);
 }
开发者ID:bperreault,项目名称:autox,代码行数:7,代码来源:AbstractAction.cs


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