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


C# XElement.ToString方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GetJohnDeerePartInfoAndSubmit

        public void GetJohnDeerePartInfoAndSubmit(XElement SKUParts)
        {
            string info = "";
            bool IsFailed = false;
            try
            {
                info = GetJohnDeerePartInfo(SKUParts);
                //var fileBytes = Encoding.Default.GetBytes(info);
                //string acsNamespace = HartvilleToolConfigManager.GetSetting("JohnDeere.Biztalk.acsNamespace");
                //string issuerName = HartvilleToolConfigManager.GetSetting("JohnDeere.Biztalk.issuerName");
                //string issuerKey = HartvilleToolConfigManager.GetSetting("JohnDeere.Biztalk.issuerKey");
                //string runtimeAddress = HartvilleToolConfigManager.GetSetting("JohnDeere.Biztalk.runtimeAddress");
                //string contentType = "application/xml";
                //// Trace.TraceInformation("Prepare for sending to Biztalk");
                //MessageSender.SendMessage(acsNamespace,
                //    issuerName, issuerKey, runtimeAddress,
                //    fileBytes, contentType);
                InsertResultIntoSQL(info);

            }
            catch(Exception ex) {
                IsFailed = true;
                HartvilleToolConfigManager.NotifyEmailError("Error  GetJohnDeerePartInfo raw-WCF" + ex.Message, SKUParts.ToString() + Environment.NewLine +  info);
            }

            LogRequestIntoDatabase("GetJohnDeerePartInfo", SKUParts.ToString(), info, IsFailed);
        }
开发者ID:msaleh,项目名称:HRM,代码行数:27,代码来源:JohnDeereService.svc.cs

示例4: ParseRDFItem

        /// <summary>
        /// RSS version 1.0
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private RssSchema ParseRDFItem(XElement item)
        {
            var rssItem = ParseItem(item);

            rssItem.PublishDate = item.GetSafeElementDate("date", NsRdfElementsNamespaceUri);

            string image = item.GetSafeElementString("image");
            if (string.IsNullOrEmpty(image))
            {
                image = item.GetImage();
            }
            if (string.IsNullOrEmpty(image) && item.ToString().Contains("media:thumbnail"))
            {
                XNamespace ns = "http://search.yahoo.com/mrss/";
                var element = item.Elements(ns + "thumbnail").Last();
                image = element.Attribute("url").Value;
            }
            if (string.IsNullOrEmpty(image) && item.ToString().Contains("thumbnail"))
            {
                image = item.GetSafeElementString("thumbnail");
            }

            rssItem.ImageUrl = image;

            return rssItem;
        }
开发者ID:Belenar,项目名称:OtherAppRepository,代码行数:31,代码来源:RssReader.cs

示例5: PrintXml

		private static void PrintXml(XElement xml){
			Console.WriteLine(xml.ToString());
			Console.WriteLine();
			Console.WriteLine("---------------------------");
			Console.WriteLine();
			Console.WriteLine(xml.ToString().Replace("\"", "\"\""));
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:7,代码来源:IntermediateDocumentTest.cs

示例6: formulaVector

 public Scientrace.Vector formulaVector(Scientrace.Vector aVector, XElement xformula)
 {
     string f_x = "x";
     string f_y = "y";
     string f_z = "z";
     if (xformula.Attribute("xyz") != null) {
     try {
         string xyz = xformula.Attribute("xyz").Value;
         char[] delimiterChars = { ';', '\t' };
         string[] elements = xyz.Split(delimiterChars);
         if (elements.Length !=3) {
             throw new XMLException("Element "+xformula.ToString()+" has \""+elements.Length+ "\" != 3 valid vector elements. ");
             }
         f_x=elements[0];
         f_y=elements[1];
         f_z=elements[2];
         } catch { throw new XMLException("Formula "+xformula.ToString()+" does not have proper parameters for {xyz} attribute (can't parse {"+xformula.Attribute("xyz").Value.ToString()+"}. Perhaps incorrect use of PreProcess variables or decimal separators?)."); }
     } // attribute "xyz"
     f_x = this.getXStringByName(xformula, "x", f_x);
     f_y = this.getXStringByName(xformula, "y", f_y);
     f_z = this.getXStringByName(xformula, "z", f_z);
     Dictionary<string, object> replace_vectors = new Dictionary<string, object>(){{"x", (decimal)aVector.x}, {"y", (decimal)aVector.y}, {"z", (decimal)aVector.z} };
     return new Scientrace.Vector(
     Scientrace.MathStrings.solveString(f_x, replace_vectors),
     Scientrace.MathStrings.solveString(f_y, replace_vectors),
     Scientrace.MathStrings.solveString(f_z, replace_vectors)
     );
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:28,代码来源:CustomXMLDocumentOperations.cs

示例7: Trans

 private void Trans(XElement serializedExpression)
 {
     serializedExpression.Save("beforeTransit.xml");
     Console.WriteLine("beforeTransit:");
     Console.WriteLine(serializedExpression.ToString());
     Transit(serializedExpression);
     Console.WriteLine("afterTransit:");
     Console.WriteLine(serializedExpression.ToString());
     serializedExpression.Save("afterTransit.xml");
 }
开发者ID:fr4nky80,项目名称:LearnCSharp,代码行数:10,代码来源:ExpressionSerializationTest.cs

示例8: ConstructorShould_Load_Project_File_Content_Into_Member

        public void ConstructorShould_Load_Project_File_Content_Into_Member()
        {
            XElement fileContentAsXml = new XElement("project", new XElement("project_name", PROJECT_NAME));

            File.WriteAllText(projectFilePath, fileContentAsXml.ToString());

            ProjectFileReader pfr = new ProjectFileReader(projectFilePath);

            Assert.AreEqual(fileContentAsXml.ToString(), pfr.ProjectFileContent);
        }
开发者ID:AbdelghaniDr,项目名称:opcmock,代码行数:10,代码来源:ProjectFileReaderTests.cs

示例9: UpdatePaymentRequest

        public long UpdatePaymentRequest(XElement xml)
        {
            if (logger.IsDebugEnabled)
            {
                logger.Debug(string.Format("UpdatePaymentRequest {0}", xml));
            }

            long batchControlLogId = 0;

            using (SqlConnection conn = new SqlConnection(this.GeniusXConnectionString))
            {
                conn.Open();

                // insert record in BatchControllog (Status = In Progress)
                batchControlLogId = this.AddBatchEntry(BatchControlConstant.BatchType.Custom, "Description", xml.ToString(), conn);

                try
                {
                    // update Paymenet request
                    using (SqlCommand cmd = new SqlCommand("UpdatePaymentRequestAXA", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@PaymentRequests", SqlDbType.Xml).Value = xml.ToString();                        
                        cmd.ExecuteScalar();
                    }

                    // update BatchControlLog (Status = completed, CompletionStatus = Clear)
                    this.UpdateBatchStatus(batchControlLogId, BatchControlConstant.BatchStatus.Completed, BatchControlConstant.CompletionStatus.Clear, conn);
                }
                catch (Exception ex)
                {
                    // insert record into BatchErrorLogHeader                    
                    // add error detail into BatchErrorLogDetail
                    this.AddErrorLog(batchControlLogId, BatchControlConstant.MessageLevel.Error, ex.Message, string.Empty, conn);

                    // update BatchControlLog (Status = completed, CompletionStatus= Errors)
                    this.UpdateBatchStatus(batchControlLogId, BatchControlConstant.BatchStatus.Completed, BatchControlConstant.CompletionStatus.Errors, conn);                    

                    logger.Error(string.Format("UpdatePaymentRequest - {0}", ex.Message));

                    return batchControlLogId;
                }
            }

            if (logger.IsDebugEnabled)
            {
                logger.Debug(string.Format("UpdatePaymentRequest {0} => returns: {1}", xml,batchControlLogId));
            }

            return 0;
        }
开发者ID:victorxata,项目名称:261120,代码行数:51,代码来源:GeniusXHelper.cs

示例10: TestAssignValue

        public void TestAssignValue()
        {
            var address = new XElement("address",
                                       new XElement("street", "1st street"),
                                       new XElement("city", "2nd city"));
            var street = address.Element("street");
            street.Value = "88";

            Assert.AreEqual("<address><street>88</street><city>2nd city</city></address>", address.ToString(SaveOptions.DisableFormatting));

            // -------------- set value on parent will replace all its children elements
            address.Value = "replaced";
            Assert.AreEqual("<address>replaced</address>", address.ToString(SaveOptions.DisableFormatting));
        }
开发者ID:stasi009,项目名称:TestDrivenLearn,代码行数:14,代码来源:TestXmlUpdate.cs

示例11: FromXml

        public static PaymentMethod FromXml(XElement element)
        {
            if (element == null)
            {
                return null;
            }

            var ret = new PaymentMethod(element.ToString());
            ret.Token = element.GetStringChild("token");
            ret.Number = element.GetStringChild("number");
            ret.StorageState = element.GetStringChild("storage_state");
            ret.FirstName = element.GetStringChild("first_name");
            ret.LastName = element.GetStringChild("last_name");
            ret.CreatedAt = DateTime.Parse(element.GetStringChild("created_at"));

            ret.ExpirationMonth = int.Parse(element.GetStringChild("month"));
            ret.ExpirationYear = int.Parse(element.GetStringChild("year"));
            ret.CardType = element.GetStringChild("card_type");
            ret.Address1 = element.GetStringChild("address1");
            ret.Address2 = element.GetStringChild("address2");
            ret.City = element.GetStringChild("city");
            ret.State = element.GetStringChild("state");
            ret.Zip = element.GetStringChild("zip");
            ret.Country = element.GetStringChild("country");

            return ret;
        }
开发者ID:hross,项目名称:Spreedly.Net,代码行数:27,代码来源:PaymentMethod.cs

示例12: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";

            XElement result = new XElement("Result");
            try
            {
                int userid = int.Parse(context.Request.Params["ID"]);
                
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    ItemInfo[] items = db.GetUserItem(userid);

                    foreach (ItemInfo item in items)
                    {
                        result.Add(Road.Flash.FlashUtils.CreateGoodsInfo(item));
                    }

                }
                value = true;
                message = "Success!";
            }
            catch (Exception ex)
            {
                log.Error("LoadUserItems", ex);
            }

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

            context.Response.ContentType = "text/plain";
            context.Response.Write(result.ToString(false));
        }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:34,代码来源:LoadUserItems.ashx.cs

示例13: Compare

        public void Compare(XElement expected, XElement actual)
        {
            this.UpdateSchemasForUseStrongSpatialTypes(expected);
            this.UpdateSchemasForUseStrongSpatialTypes(actual);

            this.UpdateSchemaAliasToSchemaNamepsace(expected);
            this.UpdateSchemaAliasToSchemaNamepsace(actual);

            this.UpdatePrimitiveTypeNameForEdmFullName(expected);
            this.UpdatePrimitiveTypeNameForEdmFullName(actual);

            this.CompensateDefaultFacets(expected);
            this.CompensateDefaultFacets(actual);

            this.CompensateSpatialTypeSrid(expected);
            this.CompensateSpatialTypeSrid(actual);

            XElement sortedExpected = this.csdlSorter.SortCsdl(expected);
            XElement sortedActual = this.csdlSorter.SortCsdl(actual);

            Console.WriteLine("Sorted Expected: " + expected.ToString());
            Console.WriteLine("Sorted Actual: " + sortedActual.ToString());

            Assert.AreEqual(sortedExpected.ToString(), sortedActual.ToString(), "Csdl not equal!");
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:25,代码来源:CsdlXElementComparer.cs

示例14: belEncerramentoMDFe

        public belEncerramentoMDFe(PesquisaManifestosModel objPesquisa, string cUF, string cMun)
        {
            this.objPesquisa = objPesquisa;
            XNamespace pf = "http://www.portalfiscal.inf.br/mdfe";
            XContainer envCTe = new XElement(pf + "evEncMDFe",
                 new XElement(pf + "descEvento", "Encerramento"),
                 new XElement(pf + "nProt", objPesquisa.protocolo),
                 new XElement(pf + "dtEnc", daoUtil.GetDateServidor().ToString("yyyy-MM-dd")),
                 new XElement(pf + "cUF", cUF),
                 new XElement(pf + "cMun", cMun.Trim()));
            XmlDocument xmlCanc = new XmlDocument();
            xmlCanc.LoadXml(envCTe.ToString());
            string sPath = Pastas.PROTOCOLOS + objPesquisa.protocolo + "evEnc.xml";
            if (File.Exists(sPath))
                File.Delete(sPath);
            xmlCanc.Save(sPath);
            try
            {
                belValidaXml.ValidarXml("http://www.portalfiscal.inf.br/mdfe", Pastas.SCHEMA_MDFe + "\\evEncMDFe_v1.00.xsd", sPath);
            }
            catch (Exception ex)
            {                
                throw ex;
            }

            objEvento = new belEventoMDFe(xmlCanc.DocumentElement, objPesquisa, "110112");

          //  Encerramento();
        }
开发者ID:dramosti,项目名称:GeraXml_3.0,代码行数:29,代码来源:belEncerramentoMDFe.cs

示例15: SaveTree

        public void SaveTree(String TreeXml)
        {
            if (String.IsNullOrEmpty(TreeXml))
            {
                //创建一棵空树
                XElement root = new XElement("root");
                TreeXml = root.ToString();
            }

            using (InfocenterEntities context = new InfocenterEntities(EFConnectionString))
            {
               Tree treeObj = context.Trees.FirstOrDefault();
               if (treeObj != null)
               {
                   //更新树
                   treeObj.maintree = Encoding.UTF8.GetBytes(TreeXml);
                   context.SaveChanges();
               }
               else
               {
                   //正常情况下应该不会走到这个分支,但仍然写在这里,逻辑就完整了。
                   treeObj = new Tree();
                   treeObj.maintree = Encoding.UTF8.GetBytes(TreeXml);
                   context.Trees.Add(treeObj);
                   context.SaveChanges();
               }

            }
        }
开发者ID:HETUAN,项目名称:PersonalInfoForWPF,代码行数:29,代码来源:MainTreeRepository.cs


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