本文整理汇总了C#中System.Xml.XmlTextWriter.WriteAttributeString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextWriter.WriteAttributeString方法的具体用法?C# System.Xml.XmlTextWriter.WriteAttributeString怎么用?C# System.Xml.XmlTextWriter.WriteAttributeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了System.Xml.XmlTextWriter.WriteAttributeString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Project");
writer.WriteStartElement("Items");
Dictionary<int, sProject> projectList;
DB.LoadProject(out projectList);
foreach (KeyValuePair<int, sProject> item in projectList)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("uid", item.Key.ToString());
writer.WriteAttributeString("name", item.Value.name);
writer.WriteEndElement();
}
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例2: SaveToFile
protected virtual void SaveToFile(DataSet pDataSet)
{
if (m_FileName == null)
throw new ApplicationException("FileName is null");
byte[] completeByteArray;
using (System.IO.MemoryStream fileMemStream = new System.IO.MemoryStream())
{
System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(fileMemStream, System.Text.Encoding.UTF8);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("filedataset", c_DataNamespace);
xmlWriter.WriteStartElement("header", c_DataNamespace);
//File Version
xmlWriter.WriteAttributeString(c_FileVersion, c_FileVersionNumber.ToString());
//Data Version
xmlWriter.WriteAttributeString(c_DataVersion, GetDataVersion().ToString());
//Data Format
xmlWriter.WriteAttributeString(c_DataFormat, ((int)mSaveDataFormat).ToString());
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("data", c_DataNamespace);
byte[] xmlByteArray;
using (System.IO.MemoryStream xmlMemStream = new System.IO.MemoryStream())
{
StreamDataSet.Write(xmlMemStream, pDataSet, mSaveDataFormat);
//pDataSet.WriteXml(xmlMemStream);
xmlByteArray = xmlMemStream.ToArray();
xmlMemStream.Close();
}
xmlWriter.WriteBase64(xmlByteArray, 0, xmlByteArray.Length);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
completeByteArray = fileMemStream.ToArray();
fileMemStream.Close();
}
//se tutto è andato a buon fine scrivo effettivamente il file
using (System.IO.FileStream fileStream = new System.IO.FileStream(m_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
fileStream.Write(completeByteArray, 0, completeByteArray.Length);
fileStream.Close();
}
}
示例3: saveButton_Click
private void saveButton_Click(object sender, EventArgs e)
{
string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperPathSettings.xml";
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsFile, System.Text.Encoding.Unicode))
{
writer.WriteStartElement("PathSettings");
writer.WriteAttributeString("Path", pathTextBox.Text);
writer.WriteAttributeString("CreateFolder", createFolderBox.Checked.ToString());
writer.WriteEndElement();
writer.Close();
}
this.Close();
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int callstack_uid;
if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
callstack_uid = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Callstack");
DB.LoadCallstack(callstack_uid,
delegate(int depth, string funcname, string fileline)
{
writer.WriteStartElement("Singlestep");
writer.WriteAttributeString("depth", depth.ToString());
this.WriteCData(writer, "Funcname", funcname);
this.WriteCData(writer, "Fileline", fileline);
writer.WriteEndElement();
}
);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例5: button1_Click
private void button1_Click(object sender, EventArgs e)
{
string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperProxySettings.xml";
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsFile, System.Text.Encoding.Unicode))
{
writer.WriteStartElement("ProxySettings");
writer.WriteAttributeString("Server", serverBox.Text);
writer.WriteAttributeString("Port", portBox.Text);
writer.WriteAttributeString("Login", loginBox.Text);
writer.WriteAttributeString("Password", passwordBox.Text);
writer.WriteAttributeString("UseProxy", useProxyBox.Checked.ToString());
writer.WriteEndElement();
writer.Close();
}
this.Close();
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int project_uid;
if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
project_uid = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Report");
writer.WriteAttributeString("project", project_uid.ToString());
writer.WriteStartElement("Items");
DB.LoadReportDeleted(project_uid,
delegate(int report_uid, string login_id, string ipaddr, DateTime reported_time, string relative_time, int callstack_uid, string funcname, string version, string filename, string assigned, string uservoice, int num_comments)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("report_uid", report_uid.ToString());
writer.WriteAttributeString("login_id", login_id);
writer.WriteAttributeString("ipaddr", ipaddr);
writer.WriteAttributeString("reported_time", reported_time.ToString());
writer.WriteAttributeString("relative_time", relative_time);
writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
writer.WriteAttributeString("assigned", assigned);
writer.WriteAttributeString("num_comments", num_comments.ToString());
this.WriteCData(writer, "Funcname", funcname);
this.WriteCData(writer, "Version", version);
this.WriteCData(writer, "Filename", filename);
this.WriteCData(writer, "Uservoice", uservoice);
writer.WriteEndElement();
}
);
writer.WriteEndElement(); // Items
writer.WriteEndElement(); // Report
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int callstack_uid;
if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
callstack_uid = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Comment");
writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
DB.ForEachCallstackComment CommentWriter = delegate(string author, string comment, DateTime created)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("author", author);
writer.WriteAttributeString("created", created.ToString());
writer.WriteCData(comment);
writer.WriteEndElement();
};
DB.LoadCallstackComment(callstack_uid, CommentWriter);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例8: OutputFunctionNames
public static void OutputFunctionNames(bool compact, string k_test_results_path, string file_name, string[] script_functions)
{
using (var t = new System.Xml.XmlTextWriter(System.IO.Path.Combine(k_test_results_path, file_name), System.Text.Encoding.ASCII))
{
t.Indentation = 1;
t.IndentChar = '\t';
t.Formatting = System.Xml.Formatting.Indented;
t.WriteStartDocument();
t.WriteStartElement("Functions");
for (int x = 0; x < script_functions.Length; x++)
{
if (script_functions[x] != "123")
{
t.WriteStartElement("entry");
t.WriteAttributeString("key", "0x" + x.ToString("X3"));
t.WriteAttributeString("value", script_functions[x]);
t.WriteEndElement();
}
else if (!compact)
{
t.WriteStartElement("entry");
t.WriteAttributeString("key", "0x" + x.ToString("X3"));
t.WriteAttributeString("value", "UNKNOWN");
t.WriteEndElement();
}
}
t.WriteEndElement();
t.WriteEndDocument();
}
}
示例9: Serialize
/// <summary> Writes the mapping of all mapped classes of the specified assembly in the specified stream. </summary>
/// <param name="stream">Where the xml is written.</param>
/// <param name="assembly">Assembly used to extract user-defined types containing a valid attribute (can be [Class] or [xSubclass]).</param>
public virtual void Serialize(System.IO.Stream stream, System.Reflection.Assembly assembly)
{
if(stream == null)
throw new System.ArgumentNullException("stream");
if(assembly == null)
throw new System.ArgumentNullException("assembly");
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter( stream, System.Text.Encoding.UTF8 );
writer.Formatting = System.Xml.Formatting.Indented;
writer.WriteStartDocument();
if(WriteDateComment)
writer.WriteComment( string.Format( "Generated from NHibernate.Mapping.Attributes on {0}.", System.DateTime.Now.ToString("u") ) );
WriteHibernateMapping(writer, null);
// Write imports (classes decorated with the [ImportAttribute])
foreach(System.Type type in assembly.GetTypes())
{
object[] imports = type.GetCustomAttributes(typeof(ImportAttribute), false);
foreach(ImportAttribute import in imports)
{
writer.WriteStartElement("import");
if(import.Class != null && import.Class != string.Empty)
writer.WriteAttributeString("class", import.Class);
else // Assume that it is the current type that must be imported
writer.WriteAttributeString("class", HbmWriterHelper.GetNameWithAssembly(type));
if(import.Rename != null && import.Rename != string.Empty)
writer.WriteAttributeString("rename", import.Rename);
writer.WriteEndElement();
}
}
// Write classes and x-subclasses (classes must come first if inherited by "external" subclasses)
int classCount = 0;
System.Collections.ArrayList mappedClassesNames = new System.Collections.ArrayList();
foreach(System.Type type in assembly.GetTypes())
{
if( ! IsClass(type) )
continue;
HbmWriter.WriteClass(writer, type);
mappedClassesNames.Add(HbmWriterHelper.GetNameWithAssembly(type));
classCount++;
}
System.Collections.ArrayList subclasses = new System.Collections.ArrayList();
System.Collections.Specialized.StringCollection extendedClassesNames = new System.Collections.Specialized.StringCollection();
foreach(System.Type type in assembly.GetTypes())
{
if( ! IsSubclass(type) )
continue;
bool map = true;
System.Type t = type;
while( (t=t.DeclaringType) != null )
if (IsClass(t) || AreSameSubclass(type, t)) // If a base class is also mapped... (Note: A x-subclass can only contain x-subclasses of the same family)
{
map = false; // This class's mapping is already included in the mapping of the base class
break;
}
if(map)
{
subclasses.Add(type);
if( IsSubclass(type, typeof(SubclassAttribute)) )
extendedClassesNames.Add((type.GetCustomAttributes(typeof(SubclassAttribute), false)[0] as SubclassAttribute).Extends);
else if( IsSubclass(type, typeof(JoinedSubclassAttribute)) )
extendedClassesNames.Add((type.GetCustomAttributes(typeof(JoinedSubclassAttribute), false)[0] as JoinedSubclassAttribute).Extends);
else if( IsSubclass(type, typeof(UnionSubclassAttribute)) )
extendedClassesNames.Add((type.GetCustomAttributes(typeof(UnionSubclassAttribute), false)[0] as UnionSubclassAttribute).Extends);
}
}
classCount += subclasses.Count;
MapSubclasses(subclasses, extendedClassesNames, mappedClassesNames, writer);
writer.WriteEndElement(); // </hibernate-mapping>
writer.WriteEndDocument();
writer.Flush();
if(classCount == 0)
throw new MappingException("The following assembly contains no mapped classes: " + assembly.FullName);
if( ! Validate )
return;
// Validate the generated XML stream
try
{
writer.BaseStream.Position = 0;
System.Xml.XmlTextReader tr = new System.Xml.XmlTextReader(writer.BaseStream);
System.Xml.XmlValidatingReader vr = new System.Xml.XmlValidatingReader(tr);
// Open the Schema
System.IO.Stream schema = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("NHibernate.Mapping.Attributes.nhibernate-mapping.xsd");
vr.Schemas.Add("urn:nhibernate-mapping-2.2", new System.Xml.XmlTextReader(schema));
vr.ValidationType = System.Xml.ValidationType.Schema;
vr.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(XmlValidationHandler);
_stop = false;
while(vr.Read() && !_stop) // Read to validate (stop at the first error)
;
}
//.........这里部分代码省略.........
示例10: Ask
public void Ask(SelectableSource source, TextWriter output) {
bool result = Ask(source);
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(output);
w.Formatting = System.Xml.Formatting.Indented;
w.WriteStartElement("sparql");
w.WriteAttributeString("xmlns", "http://www.w3.org/2001/sw/DataAccess/rf1/result");
w.WriteStartElement("head");
w.WriteEndElement();
w.WriteStartElement("results");
w.WriteStartElement("boolean");
w.WriteString(result ? "true" : "false");
w.WriteEndElement();
w.WriteEndElement();
w.WriteEndElement();
w.Close();
}
示例11: Convert
//.........这里部分代码省略.........
string ErrMsg = String.Format(Sfm2XmlStrings.UnhandledException0, e.Message);
Log.AddError(ErrMsg);
}
string nl = System.Environment.NewLine;
string comments = nl;
comments += " ================================================================" + nl;
comments += " Element: " + m_Root.Name + nl;
comments += " This element contains the inputfile in an XML format." + nl;
comments += " ================================================================" + nl;
xmlOutput.WriteComment(comments);
// xmlOutput.WriteComment(" This element contains the inputfile in an XML format ");
try
{
// xmlOutput.WriteStartElement(m_Root.Name);
// ProcessSfmFile(xmlOutput);
ProcessSfmFileNewLogic(xmlOutput);
}
catch (System.Exception e)
{
string ErrMsg = String.Format(Sfm2XmlStrings.UnhandledException0, e.Message);
Log.AddError(ErrMsg);
}
#if false
if (m_autoFieldsUsed.Count > 0)
{
xmlOutput.WriteComment(" This is where the autofield info goes after the data has been processed. ");
xmlOutput.WriteStartElement("autofields");
foreach(DictionaryEntry autoEntry in m_autoFieldsUsed)
{
AutoFieldInfo afi = autoEntry.Value as AutoFieldInfo;
xmlOutput.WriteStartElement("field");
xmlOutput.WriteAttributeString("class", afi.className);
xmlOutput.WriteAttributeString("sfm", afi.sfmName);
xmlOutput.WriteAttributeString("fwid", afi.fwDest);
xmlOutput.WriteEndElement();
}
xmlOutput.WriteEndElement();
}
#endif
// put out the field descriptions with the autofield info integrated in: for xslt processing...
comments = nl;
comments += " ================================================================" + nl;
comments += " Element: fieldDescriptions" + nl;
comments += " This element is put out after the data so that auto fields can be" + nl;
comments += " added here. Otherwise, we'd have to make two passes over the data." + nl;
comments += " The additional information related to auto fields is used in the" + nl;
comments += " XSLT processing for building the phase2 output file." + nl;
comments += " ================================================================" + nl;
xmlOutput.WriteComment(comments);
xmlOutput.WriteStartElement("fieldDescriptions");
foreach(DictionaryEntry fieldEntry in m_FieldDescriptionsTable)
{
ClsFieldDescription fd = fieldEntry.Value as ClsFieldDescription;
if (fd is ClsCustomFieldDescription)
continue; // the custom fields will be put out in a CustomFields section following...
if (m_autoFieldsBySFM.ContainsKey(fd.SFM))
{
ArrayList afiBysfm = m_autoFieldsBySFM[fd.SFM] as ArrayList;
foreach(AutoFieldInfo afi in afiBysfm)
{
fd.AddAutoFieldInfo(afi.className, afi.fwDest);
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int project_uid;
int pageNo;
int pageSize;
bool seperate_version;
string specific_version;
int hideResolved = 0;
int fromDate;
int toDate;
if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
project_uid = 1;
if (int.TryParse(Request.QueryString["pageNo"], out pageNo) == false)
pageNo = 1;
if (int.TryParse(Request.QueryString["pageSize"], out pageSize) == false)
pageSize = 30;
if (int.TryParse(Request.QueryString["from"], out fromDate) == false)
fromDate = 0;
if (int.TryParse(Request.QueryString["to"], out toDate) == false)
toDate = 0;
if (bool.TryParse(Request.QueryString["sv"], out seperate_version) == false)
seperate_version = false;
specific_version = Request.QueryString["ver"];
if (specific_version != null)
{
specific_version.Trim();
if (specific_version.Length <= 0)
specific_version = null;
}
string temp1 = Request.QueryString["hideResolved"];
string temp2 = Request.QueryString["hideExamination"];
Boolean check1 = false;
Boolean check2 = false;
if (temp1 != null)
check1 = Boolean.Parse(temp1);
if (temp2 != null)
check2 = Boolean.Parse(temp2);
if (check1 && check2)
hideResolved = 3;
else if (check1)
hideResolved = 1;
else if (check2)
hideResolved = 2;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Callstack");
writer.WriteAttributeString("project", project_uid.ToString());
writer.WriteAttributeString("pageNo", pageNo.ToString());
writer.WriteAttributeString("pageSize", pageSize.ToString());
writer.WriteAttributeString("req", specific_version);
writer.WriteStartElement("Items");
DB.ForEachCallstackGroup ItemWriter = delegate(int count, int callstack_uid, string funcname, string version, DateTime latest_time, string relative_time, string assigned, int num_comments)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("count", count.ToString());
writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
writer.WriteAttributeString("latest_time", latest_time.ToString());
writer.WriteAttributeString("relative_time", relative_time);
writer.WriteAttributeString("assigned", assigned);
writer.WriteAttributeString("num_comments", num_comments.ToString());
this.WriteCData(writer, "Funcname", funcname);
this.WriteCData(writer, "Version", version);
writer.WriteEndElement();
};
int totalPageSize = 0;
DB.LoadCallstackList(project_uid, pageNo, pageSize, fromDate, toDate, seperate_version, specific_version, hideResolved, ItemWriter, out totalPageSize);
writer.WriteEndElement(); // Items
writer.WriteStartElement("Outputs");
this.WriteCData(writer, "TotalPageSize", totalPageSize.ToString());
writer.WriteEndElement(); // Outputs
writer.WriteEndElement(); // Callstack
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例13: writeGPX
public void writeGPX(string filename)
{
System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII);
xw.WriteStartElement("gpx");
xw.WriteAttributeString("creator", MainV2.instance.Text);
xw.WriteAttributeString("xmlns", "http://www.topografix.com/GPX/1/1");
xw.WriteStartElement("trk");
xw.WriteStartElement("trkseg");
DateTime start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
foreach (Data mod in flightdata)
{
xw.WriteStartElement("trkpt");
xw.WriteAttributeString("lat", mod.model.Location.latitude.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteAttributeString("lon", mod.model.Location.longitude.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteElementString("ele", mod.model.Location.altitude.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteElementString("time", mod.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"));
xw.WriteElementString("course", (mod.model.Orientation.heading).ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteElementString("roll", mod.model.Orientation.roll.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteElementString("pitch", mod.model.Orientation.tilt.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteElementString("mode", mod.mode);
//xw.WriteElementString("speed", mod.model.Orientation.);
//xw.WriteElementString("fix", mod.model.Location.altitude);
xw.WriteEndElement();
}
xw.WriteEndElement(); // trkseg
xw.WriteEndElement(); // trk
int a = 0;
foreach (Data mod in flightdata)
{
xw.WriteStartElement("wpt");
xw.WriteAttributeString("lat", mod.model.Location.latitude.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteAttributeString("lon", mod.model.Location.longitude.ToString(new System.Globalization.CultureInfo("en-US")));
xw.WriteElementString("name", (a++).ToString());
xw.WriteEndElement();//wpt
}
xw.WriteEndElement(); // gpx
xw.Close();
}
示例14: Ask
public void Ask(SelectableSource source, TextWriter output)
{
bool result = Ask(source);
if (MimeType == SparqlXmlQuerySink.MimeType || MimeType == "text/xml") {
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(output);
w.Formatting = System.Xml.Formatting.Indented;
w.WriteStartElement("sparql");
w.WriteAttributeString("xmlns", "http://www.w3.org/2001/sw/DataAccess/rf1/result");
w.WriteStartElement("head");
w.WriteEndElement();
w.WriteStartElement("boolean");
w.WriteString(result ? "true" : "false");
w.WriteEndElement();
w.WriteEndElement();
w.Flush();
} else if (MimeType == "text/plain") {
output.WriteLine(result ? "true" : "false");
} else {
}
}
示例15: Output
public void Output(IList<ValidationResult> list)
{
using (System.Xml.XmlTextWriter output = new System.Xml.XmlTextWriter("output.html", Encoding.Unicode))
{
output.WriteRaw("<html><head><title>results</title><style type=\"text/css\">.failedcount-0 { display: none; }</style></head><body>");
output.WriteStartElement("h1");
output.WriteRaw("Validation Results");
output.WriteEndElement();
output.WriteStartElement("h2");
output.WriteRaw("Summary");
output.WriteEndElement();
output.WriteStartElement("ul");
output.WriteAttributeString("class", "summary");
foreach (var s in Enum.GetNames(typeof(XCRI.Validation.ContentValidation.ValidationStatus))
.Where(vg => vg.ToLower() != "unknown" && vg.ToLower() != "passed")
.Reverse())
{
output.WriteStartElement("li");
output.WriteAttributeString("class", s.ToString().ToLower());
output.WriteRaw(String.Format("{0} ({1})", s, GetCount(list, s)));
var vgList = list
.Select(vr => vr.ValidationGroup)
.Distinct()
.OrderBy(vg => vg);
if (list.Where(vr => vr.Status.ToString() == s).Sum(x => x.FailedCount) > 0)
{
output.WriteStartElement("ul");
foreach (var vg in vgList)
{
var filteredModel = list.Where(vr => vr.ValidationGroup == vg).Where(vr => vr.Status.ToString() == s);
var filteredCount = filteredModel.Count();
if (filteredCount == 0)
continue;
output.WriteStartElement("li");
output.WriteRaw(String.Format("{0} {1} {2}", filteredModel.Count(), vg.ToLower(), (filteredCount == 1 ? s.ToLower() : s.ToLower() + "s")));
output.WriteEndElement(); // li
}
output.WriteEndElement(); // ul
}
output.WriteEndElement(); // li
}
output.WriteEndElement(); // ul
output.WriteStartElement("h2");
output.WriteRaw("Details");
output.WriteEndElement();
foreach (var s in Enum.GetNames(typeof(XCRI.Validation.ContentValidation.ValidationStatus))
.Where(vg => vg.ToLower() != "unknown"))
{
if (list.Where(vr => vr.Status == (XCRI.Validation.ContentValidation.ValidationStatus)Enum.Parse(typeof(XCRI.Validation.ContentValidation.ValidationStatus), s)).Sum(x => x.FailedCount) == 0)
continue;
output.WriteStartElement("h3");
output.WriteRaw(s);
output.WriteEndElement();
foreach (var vg in list
.Select(vr => vr.ValidationGroup)
.Distinct())
{
var filteredModel = list
//.Where(vr => vr.FailedCount > 0)
.Where(vr => vr.ValidationGroup == vg && vr.Status == (XCRI.Validation.ContentValidation.ValidationStatus)Enum.Parse(typeof(XCRI.Validation.ContentValidation.ValidationStatus), s))
.OrderByDescending(vr => vr.Status);
var filteredCount = filteredModel.Count();
if (filteredCount == 0)
continue;
output.WriteStartElement("div");
output.WriteAttributeString("class", "failedcount-" + filteredModel.Sum(vr => vr.FailedCount).ToString());
output.WriteStartElement("h4");
output.WriteRaw(vg);
output.WriteEndElement();
output.WriteStartElement("ul");
foreach (var vr in filteredModel)
{
output.WriteStartElement("div");
output.WriteAttributeString("class", "failedcount-" + vr.FailedCount.ToString());
output.WriteStartElement("p");
output.WriteRaw(String.Format("{0} ({1} failed instance{2})", vr.Message, vr.FailedCount, (vr.FailedCount == 1 ? String.Empty : "s")));
output.WriteEndElement();
output.WriteRaw("<table cellspacing=\"0\"><thead><tr><th class=\"status\">Status</th><th class=\"numeric\">Line Number</th><th class=\"numeric\">Line Position</th><th>Details</th></tr></thead><tbody>");
//.........这里部分代码省略.........