本文整理汇总了C#中System.Xml.XmlWriter.WriteComment方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteComment方法的具体用法?C# XmlWriter.WriteComment怎么用?C# XmlWriter.WriteComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteComment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
internal override void WriteTo(XmlWriter xml)
{
if (xml == null)
return;
xml.WriteComment(SR.GetString(SR.ServiceNameFromClient));
xml.WriteElementString("ServiceName", this.serviceBindingNameSentByClient);
xml.WriteComment(SR.GetString(SR.ServiceNameOnService));
xml.WriteStartElement("ServiceNameCollection");
if (this.serviceNameCollectionConfiguredOnServer == null || this.serviceNameCollectionConfiguredOnServer.Count < 1)
{
xml.WriteElementString("ServiceName", this.defaultServiceBindingNameOfServer);
}
else
{
foreach (string serviceName in this.serviceNameCollectionConfiguredOnServer)
{
xml.WriteElementString("ServiceName", serviceName);
}
}
xml.WriteFullEndElement();
}
示例2: EndExport
protected void EndExport(XmlWriter xmlWriter)
{
xmlWriter.WriteEndElement();
xmlWriter.WriteComment("*************************************");
xmlWriter.WriteComment(".NET SQL Authorization Manager (Ms-PL)");
xmlWriter.WriteComment("*************************************");
}
示例3: BeginExport
protected void BeginExport(XmlWriter xmlWriter)
{
xmlWriter.WriteComment("*************************************");
xmlWriter.WriteComment(".NET SQL Authorization Manager (Ms-PL)");
xmlWriter.WriteComment("*************************************");
xmlWriter.WriteComment("http://netsqlazman.codeplex.com");
xmlWriter.WriteComment("Andrea Ferendeles");
xmlWriter.WriteComment("*************************************");
xmlWriter.WriteComment(String.Format("Creation Date: {0}", DateTime.Now.ToString()));
xmlWriter.WriteComment(String.Format("NetSqlAzMan Run-Time version: {0}", this.storage.GetType().Assembly.GetName().Version.ToString()));
xmlWriter.WriteComment(String.Format("NetSqlAzMan Database version: {0}", this.storage.DatabaseVesion));
xmlWriter.WriteComment("*************************************");
xmlWriter.WriteStartElement("NetSqlAzMan");
}
示例4: Save
public void Save(object obj, XmlWriter writer)
{
Type t = obj.GetType();
// writer.WriteStartElement(GetTypeName(t));
// System.Console.WriteLine("\tSave <{0}>",GetTypeName(t));
writer.WriteStartElement(obj.GetType().Name);
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj);
PropertyInfo [] propertyInfos = new PropertyInfo[properties.Count];
for (int i = 0;i < properties.Count ; i ++){
propertyInfos[i] = t.GetProperty(properties[i].Name);
}
foreach (PropertyInfo info in propertyInfos) {
if (info == null){
continue;
}
if (!info.CanRead) continue;
if (info.GetCustomAttributes(typeof(XmlIgnoreAttribute), true).Length != 0) continue;
object val = info.GetValue(obj, null);
if (val == null) continue;
if (val is ICollection) {
// PropertyInfo pinfo = t.GetProperty(info.Name);
// Console.WriteLine("pinfo {0}",pinfo.Name);
if (info.Name.StartsWith("Contr")) {
writer.WriteStartElement("Items");
} else {
writer.WriteStartElement(info.Name);
}
foreach (object element in (ICollection)val) {
Save(element, writer);
}
writer.WriteEndElement();
} else {
if (!info.CanWrite) continue;
TypeConverter c = TypeDescriptor.GetConverter(info.PropertyType);
if (c.CanConvertFrom(typeof(string)) && c.CanConvertTo(typeof(string))) {
try {
writer.WriteElementString(info.Name, c.ConvertToInvariantString(val));
} catch (Exception ex) {
writer.WriteComment(ex.ToString());
}
} else if (info.PropertyType == typeof(Type)) {
writer.WriteElementString(info.Name, ((Type)val).AssemblyQualifiedName);
} else {
// System.Diagnostics.Trace.WriteLine("Serialize Pagelayout");
// writer.WriteStartElement(info.Name);
// Save(val, writer);
// writer.WriteEndElement();
}
}
}
writer.WriteEndElement();
}
示例5: WriteXmlLogStart
public static void WriteXmlLogStart(XmlWriter xw)
{
xw.WriteStartDocument();
xw.WriteStartElement("LogEntries");
xw.WriteString("\r\n");
xw.WriteComment(StaticVariables.Logo(false) + "\r\n" + CurrentQuery + "\r\n"); //+ CurrentEntryCount + "\r\n");
}
示例6: WriteNode
private static void WriteNode(XmlReader reader, XmlWriter writer)
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Name);
break;
case XmlNodeType.Text:
writer.WriteString(reader.Value);
break;
case XmlNodeType.CDATA:
writer.WriteCData(reader.Value);
break;
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.XmlDeclaration:
break;
case XmlNodeType.Document:
break;
case XmlNodeType.DocumentType:
break;
case XmlNodeType.EntityReference:
break;
case XmlNodeType.EndElement:
writer.WriteEndElement();
break;
}
}
}
示例7: WriteTo
public override void WriteTo(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException("writer");
}
writer.WriteComment(this.value);
}
示例8: Write
/// <summary>
/// Writes the section using an XML writer
/// </summary>
/// <param name="writer">XML writer to use</param>
/// <param name="project">The project to generate .csproj for</param>
/// <param name="context">Current .csproj generation context</param>
public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
{
writer.WriteStartElement("ItemGroup");
foreach (var refPath in context.References.Where(IsValidReference))
{
if (IsSolutionReference(refPath))
{
var moduleAndprojectName = ((string) refPath).Substring(4);
var parts = moduleAndprojectName.Split('#');
var moduleName = parts[0];
var projectName = parts[1];
var referredProject = Suite.GetModule(moduleName).GetProjectOrTestProject(projectName);
if (referredProject.Type == ProjectType.Library ||
referredProject.Type == ProjectType.Executable)
{
writer.WriteComment("Project reference " + projectGuidManagement.GetGuid(referredProject));
writer.WriteStartElement("Reference");
writer.WriteAttributeString("Include", projectName);
writer.WriteElementString("HintPath",
ToProjectRelativePath(project,
Path.Combine(Suite.SuiteRoot.GetRelativePath(targetDir), referredProject.Module.Name,
referredProject.Name + ".dll"), sourceSetName));
writer.WriteElementString("SpecificVersion", "False");
writer.WriteEndElement();
}
}
else
{
writer.WriteStartElement("Reference");
if (IsGACReference(refPath))
{
var assemblyName = ((string) refPath).Substring(4);
writer.WriteAttributeString("Include", assemblyName);
}
else
{
string relativePath = ToProjectRelativePath(project, Path.Combine("target", refPath), sourceSetName);
writer.WriteAttributeString("Include", Path.GetFileNameWithoutExtension(relativePath));
writer.WriteElementString("HintPath", relativePath);
writer.WriteElementString("SpecificVersion", "False");
writer.WriteElementString("Private", "True");
}
writer.WriteEndElement();
}
}
writer.WriteEndElement();
}
示例9: startLocal
public static void startLocal() {
local = true;
if (Xmlw == null) {
byte[] b = Encoding.UTF8.GetBytes(DateTime.Now.ToString());
log = Convert.ToBase64String(b) + ".gh";
Xmlw = XmlWriter.Create(log);
Xmlw.WriteStartElement("doc");
Xmlw.WriteComment(DateTime.Now.ToString());
Xmlw.Flush();
}
}
示例10: WriteTo
internal override void WriteTo(XmlWriter writer)
{
base.WriteTo(writer);
//
// canonical element string
//
byte[] contentBuffer = _logStream.GetBuffer();
string contentAsString = System.Text.Encoding.UTF8.GetString(contentBuffer, 0, (int)_logStream.Length);
writer.WriteElementString(CanonicalElementStringLength, contentAsString.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteComment(CanonicalElementString + ":" + contentAsString);
//
// canonical element base64 format
//
writer.WriteElementString(CanonicalOctetsLength, contentBuffer.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteElementString(CanonicalOctets, Convert.ToBase64String(contentBuffer));
//
// Hash
//
writer.WriteElementString(CanonicalOctetsHashLength, _hash.Hash.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteElementString(CanonicalOctetsHash, Convert.ToBase64String(_hash.Hash));
//
// Key: this will only be printed out for the symmetric key case
//
if (_hash is KeyedHashAlgorithm)
{
KeyedHashAlgorithm keyedHash = _hash as KeyedHashAlgorithm;
byte[] key = keyedHash.Key;
writer.WriteStartElement(Key); // start the key element
writer.WriteElementString(Length, key.Length.ToString(CultureInfo.InvariantCulture)); // key length
writer.WriteElementString(FirstByte, key[0].ToString(CultureInfo.InvariantCulture)); // first byte of the key
writer.WriteElementString(LastByte, key[key.Length - 1].ToString(CultureInfo.InvariantCulture)); // last byte of the key
writer.WriteEndElement(); // close the key element
}
}
示例11: WriteXml
public void WriteXml(XmlWriter writer)
{
var w = new APIWriter(writer);
writer.WriteComment(DateTime.Now.ToString());
foreach (var pi in typeof(OnlineRegModel).GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(vv => vv.CanRead && vv.CanWrite))
{
switch (pi.Name)
{
case "List":
w.Start("List");
foreach (var i in _list)
Util.Serialize(i, writer);
w.End();
break;
case "History":
w.Start("History");
foreach (var i in History)
w.Add("item", i);
w.End();
break;
case "password":
break;
case "testing":
if (testing == true)
w.Add(pi.Name, testing);
break;
case "FromMobile":
if (FromMobile.HasValue())
w.Add(pi.Name, FromMobile);
else if (MobileAppMenuController.Source.HasValue())
w.Add(pi.Name, MobileAppMenuController.Source);
break;
case "prospect":
if (prospect)
w.Add(pi.Name, prospect);
break;
default:
w.Add(pi.Name, pi.GetValue(this, null));
break;
}
}
}
示例12: WriteActivity
protected void WriteActivity (XmlWriter _xmlWriter, string _name, string _theme = null, string _orientation = null, string _configChanges = null, string _comment = null)
{
if (_comment != null)
_xmlWriter.WriteComment(_comment);
_xmlWriter.WriteStartElement("activity");
{
_xmlWriter.WriteAttributeString("android:name", _name);
if (_theme != null)
_xmlWriter.WriteAttributeString("android:theme", _theme);
if (_orientation != null)
_xmlWriter.WriteAttributeString("android:screenOrientation", _orientation);
if (_configChanges != null)
_xmlWriter.WriteAttributeString("android:configChanges", _configChanges);
}
_xmlWriter.WriteEndElement();
}
示例13: WriteTo
internal override void WriteTo(XmlWriter writer)
{
base.WriteTo(writer);
byte[] bytes = this._logStream.GetBuffer();
string str = Encoding.UTF8.GetString(bytes, 0, (int) this._logStream.Length);
writer.WriteElementString("CanonicalElementStringLength", str.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteComment("CanonicalElementString:" + str);
writer.WriteElementString("CanonicalOctetsLength", bytes.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteElementString("CanonicalOctets", Convert.ToBase64String(bytes));
writer.WriteElementString("CanonicalOctetsHashLength", this._hash.Hash.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteElementString("CanonicalOctetsHash", Convert.ToBase64String(this._hash.Hash));
if (this._hash is KeyedHashAlgorithm)
{
KeyedHashAlgorithm algorithm = this._hash as KeyedHashAlgorithm;
byte[] key = algorithm.Key;
writer.WriteStartElement("Key");
writer.WriteElementString("Length", key.Length.ToString(CultureInfo.InvariantCulture));
writer.WriteElementString("FirstByte", key[0].ToString(CultureInfo.InvariantCulture));
writer.WriteElementString("LastByte", key[key.Length - 1].ToString(CultureInfo.InvariantCulture));
writer.WriteEndElement();
}
}
示例14: Save
public void Save(object obj, XmlWriter writer)
{
Type t = obj.GetType();
writer.WriteStartElement(GetTypeName(t));
foreach (PropertyInfo info in t.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
if (!info.CanRead) continue;
if (info.GetCustomAttributes(typeof(XmlIgnoreAttribute), true).Length != 0) continue;
object val = info.GetValue(obj, null);
if (val == null) continue;
if (val is ICollection) {
writer.WriteStartElement(info.Name);
foreach (object element in (ICollection)val) {
Save(element, writer);
}
writer.WriteEndElement();
} else {
if (!info.CanWrite) continue;
TypeConverter c = TypeDescriptor.GetConverter(info.PropertyType);
if (c.CanConvertFrom(typeof(string)) && c.CanConvertTo(typeof(string))) {
try {
writer.WriteElementString(info.Name, c.ConvertToInvariantString(val));
} catch (Exception ex) {
writer.WriteComment(ex.ToString());
}
} else if (info.PropertyType == typeof(Type)) {
writer.WriteElementString(info.Name, ((Type)val).AssemblyQualifiedName);
} else {
writer.WriteStartElement(info.Name);
Save(val, writer);
writer.WriteEndElement();
}
}
}
writer.WriteEndElement();
}
示例15: WriteNode
private void WriteNode(XmlWriter xtw, bool defattr)
{
int num = (this.NodeType == XmlNodeType.None) ? -1 : this.Depth;
while (this.Read() && (num < this.Depth))
{
switch (this.NodeType)
{
case XmlNodeType.Element:
xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
((XmlTextWriter) xtw).QuoteChar = this.QuoteChar;
xtw.WriteAttributes(this, defattr);
if (this.IsEmptyElement)
{
xtw.WriteEndElement();
}
break;
case XmlNodeType.Text:
xtw.WriteString(this.Value);
break;
case XmlNodeType.CDATA:
xtw.WriteCData(this.Value);
break;
case XmlNodeType.EntityReference:
xtw.WriteEntityRef(this.Name);
break;
case XmlNodeType.ProcessingInstruction:
case XmlNodeType.XmlDeclaration:
xtw.WriteProcessingInstruction(this.Name, this.Value);
break;
case XmlNodeType.Comment:
xtw.WriteComment(this.Value);
break;
case XmlNodeType.DocumentType:
xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
xtw.WriteWhitespace(this.Value);
break;
case XmlNodeType.EndElement:
xtw.WriteFullEndElement();
break;
}
}
if ((num == this.Depth) && (this.NodeType == XmlNodeType.EndElement))
{
this.Read();
}
}