本文整理汇总了C#中System.Xml.XmlWriterSettings类的典型用法代码示例。如果您正苦于以下问题:C# XmlWriterSettings类的具体用法?C# XmlWriterSettings怎么用?C# XmlWriterSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlWriterSettings类属于System.Xml命名空间,在下文中一共展示了XmlWriterSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateRequestXml
private string GenerateRequestXml(RequestInput input)
{
var sw = new StringWriter();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = false;
settings.OmitXmlDeclaration = true;
using (XmlWriter writer = XmlWriter.Create(sw, settings))
{
writer.WriteStartDocument();
writer.WriteStartElement("GenerateRequest");
writer.WriteElementString("pxPayUserId", pxPayUserId);
writer.WriteElementString("pxPayKey", pxPayKey);
PropertyInfo[] properties = input.GetType().GetProperties();
foreach (PropertyInfo prop in properties)
{
if (prop.CanWrite)
{
string val = (string)prop.GetValue(input, null);
if (val != null || val != string.Empty)
{
writer.WriteElementString(prop.Name, val);
}
}
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
}
return sw.ToString();
}
开发者ID:venetiabird,项目名称:WV_Spikes,代码行数:35,代码来源:PxPay.cs
示例2: SaveCustomers
public static void SaveCustomers(List<Customer> customers)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = (" ");
XmlWriter xmlOut = XmlWriter.Create(CustomerDB.path, settings);
xmlOut.WriteStartDocument();
xmlOut.WriteStartElement("Customers");
foreach (Customer customer in customers)
{
switch (customer.GetType().Name)
{
case "Customer":
Write((Customer)customer, xmlOut);
break;
case "RetailCustomer":
WriteRetail((RetailCustomer)customer, xmlOut);
break;
case "WholesaleCustomer":
WriteWholesale((WholesaleCustomer)customer, xmlOut);
break;
default:
break;
}
}
xmlOut.WriteEndElement();
xmlOut.Close();
}
开发者ID:28ACB29,项目名称:Maintenance-Application,代码行数:31,代码来源:CustomerDB.cs
示例3: UpdateHeartbeat
public void UpdateHeartbeat()
{
// Create or Update External XML For Last Update Check DateTime
if (!File.Exists(CheckUpdateFile))
{
DateTime DateTimeNow = DateTime.Now;
XmlWriterSettings wSettings = new XmlWriterSettings();
wSettings.Indent = true;
XmlWriter writer = XmlWriter.Create(CheckUpdateFile, wSettings);
writer.WriteStartDocument();
writer.WriteComment("This file is generated by WWIV5TelnetServer - DO NOT MODIFY.");
writer.WriteStartElement("WWIV5UpdateStamp");
writer.WriteStartElement("LastChecked");
writer.WriteElementString("DateTime", DateTimeNow.ToString());
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
// Do Update Check
updateTimer = new System.Timers.Timer(1000 * 60 * 60); // Hourly - Release Code
//updateTimer = new System.Timers.Timer(1000 * 10); // 10 Seconds for Testing Only
updateTimer.Elapsed += new ElapsedEventHandler(DoUpdateCheck);
updateTimer.AutoReset = true;
updateTimer.Enabled = true;
if (Properties.Settings.Default.checkUpdates == "On Startup")
{
DoUpdateCheck(null, null);
}
}
开发者ID:firefighter389,项目名称:wwiv,代码行数:32,代码来源:CheckUpdates.cs
示例4: StringBuilder
string DotNetNuke.Entities.Modules.IPortable.ExportModule(int ModuleID)
{
StringBuilder strXML = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = true;
XmlWriter Writer = XmlWriter.Create(strXML, settings);
ArrayList alCategories = GetCategories(PortalId, true, -3);
if (alCategories.Count > 0)
{
Writer.WriteStartElement("Categories");
foreach (CategoryInfo categoryInfo in alCategories)
{
Writer.WriteStartElement("Category");
Writer.WriteElementString("CategoryID", categoryInfo.CategoryID.ToString());
Writer.WriteElementString("Name", categoryInfo.CategoryName);
Writer.WriteElementString("Description", categoryInfo.CategoryDescription);
Writer.WriteElementString("Message", categoryInfo.Message);
Writer.WriteElementString("Archived", categoryInfo.Archived.ToString());
Writer.WriteElementString("OrderID", categoryInfo.OrderID.ToString());
Writer.WriteElementString("ParentCategoryID", categoryInfo.ParentCategoryID.ToString());
Writer.WriteEndElement();
}
Writer.WriteEndElement();
Writer.Close();
}
else
{
return String.Empty;
}
return strXML.ToString();
}
开发者ID:helder1978,项目名称:Store,代码行数:34,代码来源:CategoryController.cs
示例5: Compile
public void Compile()
{
ParsedPath resxPath = Target.InputPaths.Where(f => f.Extension == ".resx").First();
ParsedPath stringsPath = Target.OutputPaths.Where(f => f.Extension == ".strings").First();
List<ResourceItem> resources = ReadResources(resxPath);
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.Indent = true;
xmlSettings.IndentChars = "\t";
using (XmlWriter xmlWriter = XmlWriter.Create(stringsPath, xmlSettings))
{
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("Strings");
foreach (ResourceItem resource in resources)
{
if (resource.DataType == typeof(string))
{
string value = resource.ValueString;
xmlWriter.WriteStartElement("String");
xmlWriter.WriteAttributeString("Name", resource.Name);
xmlWriter.WriteString(value);
xmlWriter.WriteEndElement();
}
}
xmlWriter.WriteEndElement();
}
}
开发者ID:jlyonsmith,项目名称:Playroom,代码行数:31,代码来源:ResxToStringsCompiler.cs
示例6: WrappedSerializer
internal WrappedSerializer(Serialization.DataFormat dataFormat, string streamName, TextWriter output) : base(dataFormat, streamName)
{
this.firstCall = true;
this.textWriter = output;
Serialization.DataFormat dataFormat1 = this.format;
switch (dataFormat1)
{
case Serialization.DataFormat.Text:
{
return;
}
case Serialization.DataFormat.XML:
{
XmlWriterSettings xmlWriterSetting = new XmlWriterSettings();
xmlWriterSetting.CheckCharacters = false;
xmlWriterSetting.OmitXmlDeclaration = true;
this.xmlWriter = XmlWriter.Create(this.textWriter, xmlWriterSetting);
this.xmlSerializer = new Serializer(this.xmlWriter);
return;
}
default:
{
return;
}
}
}
开发者ID:nickchal,项目名称:pash,代码行数:26,代码来源:WrappedSerializer.cs
示例7: Unformat
public override string Unformat(string value)
{
if (string.IsNullOrWhiteSpace(value)) return null;
try
{
var stringBuilder = new StringBuilder();
var element = XElement.Parse(value);
var settings = new XmlWriterSettings
{
OmitXmlDeclaration = true,
Indent = false,
NewLineOnAttributes = false
};
using (var xmlWriter = XmlWriter.Create(stringBuilder, settings))
{
element.Save(xmlWriter);
}
return stringBuilder.ToString();
}
catch (Exception ex)
{
Log.Error($"Error while unformatting expected XML field {value}. The raw value will be used instead.", ex, this);
return value;
}
}
开发者ID:csteeg,项目名称:Rainbow,代码行数:30,代码来源:XmlFieldFormatter.cs
示例8: FixNuSpec
private static void FixNuSpec(ProjectVersion version, string file)
{
XNamespace ns = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd";
var readerSettings = new XmlReaderSettings
{
IgnoreComments = false,
IgnoreWhitespace = false
};
XDocument doc;
using (var reader = XmlReader.Create(file, readerSettings))
{
doc = XDocument.Load(reader);
}
var versionElement = doc.Descendants(ns + "version").Single();
versionElement.Value = version.FullText;
var dependency = doc.Descendants(ns + "dependency").Where(x => (string)x.Attribute("id") == "NodaTime").FirstOrDefault();
if (dependency != null)
{
dependency.SetAttributeValue("version", version.Dependency);
}
var writerSettings = new XmlWriterSettings
{
Encoding = new UTF8Encoding(false),
Indent = false,
NewLineHandling = NewLineHandling.None,
};
using (var writer = XmlWriter.Create(file, writerSettings))
{
doc.Save(writer);
}
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:33,代码来源:Program.cs
示例9: FormatText
static string FormatText(string text)
{
XmlTextWriter writer = null;
XmlDocument doc = new XmlDocument();
XmlWriterSettings xwSettings = new XmlWriterSettings();
string formattedText = string.Empty;
try
{
doc.LoadXml(text);
writer = new XmlTextWriter(".data.xml", null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
writer.Close();
using (StreamReader sr = new StreamReader(".data.xml"))
{
formattedText = sr.ReadToEnd();
}
}
finally
{
File.Delete(".data.xml");
}
return formattedText;
}
开发者ID:ayayalar,项目名称:functmetalnet,代码行数:26,代码来源:FunctMetaLRunner.cs
示例10: Execute
/// <summary>
/// Executes the request message on the target system and returns a response message.
/// If there isn’t a response, this method should return null
/// </summary>
public Message Execute(Message message, TimeSpan timeout)
{
if (message.Headers.Action != "Submit")
throw new ApplicationException("Unexpected Message Action");
//Parse the request message to extract the string and get out the body to send to the socket
XmlDictionaryReader rdr = message.GetReaderAtBodyContents();
rdr.Read();
string input = rdr.ReadElementContentAsString();
//Interact with the socket
this.Connection.Client.SendData(input);
string output = this.Connection.Client.ReceiveData();
Debug.WriteLine(output);
//Produce the response message
StringBuilder outputString = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
XmlWriter replywriter = XmlWriter.Create(outputString, settings);
replywriter.WriteStartElement("SendResponse", "http://acme.wcf.lob.paymentapplication/");
replywriter.WriteStartElement("SendResult");
replywriter.WriteString(Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(output)));
replywriter.WriteEndElement();
replywriter.WriteEndElement();
replywriter.Close();
XmlReader replyReader = XmlReader.Create(new StringReader(outputString.ToString()));
Message response = Message.CreateMessage(MessageVersion.Default, "Submit/Response", replyReader);
return response;
}
开发者ID:andychops,项目名称:Libraries,代码行数:35,代码来源:SocketAdapterOutboundHandler.cs
示例11: prepareRAWPayload
private static byte[] prepareRAWPayload(string location, string temperature, string weatherType)
{
MemoryStream stream = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings() { Indent = true, Encoding = Encoding.UTF8 };
XmlWriter writer = XmlTextWriter.Create(stream, settings);
writer.WriteStartDocument();
writer.WriteStartElement("WeatherUpdate");
writer.WriteStartElement("Location");
writer.WriteValue(location);
writer.WriteEndElement();
writer.WriteStartElement("Temperature");
writer.WriteValue(temperature);
writer.WriteEndElement();
writer.WriteStartElement("WeatherType");
writer.WriteValue(weatherType);
writer.WriteEndElement();
writer.WriteStartElement("LastUpdated");
writer.WriteValue(DateTime.Now.ToString());
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
byte[] payload = stream.ToArray();
return payload;
}
开发者ID:ChrisKoenig,项目名称:PushNotifications,代码行数:33,代码来源:MainWindow.xaml.cs
示例12: write
private void write(string filePath)
{
try
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.CloseOutput = true;
settings.CheckCharacters = true;
settings.ConformanceLevel = ConformanceLevel.Document;
settings.Encoding = Encoding.UTF8;
settings.Indent = true;
settings.IndentChars = "\t";
settings.NewLineChars = "\r\n";
using (XmlWriter writer = XmlWriter.Create(filePath, settings))
{
writer.WriteStartDocument();
writer.WriteStartElement("Config");
writer.WriteStartElement("FrequencyRange");
writer.WriteAttributeString("min", _minFreq.ToString());
writer.WriteAttributeString("max", _maxFreq.ToString());
writer.WriteEndElement();
writer.WriteElementString("DeviceID", _deviceId);
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
catch (Exception ex)
{
Logger.Instance.Log(LogType.Error, "設定ファイルの書き込みに失敗: " + ex.Message + "\r\n" + ex.StackTrace);
}
}
开发者ID:davinx,项目名称:PitchPitch,代码行数:34,代码来源:Config.cs
示例13: Serialize
/// <summary>
/// Serializes the specified <see cref="Element"/> to XML.
/// </summary>
/// <param name="root">
/// The <c>Element</c> to serialize, including all its children.
/// </param>
/// <remarks>
/// The generated XML will be indented and have a full XML
/// declaration header.
/// </remarks>
/// <exception cref="ArgumentNullException">root is null.</exception>
public void Serialize(Element root)
{
var settings = new XmlWriterSettings();
settings.Indent = true;
//settings.NamespaceHandling = NamespaceHandling.OmitDuplicates;
this.Serialize(root, settings);
}
开发者ID:shocky,项目名称:MissionPlanner,代码行数:18,代码来源:Serializer.cs
示例14: CreateDefinitions
public void CreateDefinitions(WizardConfiguration wizardConfiguration)
{
var projectCollection = new XElement(Ns + "ProjectCollection");
var doc = new XDocument(
new XElement(Ns + "VSTemplate",
new XAttribute("Version", "3.0.0"),
new XAttribute("Type", "ProjectGroup"),
new XElement(Ns + "TemplateData",
new XElement(Ns + "Name", wizardConfiguration.Name),
new XElement(Ns + "Description", wizardConfiguration.Description),
new XElement(Ns + "ProjectType", wizardConfiguration.ProjectType),
new XElement(Ns + "DefaultName", wizardConfiguration.DefaultName),
new XElement(Ns + "SortOrder", wizardConfiguration.SortOrder),
new XElement(Ns + "Icon", wizardConfiguration.IconName)),
new XElement(Ns + "TemplateContent", projectCollection),
MakeWizardExtension(
"LogoFX.Tools.Templates.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
$"LogoFX.Tools.Templates.Wizard.SolutionWizard")
));
XmlWriterSettings settings = new XmlWriterSettings
{
OmitXmlDeclaration = true,
Indent = true
};
var definitionFile = GetDefinitionFileName();
using (XmlWriter xw = XmlWriter.Create(definitionFile, settings))
{
doc.Save(xw);
}
}
开发者ID:LogoFX,项目名称:tools,代码行数:34,代码来源:DefinitionsGenerator.cs
示例15: MergeFrom
// This might better be rewrite to "examine two settings and return the existing one or new one if required".
internal void MergeFrom (XmlWriterSettings other)
{
CloseOutput |= other.CloseOutput;
OmitXmlDeclaration |= other.OmitXmlDeclaration;
if (ConformanceLevel == ConformanceLevel.Auto)
ConformanceLevel = other.ConformanceLevel;
}
开发者ID:carrie901,项目名称:mono,代码行数:8,代码来源:XmlWriterSettings.cs
示例16: SaveDatasetsXml
// 1. save XFA form XML stream to a file to inspect form fields
public void SaveDatasetsXml(string readerPath)
{
using (var reader = new PdfReader(readerPath))
{
var xfa = new XfaForm(reader);
XmlDocument doc = xfa.DomDocument;
//// remove namespace so XML is easier to read
//if (!string.IsNullOrEmpty(doc.DocumentElement.NamespaceURI))
//{
// doc.DocumentElement.SetAttribute("xmlns", "");
// var temp = new XmlDocument();
// temp.LoadXml(doc.OuterXml);
// doc = temp;
//}
var sb = new StringBuilder();
var xSettings = new XmlWriterSettings()
{
Indent = true,
WriteEndDocumentOnClose = true
};
using (var writer = XmlWriter.Create(sb, xSettings))
{
doc.Save(writer);
}
File.WriteAllText(GetXmlPath(readerPath), sb.ToString());
}
}
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp,代码行数:29,代码来源:UsageRightsCheckbox.cs
示例17: generateXml
public XmlReader generateXml()
{
MemoryStream stream = new MemoryStream();
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.OmitXmlDeclaration = true;
writerSettings.Indent = true;
XmlWriter classWriter = XmlWriter.Create(stream, writerSettings);
classWriter.WriteStartElement("class");
classWriter.WriteElementString("className", this.getClassName().Replace(".", "_"));
classWriter.WriteElementString("controllerAlias", (this.getAliasName() != null) ? this.getAliasName() : "Not Set");
SortedList<string, MethodModel> methodsInClass = this.getUserSelectedMethodsInThisClass();
classWriter.WriteStartElement("methods");
foreach (KeyValuePair<string, MethodModel> methodPair in methodsInClass)
{
MethodModel methodAtHand = methodPair.Value;
classWriter.WriteNode(methodAtHand.generateXml(), false);
}
classWriter.WriteEndElement();
classWriter.WriteEndElement();
classWriter.Flush();
stream.Position = 0;
stream.Position = 0;
XmlReader xmlReader = XmlReader.Create(stream);
classWriter.Close();
return xmlReader;
}
开发者ID:sandeepnjk,项目名称:WMPoc,代码行数:31,代码来源:ClassModel.cs
示例18: SaveSettings
/// <summary>
/// Saves the settings to the provider.
/// </summary>
/// <param name="settings">
/// The settings.
/// </param>
public override void SaveSettings(StringDictionary settings)
{
if (settings == null)
{
throw new ArgumentNullException("settings");
}
var filename = string.Format("{0}settings.xml", this.Folder);
var writerSettings = new XmlWriterSettings { Indent = true };
// ------------------------------------------------------------
// Create XML writer against file path
// ------------------------------------------------------------
using (var writer = XmlWriter.Create(filename, writerSettings))
{
writer.WriteStartElement("settings");
foreach (string key in settings.Keys)
{
writer.WriteElementString(key, settings[key]);
}
writer.WriteEndElement();
}
}
开发者ID:RajneeshVerma,项目名称:blogengine.net-mvc,代码行数:31,代码来源:Settings.cs
示例19: SaveRecentExperimentListToXML
public static void SaveRecentExperimentListToXML(RecentExperimentList pList, string pFilepath)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.CloseOutput = true;
settings.CheckCharacters = true;
// Create file
using (System.Xml.XmlWriter writer = XmlWriter.Create(pFilepath, settings))
{
writer.WriteStartDocument();
writer.WriteStartElement("RecentExperiments");
foreach (var item in pList)
{
writer.WriteStartElement("RecentExperimentItem");
writer.WriteAttributeString("FullPath", item.FullPath);
//writer.WriteAttributeString("Filename", item.Filename);
writer.WriteAttributeString("LastAccessTime", item.LastAccessTime.ToString());
writer.WriteEndElement(); // RecentExperimentItem
}
writer.WriteEndElement(); // RecentExperiments
writer.WriteEndDocument();
writer.Close();
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:27,代码来源:RecentExperimentsHelper.cs
示例20: XmlDataContractSerializer
/// <summary>
/// Constructor
/// </summary>
public XmlDataContractSerializer()
{
XmlWriterSettings = new System.Xml.XmlWriterSettings
{
Encoding = _defaultEncoding,
};
}
开发者ID:changsunfung,项目名称:RestSharp.Portable,代码行数:10,代码来源:XmlDataContractSerializer.cs
注:本文中的System.Xml.XmlWriterSettings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论