• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Linq.XElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XElement类属于System.Xml.Linq命名空间,在下文中一共展示了XElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ToPhysical

        public System.Xml.Linq.XElement ToPhysical(System.Xml.Linq.XElement udsService)
        {
            string name = udsService.Attribute("Name").Value;
            XElement x = new XElement("Service", new XAttribute("Name", name));
            XElement prop = new XElement("Property", new XAttribute("Name", "Definition"));
            x.Add(prop);

            XElement serv = new XElement("Service");
            prop.Add(serv);

            XElement sd = new XElement("ServiceDescription");
            serv.Add(sd);

            XElement handler = new XElement("Handler", new XAttribute("ExecType", "RemoteComponent"));
            sd.Add(handler);
            
            XElement udsDefinition = udsService.Element("Definition");
            foreach (XElement e in udsDefinition.Elements())
                sd.Add(e);

            XElement usage = new XElement("Usage");
            sd.Add(usage);

            XElement sh = new XElement("ServiceHelp");
            sh.Add(new XElement("Description"));
            sh.Add(new XElement("RequestSDDL"));
            sh.Add(new XElement("ResponseSDDL"));
            sh.Add(new XElement("Errors"));
            sh.Add(new XElement("RelatedDocumentServices"));
            sh.Add(new XElement("Samples"));
            serv.Add(sh);
            return x;
        }
开发者ID:lidonghao1116,项目名称:ProjectManager,代码行数:33,代码来源:RemoteComponentConverter.cs


示例2: CreateFromXElement

        public static TableCellStyle CreateFromXElement(XElement element)
        {
            TableCellStyle cellStyle = new TableCellStyle();
            cellStyle.PopulateFromXElement(element);

            return cellStyle;
        }
开发者ID:onesimoh,项目名称:Andamio,代码行数:7,代码来源:TableCellStyle.cs


示例3: Serialize

 public override XElement Serialize()
 {
     XElement thisElement = new XElement(GetType().Name);
     thisElement.Add(insideEquation.Serialize());
     thisElement.Add(outerEquation.Serialize());
     return thisElement;
 }
开发者ID:JackWangCUMT,项目名称:math-editor,代码行数:7,代码来源:DivMathWithOuterBase.cs


示例4: AddNextObxElement

        public void AddNextObxElement(string value, XElement document, string observationResultStatus)
        {
            XElement obxElement = new XElement("OBX");
            XElement obx01Element = new XElement("OBX.1");
            XElement obx0101Element = new XElement("OBX.1.1", this.m_ObxCount.ToString());
            obx01Element.Add(obx0101Element);
            obxElement.Add(obx01Element);

            XElement obx02Element = new XElement("OBX.2");
            XElement obx0201Element = new XElement("OBX.2.1", "TX");
            obx02Element.Add(obx0201Element);
            obxElement.Add(obx02Element);

            XElement obx03Element = new XElement("OBX.3");
            XElement obx0301Element = new XElement("OBX.3.1", "&GDT");
            obx03Element.Add(obx0301Element);
            obxElement.Add(obx03Element);

            XElement obx05Element = new XElement("OBX.5");
            XElement obx0501Element = new XElement("OBX.5.1", value);
            obx05Element.Add(obx0501Element);
            obxElement.Add(obx05Element);

            XElement obx11Element = new XElement("OBX.11");
            XElement obx1101Element = new XElement("OBX.11.1", observationResultStatus);
            obx11Element.Add(obx1101Element);
            obxElement.Add(obx11Element);

            this.m_ObxCount++;
            document.Add(obxElement);
        }
开发者ID:ericramses,项目名称:YPILIS,代码行数:31,代码来源:EpicStatusObxView.cs


示例5: ToXml

        public static XElement ToXml(ConvolutionFilter filter)
        {
            var res = new XElement(TAG_NAME,
                new XAttribute("divisor", CommonFormatter.Format(filter.Divisor)),
                new XAttribute("bias", CommonFormatter.Format(filter.Bias))
            );

            var xMatrix = new XElement("matrix");
            for (var y = 0; y < filter.MatrixY; y++) {
                var xRow = new XElement("r");
                for (var x = 0; x < filter.MatrixX; x++) {
                    var xCol = new XElement("c") { Value = CommonFormatter.Format(filter.Matrix[y, x]) };
                    xRow.Add(xCol);
                }
                xMatrix.Add(xRow);
            }
            res.Add(xMatrix);

            res.Add(new XElement("color", XColorRGBA.ToXml(filter.DefaultColor)));
            if (filter.Reserved != 0) {
                res.Add(new XAttribute("reserved", filter.Reserved));
            }
            res.Add(new XAttribute("clamp", CommonFormatter.Format(filter.Clamp)));
            res.Add(new XAttribute("preserveAlpha", CommonFormatter.Format(filter.PreserveAlpha)));
            return res;
        }
开发者ID:liwq-net,项目名称:SwfLib,代码行数:26,代码来源:XConvolutionFilter.cs


示例6: GetValueFromXml

        protected override object GetValueFromXml(XElement root, XName name, PropertyInfo prop)
        {
            var isAttribute = false;

            // Check for the DeserializeAs attribute on the property
            var options = prop.GetAttribute<DeserializeAsAttribute>();

            if (options != null)
            {
                name = options.Name ?? name;
                isAttribute = options.Attribute;
            }

            if (isAttribute)
            {
                var attributeVal = GetAttributeByName(root, name);

                if (attributeVal != null)
                {
                    return attributeVal.Value;
                }
            }

            return base.GetValueFromXml(root, name, prop);
        }
开发者ID:mgulubov,项目名称:RestSharpHighQualityCodeTeamProject,代码行数:25,代码来源:XmlAttributeDeserializer.cs


示例7: RunFromInput

        public void RunFromInput(string inputDir, string outputFile, string name)
        {
            // setup XML file
            XNamespace ns = "http://schemas.microsoft.com/wix/2006/wi";
            XElement componentGroup = new XElement(ns + "ComponentGroup", new XAttribute("Id", "Component_" + name));
            XElement directoryRef = new XElement(ns + "DirectoryRef", new XAttribute("Id", "Dir_" + name));

            // build content
            AddDirectory(inputDir, "Component_Generated_" + name, "Dir_Generated_" + name, ns, directoryRef, componentGroup);

            // save
            XDocument doc = new XDocument(
                new XDeclaration("1.0", "utf-8", ""),
                new XElement(ns + "Wix",
                    new XAttribute("xmlns", ns.NamespaceName),
                    new XComment(String.Format(
                        "Autogenerated at {0} for directory {1}",
                        DateTime.Now.ToString("dd MMM yyy HH:mm", System.Globalization.CultureInfo.InvariantCulture),
                        inputDir
                    )),
                    new XElement(ns + "Fragment", componentGroup),
                    new XElement(ns + "Fragment", directoryRef)
                )
            );
            doc.Save(outputFile);
            OutputStream.WriteLine("Done!");
        }
开发者ID:bbmjen,项目名称:MPExtended,代码行数:27,代码来源:WixFSGenerator.cs


示例8: CharacterAttachmentBrand

        internal CharacterAttachmentBrand(CharacterAttachmentSlot slot, XElement element)
        {
            Slot = slot;

            // Set up strings
            var brandNameAttribute = element.Attribute("Name");
            if (brandNameAttribute != null)
                Name = brandNameAttribute.Value;

            var brandThumbnailAttribute = element.Attribute("Thumbnail");
            if (brandThumbnailAttribute != null)
                ThumbnailPath = brandThumbnailAttribute.Value;

            // Get attachments
            var slotAttachmentElements = element.Elements("Attachment");

            int count = slotAttachmentElements.Count();
            if (Slot.CanBeEmpty)
                count++;

            var slotAttachments = new CharacterAttachment[count];

            for (int i = 0; i < slotAttachmentElements.Count(); i++)
            {
                var slotAttachmentElement = slotAttachmentElements.ElementAt(i);

                slotAttachments[i] = new CharacterAttachment(Slot, slotAttachmentElement);
            }

            if (Slot.CanBeEmpty)
                slotAttachments[slotAttachmentElements.Count()] = new CharacterAttachment(Slot, null);

            Attachments = slotAttachments;
        }
开发者ID:RogierWV,项目名称:315GR,代码行数:34,代码来源:CharacterAttachmentBrand.cs


示例9: Format

        public XElement Format(Scenario scenario, int id)
        {
            var header = new XElement(
                this.xmlns + "div",
                new XAttribute("class", "scenario-heading"),
                new XElement(this.xmlns + "h2", scenario.Name));

            var tags = RetrieveTags(scenario);
            if (tags.Length > 0)
            {
                var paragraph = new XElement(this.xmlns + "p", CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns));
                paragraph.Add(new XAttribute("class", "tags"));
                header.Add(paragraph);
            }

            header.Add(this.htmlDescriptionFormatter.Format(scenario.Description));

            return new XElement(
                this.xmlns + "li",
                new XAttribute("class", "scenario"),
                this.htmlImageResultFormatter.Format(scenario),
                header,
                new XElement(
                    this.xmlns + "div",
                    new XAttribute("class", "steps"),
                    new XElement(
                        this.xmlns + "ul",
                        scenario.Steps.Select(step => this.htmlStepFormatter.Format(step)))));
        }
开发者ID:MikeThomas64,项目名称:pickles,代码行数:29,代码来源:HtmlScenarioFormatter.cs


示例10: GenerateNamespaceMapping

 private void GenerateNamespaceMapping(XElement namespaces) {
     if (namespaces == null)
         return;
     foreach(XElement ns in namespaces.Elements(XName.Get("Namespace", Constants.TypedXLinqNs))) {
         namespaceMapping.Add((string)ns.Attribute(XName.Get("Schema")), (string)ns.Attribute(XName.Get("Clr")));
     }
 }
开发者ID:o2platform,项目名称:O2.Platform.Projects,代码行数:7,代码来源:XObjectsSettings.cs


示例11: ReadElement

        public IEnumerable<JObject> ReadElement(IAixmConverter converter, JObject currentObject, XElement element)
        {
            currentObject.AddToProperties("elevation", JObject.FromObject(element));

            //If not a feature return null;
            return Enumerable.Empty<JObject>();
        }
开发者ID:s-innovations,项目名称:S-Innovations.Aixm,代码行数:7,代码来源:AIXMElevationConvtertor.cs


示例12: LoadSound

        private SoundInfo LoadSound(XElement soundNode, string basePath)
        {
            SoundInfo sound = new SoundInfo { Name = soundNode.RequireAttribute("name").Value };

            sound.Loop = soundNode.TryAttribute<bool>("loop");

            sound.Volume = soundNode.TryAttribute<float>("volume", 1);

            XAttribute pathattr = soundNode.Attribute("path");
            XAttribute trackAttr = soundNode.Attribute("track");
            if (pathattr != null)
            {
                sound.Type = AudioType.Wav;
                sound.Path = FilePath.FromRelative(pathattr.Value, basePath);
            }
            else if (trackAttr != null)
            {
                sound.Type = AudioType.NSF;

                int track;
                if (!trackAttr.Value.TryParse(out track) || track <= 0) throw new GameXmlException(trackAttr, "Sound track attribute must be an integer greater than zero.");
                sound.NsfTrack = track;

                sound.Priority = soundNode.TryAttribute<byte>("priority", 100);
            }
            else
            {
                sound.Type = AudioType.Unknown;
            }

            return sound;
        }
开发者ID:Tesserex,项目名称:C--MegaMan-Engine,代码行数:32,代码来源:SoundXmlReader.cs


示例13: setUpdateData

 public void setUpdateData(XElement updatedata)
 {
     // XElement in ein character Struct konvertieren
     e4dnd2obsidian.e4DndCharakter cnv = new e4dnd2obsidian.e4DndCharakter(updatedata);
     character chrdata = cnv.getCharakterData();
     state.SetUpdateData(this, chrdata);
 }
开发者ID:hche,项目名称:e4dnd2obsidian,代码行数:7,代码来源:ContextObsidian.cs


示例14: GenerateXml_InterfaceDynamicallyImplemented

        public void GenerateXml_InterfaceDynamicallyImplemented()
        {
            var targetType = new InvolvedType (typeof (TargetClass3));

              var mixinConfiguration = MixinConfiguration.BuildNew ().ForClass<TargetClass3> ().AddMixin<Mixin4> ().BuildConfiguration ();
              targetType.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First ());
              targetType.TargetClassDefinition = new ReflectedObject (TargetClassDefinitionUtility.GetConfiguration (targetType.Type, mixinConfiguration));
              var mixinContext = targetType.ClassContext.GetProperty ("Mixins").First ();
              var mixinDefinition = targetType.TargetClassDefinition.CallMethod ("GetMixinByConfiguredType", mixinContext.GetProperty ("MixinType").To<Type> ());

              var assemblyIdentifierGenerator = new IdentifierGenerator<Assembly> ();

              var output = new TargetCallDependenciesReportGenerator (mixinDefinition, assemblyIdentifierGenerator,
                                                             _remotionReflector, _outputFormatter).GenerateXml ();

              var expectedOutput = new XElement ("TargetCallDependencies",
                                        new XElement ("Dependency",
                                                     new XAttribute ("assembly-ref", "0"),
                                                     new XAttribute ("namespace", "System"),
                                                     new XAttribute ("name", "IDisposable"),
                                                     new XAttribute ("is-interface", true),
                                                     new XAttribute ("is-implemented-by-target", false),
                                                     new XAttribute ("is-added-by-mixin", false),
                                                     new XAttribute ("is-implemented-dynamically", true)));

              XElementComparisonHelper.Compare (output, expectedOutput);
        }
开发者ID:re-motion,项目名称:Mixins-XRef,代码行数:27,代码来源:TargetCallDependenciesReportGeneratorTest.cs


示例15: FromXml

        public static MusicInfo FromXml(XElement musicNode, string basePath)
        {
            MusicInfo music = new MusicInfo();

            var introNode = musicNode.Element("Intro");
            var loopNode = musicNode.Element("Loop");

            XAttribute trackAttr = musicNode.Attribute("nsftrack");

            if (introNode != null || loopNode != null)
            {
                music.Type = AudioType.Wav;
                if (introNode != null) music.IntroPath = FilePath.FromRelative(introNode.Value, basePath);
                if (loopNode != null) music.LoopPath = FilePath.FromRelative(loopNode.Value, basePath);
            }
            else if (trackAttr != null)
            {
                music.Type = AudioType.NSF;

                int track;
                if (!trackAttr.Value.TryParse(out track) || track <= 0) throw new GameXmlException(trackAttr, "Sound track attribute must be an integer greater than zero.");
                music.NsfTrack = track;
            }
            else
            {
                music.Type = AudioType.Unknown;
            }

            return music;
        }
开发者ID:Tesserex,项目名称:CME-Common-Library,代码行数:30,代码来源:MusicInfo.cs


示例16: Build

        public static string Build()
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    BestEquipInfo[] infos = db.GetCelebByDayBestEquip();
                    foreach (BestEquipInfo info in infos)
                    {
                        result.Add(FlashUtils.CreateBestEquipInfo(info));
                    }

                    value = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("Load CelebByDayBestEquip is fail!", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            return csFunction.CreateCompressXml(result, "CelebForBestEquip", false);
        }
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:30,代码来源:CelebByDayBestEquip.ashx.cs


示例17: InjectData

        /// <summary>
        /// Injects Calibre's metadata into XHTML element (for metadata part)
        /// </summary>
        /// <param name="metadata"></param>
        public void InjectData(XElement metadata)
        {
            if (!string.IsNullOrEmpty(SeriesName))
            {
                XElement serie = new XElement(MetaName);
                serie.Add(new XAttribute("name", "calibre:series"));
                serie.Add(new XAttribute("content", SeriesName));
                metadata.Add(serie);
            }

            if (SeriesIndex != 0)
            {
                XElement serieIndex = new XElement(MetaName);
                serieIndex.Add(new XAttribute("name", "calibre:series_index"));
                serieIndex.Add(new XAttribute("content", SeriesIndex));
                metadata.Add(serieIndex);
            }

            if (!string.IsNullOrEmpty(TitleForSort))
            {
                XElement title4Sort = new XElement(MetaName);
                title4Sort.Add(new XAttribute("name", "calibre:title_sort"));
                title4Sort.Add(new XAttribute("content", TitleForSort));
                metadata.Add(title4Sort);
            }

            XElement date = new XElement(MetaName);
            date.Add(new XAttribute("name", "calibre:timestamp"));
            date.Add(new XAttribute("content", DateTime.UtcNow.ToString("O")));
            metadata.Add(date);
        }
开发者ID:rajeshwarn,项目名称:fb2converters,代码行数:35,代码来源:CalibreMetadata.cs


示例18: buildObjectFromXML

    public static GameObject buildObjectFromXML(XElement xmlObject)
    {
        string objectName = (xmlObject.Attribute("name") != null) ? ((string)xmlObject.Attribute("name")) : ("Unit Map Object");
        string sprite = "testTile_White_Black";

        return generateObject(objectName, sprite);
    }
开发者ID:MarcT562,项目名称:Codename-Richochet,代码行数:7,代码来源:componentUnitMapObject.cs


示例19: Validate

        protected override XElement Validate(XElement item)
        {
            // Validate with XSD
            XElement xsdErrors = this.ValidateXSD(item, HttpContext.Current.Server.MapPath(@"~\Xslt\Senior\Senior.xsd"));
            if (xsdErrors != null && xsdErrors.Elements("Error").Count() > 0)
            {
                return xsdErrors;
            }

            // Validate with Stored Proc
            string result = string.Empty;
            using (Persistence oDB = new Persistence())
            {
                Persistence.ParameterCollection parameters = new Persistence.ParameterCollection();
                parameters.Add("InputXml");
                parameters[0].Value = item.ToString();
                oDB.Execute("Masters_ConnectionString", "ValidateSeniorData", parameters, out result);
            }

            if (!string.IsNullOrEmpty(result))
            {
                XElement spErrors = XElement.Parse(result);
                spErrors.Elements("Error").Where(e => string.IsNullOrEmpty(e.Value)).Remove();

                if (spErrors.Elements("Error").Count() > 0)
                {
                    return spErrors;
                }
            }

            // SUCCESS!
            return null;

        }
开发者ID:CaffGeek,项目名称:manitobamasterbowlers.com,代码行数:34,代码来源:Upload.Senior.cs


示例20: Execute

        public void Execute(ClientContext ctx, string listTitle, XElement schema, Action<Field> setAdditionalProperties = null)
        {
            var displayName = schema.Attribute("DisplayName").Value;
            Logger.Verbose($"Started executing {nameof(CreateColumnOnList)} for column '{displayName}' on list '{listTitle}'");

            var list = ctx.Web.Lists.GetByTitle(listTitle);
            var fields = list.Fields;
            ctx.Load(fields);
            ctx.ExecuteQuery();

            // if using internal names in code, remember to encode those before querying, e.g., 
            // space character becomes "_x0020_" as described here:
            // http://www.n8d.at/blog/encode-and-decode-field-names-from-display-name-to-internal-name/
            // We don't use the internal name here because it's limited to 32 chacters. This means
            // "Secondary site abcde" is the longest possible internal name when taken into account
            // the "_x0020_" character. Using a longer name will truncate the internal name to 32
            // characters. Thus querying on the complete, not truncated name, will always return no
            // results which causes the field get created repetedly.
            var field = fields.SingleOrDefault(f => f.Title == displayName);
            if (field != null)
            {
                Logger.Warning($"Column '{displayName}' already on list {listTitle}");
                return;
            }

            var newField = list.Fields.AddFieldAsXml(schema.ToString(), true, AddFieldOptions.DefaultValue);
            ctx.Load(newField);
            ctx.ExecuteQuery();

            if (setAdditionalProperties != null)
            {
                setAdditionalProperties(newField);
                newField.Update();
            }
        }
开发者ID:ronnieholm,项目名称:Bugfree.Spo.Cqrs,代码行数:35,代码来源:CreateColumnOnList.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Linq.XName类代码示例发布时间:2022-05-26
下一篇:
C# Linq.XDocument类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap