本文整理汇总了C#中System.Xml.XmlDocument.CreateAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.CreateAttribute方法的具体用法?C# System.Xml.XmlDocument.CreateAttribute怎么用?C# System.Xml.XmlDocument.CreateAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.CreateAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSave_Click
private void btnSave_Click(object sender, System.EventArgs e)
{
//Save the values to an XML file
//Could save to data source, Message Queue, etc.
System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
System.Xml.XmlAttribute aAttribute;
aDOM.LoadXml("<PersonnelData/>");
//Add the First Name attribute to XML
aAttribute = aDOM.CreateAttribute("FirstName");
aAttribute.Value = txtFName.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Add the Last Name attribute to XML
aAttribute = aDOM.CreateAttribute("LastName");
aAttribute.Value = txtLName.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Add the DOB attribute to XML
aAttribute = aDOM.CreateAttribute("DOB");
aAttribute.Value = txtDOB.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Add the SSN attribute to XML
aAttribute = aDOM.CreateAttribute("SSN");
aAttribute.Value = txtSSN.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Save file to the file system
aDOM.Save("PersonnelData.xml");
}
示例2: btnSave_Click
private void btnSave_Click(object sender, System.EventArgs e)
{
//Save the values to an XML file
//Could save to data source, Message Queue, etc.
System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
System.Xml.XmlAttribute aAttribute;
aDOM.LoadXml("<AutomobileData/>");
//Add the First Name attribute to XML
aAttribute = aDOM.CreateAttribute("Manufacturer");
aAttribute.Value = txtManufact.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Add the Last Name attribute to XML
aAttribute = aDOM.CreateAttribute("Model");
aAttribute.Value = txtModel.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Add the DOB attribute to XML
aAttribute = aDOM.CreateAttribute("Year");
aAttribute.Value = txtYear.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Add the SSN attribute to XML
aAttribute = aDOM.CreateAttribute("Color");
aAttribute.Value = txtColor.Text;
aDOM.DocumentElement.Attributes.Append(aAttribute);
//Save file to the file system
aDOM.Save("AutomobileData.xml");
}
示例3: btnPublishFolder_Click
private void btnPublishFolder_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtFolderPath.Text))
{
//To Publish Folder, add Data to XML
System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
// Load XML
objXmlDocument.Load(@".\Data\PublishedFolders.xml");
System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");
// Attribute Name
System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
objXmlAttribute.Value = "Carpeta";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Status
objXmlAttribute = objXmlDocument.CreateAttribute("Status");
objXmlAttribute.Value = "Enabled";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Path
objXmlAttribute = objXmlDocument.CreateAttribute("Path");
objXmlAttribute.Value = txtFolderPath.Text;
objXmlNode.Attributes.Append(objXmlAttribute);
// Add Node
objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
// Update File
objXmlDocument.Save(@".\Data\PublishedFolders.xml");
// Refresh List
LoadFolders();
}
}
示例4: SetNode
private static void SetNode(string cpath)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(cpath);
Console.WriteLine("Adding to machine.config path: {0}", cpath);
foreach (DataProvider dp in dataproviders)
{
System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
if (node == null)
{
System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
node = doc.CreateElement("add");
System.Xml.XmlAttribute at = doc.CreateAttribute("name");
node.Attributes.Append(at);
at = doc.CreateAttribute("invariant");
node.Attributes.Append(at);
at = doc.CreateAttribute("description");
node.Attributes.Append(at);
at = doc.CreateAttribute("type");
node.Attributes.Append(at);
root.AppendChild(node);
}
node.Attributes["name"].Value = dp.name;
node.Attributes["invariant"].Value = dp.invariant;
node.Attributes["description"].Value = dp.description;
node.Attributes["type"].Value = dp.type;
Console.WriteLine("Added Data Provider node in machine.config.");
}
doc.Save(cpath);
Console.WriteLine("machine.config saved: {0}", cpath);
}
示例5: GenerateDefinitionXmlElement
public System.Xml.XmlElement GenerateDefinitionXmlElement(EntitiesGenerator.Definitions.DataTable table)
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
System.Xml.XmlElement definitionElement = xmlDocument.CreateElement("Definition");
System.Xml.XmlElement xmlElement = xmlDocument.CreateElement("DataTable");
System.Xml.XmlAttribute tableNameXmlAttribute = xmlDocument.CreateAttribute("TableName");
tableNameXmlAttribute.Value = table.TableName.Trim();
xmlElement.Attributes.Append(tableNameXmlAttribute);
System.Xml.XmlAttribute sourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
sourceNameXmlAttribute.Value = table.SourceName.Trim();
xmlElement.Attributes.Append(sourceNameXmlAttribute);
foreach (EntitiesGenerator.Definitions.DataColumn column in table.Columns)
{
System.Xml.XmlElement dataColumnXmlElement = xmlDocument.CreateElement("DataColumn");
System.Xml.XmlAttribute dataColumnColumnNameXmlAttribute = xmlDocument.CreateAttribute("ColumnName");
dataColumnColumnNameXmlAttribute.Value = column.ColumnName.Trim();
dataColumnXmlElement.Attributes.Append(dataColumnColumnNameXmlAttribute);
System.Xml.XmlAttribute dataColumnSourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
dataColumnSourceNameXmlAttribute.Value = column.SourceName.Trim();
dataColumnXmlElement.Attributes.Append(dataColumnSourceNameXmlAttribute);
System.Xml.XmlAttribute dataColumnDataTypeXmlAttribute = xmlDocument.CreateAttribute("DataType");
dataColumnDataTypeXmlAttribute.Value = column.DataType.Trim();
dataColumnXmlElement.Attributes.Append(dataColumnDataTypeXmlAttribute);
if (column.PrimaryKey)
{
System.Xml.XmlAttribute dataColumnPrimaryKeyXmlAttribute = xmlDocument.CreateAttribute("PrimaryKey");
dataColumnPrimaryKeyXmlAttribute.Value = column.PrimaryKey ? "true" : "false";
dataColumnXmlElement.Attributes.Append(dataColumnPrimaryKeyXmlAttribute);
}
if (!column.AllowDBNull)
{
System.Xml.XmlAttribute dataColumnAllowDBNullXmlAttribute = xmlDocument.CreateAttribute("AllowDBNull");
dataColumnAllowDBNullXmlAttribute.Value = column.AllowDBNull ? "true" : "false";
dataColumnXmlElement.Attributes.Append(dataColumnAllowDBNullXmlAttribute);
}
if (column.AutoIncrement)
{
System.Xml.XmlAttribute dataColumnAutoIncrementXmlAttribute = xmlDocument.CreateAttribute("AutoIncrement");
dataColumnAutoIncrementXmlAttribute.Value = column.AutoIncrement ? "true" : "false";
dataColumnXmlElement.Attributes.Append(dataColumnAutoIncrementXmlAttribute);
}
// TODO: caption.
xmlElement.AppendChild(dataColumnXmlElement);
}
definitionElement.AppendChild(xmlElement);
xmlDocument.AppendChild(definitionElement);
return xmlDocument.DocumentElement;
}
示例6: ToDocumentXmlText
public string ToDocumentXmlText()
{
System.Xml.XmlDocument datagram = new System.Xml.XmlDocument();
System.Xml.XmlNode b1 = datagram.CreateElement(_Datagram.ToUpper());
foreach (KeyValuePair<string, string> curr in Parameters)
{
System.Xml.XmlAttribute b2 = datagram.CreateAttribute(curr.Key);
b2.Value = curr.Value;
b1.Attributes.Append(b2);
}
b1.InnerText = this._InnerText;
datagram.AppendChild(b1);
return datagram.InnerXml;
}
示例7: GetKML
/// <summary>
/// Get the kml for this list of datasets
/// </summary>
/// <param name="strWmsUrl"></param>
/// <param name="oDatasets"></param>
/// <param name="oSelectedDatasets"></param>
/// <returns></returns>
public static System.Xml.XmlDocument GetKML(string strWmsUrl, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
{
System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();
oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));
System.Xml.XmlElement oKml = oOutputXml.CreateElement("kml", "http://earth.google.com/kml/2.1");
oOutputXml.AppendChild(oKml);
System.Xml.XmlElement oDocument = oOutputXml.CreateElement("Document", "http://earth.google.com/kml/2.1");
System.Xml.XmlAttribute oAttr = oOutputXml.CreateAttribute("id");
oAttr.Value = "Geosoft";
oDocument.Attributes.Append(oAttr);
oKml.AppendChild(oDocument);
System.Xml.XmlElement oName = oOutputXml.CreateElement("name", "http://earth.google.com/kml/2.1");
oName.InnerText = "Geosoft Catalog";
oDocument.AppendChild(oName);
System.Xml.XmlElement oVisibility = oOutputXml.CreateElement("visibility", "http://earth.google.com/kml/2.1");
oVisibility.InnerText = "1";
oDocument.AppendChild(oVisibility);
System.Xml.XmlElement oOpen = oOutputXml.CreateElement("open", "http://earth.google.com/kml/2.1");
oOpen.InnerText = "1";
oDocument.AppendChild(oOpen);
foreach (string strKey in oSelectedDatasets)
{
Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];
if (oDataset != null)
OutputDataset(strWmsUrl, oDocument, oDataset);
}
return oOutputXml;
}
示例8: Save
/// <summary>
/// Saves the USN data to an XmlDocument
/// </summary>
/// <returns>An XmlDocument with the USN data</returns>
public System.Xml.XmlDocument Save()
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("usnroot"));
foreach (KeyValuePair<string, KeyValuePair<long, long>> kv in m_values)
{
System.Xml.XmlNode n = root.AppendChild(doc.CreateElement("usnrecord"));
n.Attributes.Append(doc.CreateAttribute("root")).Value = kv.Key;
n.Attributes.Append(doc.CreateAttribute("journalid")).Value = kv.Value.Key.ToString();
n.Attributes.Append(doc.CreateAttribute("usn")).Value = kv.Value.Value.ToString();
}
return doc;
}
示例9: SaveXmlDefaultConfigurationFile
/// <summary>
/// Create and Save a default configuration Xml file based on a easily specific or default defined xml string
/// </summary>
/// <param name="FilePath">The fullpath including filename.xml to save to</param>
/// <param name="XmlConfigurationFileString">If not specified, then will use the XmlDefaultConfigurationFileString</param>
/// <returns>True if succesfull created</returns>
/// <remarks></remarks>
public bool SaveXmlDefaultConfigurationFile(string FilePath, string XmlConfigurationFileString)
{
string theXmlString = ((XmlConfigurationFileString != null) ? XmlConfigurationFileString : XmlDefaultConfigurationFileString);
//What Method You want to use ?, try any by simply change the var XmlSaveMethod declared at top
switch (XmlSaveMethod) {
case enumXmlSaveMethod.StreamWrite:
//Easy Method
using (System.IO.StreamWriter StreamWriter = new System.IO.StreamWriter(FilePath)) {
//Without Compact Framework more easily using file.WriteAllText but, CF doesn't have this method
StreamWriter.Write(theXmlString);
StreamWriter.Close();
}
return true;
case enumXmlSaveMethod.XmlTextWriter:
//Alternative Method
using (System.Xml.XmlTextWriter XmlTextWriter = new System.Xml.XmlTextWriter(FilePath, System.Text.UTF8Encoding.UTF8)) {
XmlTextWriter.WriteStartDocument();
XmlTextWriter.WriteStartElement("configuration");
XmlTextWriter.WriteStartElement("appSettings");
foreach (string Item in GetListItems(theXmlString)) {
XmlTextWriter.WriteStartElement("add");
XmlTextWriter.WriteStartAttribute("key", string.Empty);
XmlTextWriter.WriteRaw(GetKey(Item));
XmlTextWriter.WriteEndAttribute();
XmlTextWriter.WriteStartAttribute("value", string.Empty);
XmlTextWriter.WriteRaw(GetValue(Item));
XmlTextWriter.WriteEndAttribute();
XmlTextWriter.WriteEndElement();
}
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteEndElement();
//XmlTextWriter.WriteEndDocument()
XmlTextWriter.Close();
}
return true;
case enumXmlSaveMethod.XmlDocument:
//Method you will practice
System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement xRoot = XmlDoc.CreateElement("configuration");
XmlDoc.AppendChild(xRoot);
System.Xml.XmlElement xAppSettingsElement = XmlDoc.CreateElement("appSettings");
xRoot.AppendChild(xAppSettingsElement);
System.Xml.XmlElement xElement = default(System.Xml.XmlElement);
System.Xml.XmlAttribute xAttrKey = default(System.Xml.XmlAttribute);
System.Xml.XmlAttribute xAttrValue = default(System.Xml.XmlAttribute);
foreach (string Item in GetListItems(theXmlString)) {
xElement = XmlDoc.CreateElement("add");
xAttrKey = XmlDoc.CreateAttribute("key");
xAttrValue = XmlDoc.CreateAttribute("value");
xAttrKey.InnerText = GetKey(Item);
xElement.SetAttributeNode(xAttrKey);
xAttrValue.InnerText = GetValue(Item);
xElement.SetAttributeNode(xAttrValue);
xAppSettingsElement.AppendChild(xElement);
}
System.Xml.XmlProcessingInstruction XmlPI = XmlDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
XmlDoc.InsertBefore(XmlPI, XmlDoc.ChildNodes[0]);
XmlDoc.Save(FilePath);
return true;
}
return false;
}
示例10: CheckAndFixXMLInput
void CheckAndFixXMLInput(string Filename)
{
System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
xmld.Load(Filename);
if (xmld.FirstChild.NodeType != System.Xml.XmlNodeType.XmlDeclaration)
{
System.Xml.XmlAttribute atr;
System.Xml.XmlNode node;
DateTime dt;
atr = xmld.CreateAttribute("xmlns:xsd");
atr.Value = "http://www.w3.org/2001/XMLSchema";
xmld.FirstChild.Attributes.Append(atr);
atr = xmld.CreateAttribute("xmlns:xsi");
atr.Value = "http://www.w3.org/2001/XMLSchema-instance" ;
xmld.FirstChild.Attributes.Append(atr);
atr = xmld.CreateAttribute("xmlns");
atr.Value = "http://carverlab.com/xsd/VideoExchange.xsd";
xmld.FirstChild.Attributes.Append(atr);
xmld.InsertBefore(xmld.CreateXmlDeclaration("1.0","utf-8",""),xmld.FirstChild);
node = xmld.SelectSingleNode("CARDVIDEO/TIMESTART");
dt = DateTime.Parse(node.InnerText);
node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
node = xmld.SelectSingleNode("CARDVIDEO/TIMESTOP");
dt = DateTime.Parse(node.InnerText);
node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
xmld.Save(Filename);
}
}
示例11: GetFunctionsXml
/// <summary>
/// Returns an Xml document containing information on all of the functions in the TemplateGen
/// type from the current assembly
/// </summary>
/// <returns></returns>
public string GetFunctionsXml()
{
object obj = CurrentAssembly.CreateInstance(_ProjectNamespace + ".TemplateGen");
Type objType = obj.GetType();
MethodInfo[] methods = objType.GetMethods(BindingFlags.Public | BindingFlags.Static);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode rootNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "functions", "");
foreach (MethodInfo method in methods)
{
System.Xml.XmlNode functionNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "function", "");
System.Xml.XmlAttribute attName = doc.CreateAttribute("name");
attName.Value = method.Name;
System.Xml.XmlAttribute attParamTypeName = doc.CreateAttribute("parametertypename");
ParameterInfo[] parameters = method.GetParameters();
switch (parameters.Length)
{
case 0:
attParamTypeName.Value = "";
break;
case 1:
attParamTypeName.Value = parameters[0].ParameterType.ToString();
break;
default:
attParamTypeName.Value = parameters[0].ParameterType.ToString();
// TODO: Determine how to handle Template vs. normal functions WRT number of parameters
//throw new Exception("Template functions can't have more than one parameter: "+ method.Name);
break;
}
functionNode.Attributes.Append(attName);
functionNode.Attributes.Append(attParamTypeName);
rootNode.AppendChild(functionNode);
}
doc.AppendChild(rootNode);
return doc.OuterXml;
}
示例12: ExportXml
void ExportXml(string in_path, System.Collections.Generic.IEnumerable<Google.GData.Spreadsheets.WorksheetEntry> in_entries)
{
ShowNotification(new GUIContent("Saving to: " + in_path));
Debug.Log("Saving to: " + in_path);
// Create the System.Xml.XmlDocument.
var xmlDoc = new System.Xml.XmlDocument();
var rootNode = xmlDoc.CreateElement("Sheets");
xmlDoc.AppendChild(rootNode);
foreach (Google.GData.Spreadsheets.WorksheetEntry entry in in_entries)
{
// Define the URL to request the list feed of the worksheet.
Google.GData.Client.AtomLink listFeedLink = entry.Links.FindService(Google.GData.Spreadsheets.GDataSpreadsheetsNameTable.ListRel, null);
// Fetch the list feed of the worksheet.
var listQuery = new Google.GData.Spreadsheets.ListQuery(listFeedLink.HRef.ToString());
var listFeed = _Service.Query(listQuery);
//int rowCt = listFeed.Entries.Count;
//int colCt = ((Google.GData.Spreadsheets.ListEntry)listFeed.Entries[0]).Elements.Count;
System.Xml.XmlNode sheetNode = xmlDoc.CreateElement("sheet");
System.Xml.XmlAttribute sheetName = xmlDoc.CreateAttribute("name");
sheetName.Value = entry.Title.Text;
if (sheetNode.Attributes != null)
{
sheetNode.Attributes.Append(sheetName);
rootNode.AppendChild(sheetNode);
if (listFeed.Entries.Count <= 0) continue;
// Iterate through each row, printing its cell values.
foreach (var atomEntry in listFeed.Entries)
{
var row = (Google.GData.Spreadsheets.ListEntry)atomEntry;
// Don't process rows or columns marked for _Ignore
if (GfuStrCmp(row.Title.Text, "VOID"))
{
continue;
}
System.Xml.XmlNode rowNode = xmlDoc.CreateElement("row");
System.Xml.XmlAttribute rowName = xmlDoc.CreateAttribute("name");
rowName.Value = row.Title.Text;
if (rowNode.Attributes == null) continue;
rowNode.Attributes.Append(rowName);
sheetNode.AppendChild(rowNode);
// Iterate over the remaining columns, and print each cell value
foreach (Google.GData.Spreadsheets.ListEntry.Custom element in row.Elements)
{
// Don't process rows or columns marked for _Ignore
if (GfuStrCmp(element.LocalName, "VOID"))
{
continue;
}
System.Xml.XmlNode colNode = xmlDoc.CreateElement("col");
System.Xml.XmlAttribute colName = xmlDoc.CreateAttribute("name");
colName.Value = element.LocalName;
if (colNode.Attributes != null) colNode.Attributes.Append(colName);
colNode.InnerText = element.Value;
rowNode.AppendChild(colNode);
}
}
}
}
// Save the document to a file and auto-indent the output.
var writer = new System.Xml.XmlTextWriter(in_path, null) { Formatting = System.Xml.Formatting.Indented };
xmlDoc.Save(writer);
writer.Close();
ShowNotification(new GUIContent("Saving to: " + in_path));
Debug.Log("Saving to: " + in_path);
}
示例13: Write
/// <summary>
/// Write the latest version of the XML definition file.
/// Always refer to the schema location as a relative path to the bam executable.
/// Always reference the default namespace in the first element.
/// Don't use a namespace prefix on child elements, as the default namespace covers them.
/// </summary>
public void Write()
{
if (System.IO.File.Exists(this.XMLFilename))
{
var attributes = System.IO.File.GetAttributes(this.XMLFilename);
if (0 != (attributes & System.IO.FileAttributes.ReadOnly))
{
throw new Exception("File '{0}' cannot be written to as it is read only", this.XMLFilename);
}
}
this.Dependents.Sort();
var document = new System.Xml.XmlDocument();
var namespaceURI = "http://www.buildamation.com";
var packageDefinition = document.CreateElement("PackageDefinition", namespaceURI);
{
var xmlns = "http://www.w3.org/2001/XMLSchema-instance";
var schemaAttribute = document.CreateAttribute("xsi", "schemaLocation", xmlns);
var mostRecentSchemaRelativePath = "./Schema/BamPackageDefinitionV1.xsd";
schemaAttribute.Value = System.String.Format("{0} {1}", namespaceURI, mostRecentSchemaRelativePath);
packageDefinition.Attributes.Append(schemaAttribute);
packageDefinition.SetAttribute("name", this.Name);
if (null != this.Version)
{
packageDefinition.SetAttribute("version", this.Version);
}
}
document.AppendChild(packageDefinition);
// package description
if (!string.IsNullOrEmpty(this.Description))
{
var descriptionElement = document.CreateElement("Description", namespaceURI);
descriptionElement.InnerText = this.Description;
packageDefinition.AppendChild(descriptionElement);
}
// package repositories
var packageRepos = new StringArray(this.PackageRepositories);
// TODO: could these be marked as transient?
// don't write out the repo that this package resides in
packageRepos.Remove(this.GetPackageRepository());
// nor an associated repo for tests
var associatedRepo = this.GetAssociatedPackageDirectoryForTests();
if (null != associatedRepo)
{
packageRepos.Remove(associatedRepo);
}
if (packageRepos.Count > 0)
{
var packageRootsElement = document.CreateElement("PackageRepositories", namespaceURI);
var bamDir = this.GetBamDirectory() + System.IO.Path.DirectorySeparatorChar; // slash added to make it look like a directory
foreach (string repo in packageRepos)
{
var relativePackageRepo = RelativePathUtilities.GetPath(repo, bamDir);
if (OSUtilities.IsWindowsHosting)
{
// standardize on non-Windows directory separators
relativePackageRepo = relativePackageRepo.Replace(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
}
var rootElement = document.CreateElement("Repo", namespaceURI);
rootElement.SetAttribute("dir", relativePackageRepo);
packageRootsElement.AppendChild(rootElement);
}
packageDefinition.AppendChild(packageRootsElement);
}
if (this.Dependents.Count > 0)
{
var dependentsEl = document.CreateElement("Dependents", namespaceURI);
foreach (var package in this.Dependents)
{
var packageName = package.Item1;
var packageVersion = package.Item2;
var packageIsDefault = package.Item3;
System.Xml.XmlElement packageElement = null;
{
var node = dependentsEl.FirstChild;
while (node != null)
{
var attributes = node.Attributes;
var nameAttribute = attributes["Name"];
if ((null != nameAttribute) && (nameAttribute.Value == packageName))
{
packageElement = node as System.Xml.XmlElement;
break;
}
node = node.NextSibling;
}
//.........这里部分代码省略.........
示例14: SaveDB
public override void SaveDB(string filename, DataBase tDataBase)
{
//tDataBase.WriteXml(filename)
System.Xml.XmlDocument XMLDOC = new System.Xml.XmlDocument();
XMLDOC.LoadXml("<data></data>");
XmlAttribute attr;
XmlNode newTable;
XmlNode newRow;
XmlNode newColumn;
foreach (BlackLight.Services.DB.Table tTable in tDataBase)
{
newTable = XMLDOC.CreateNode(XmlNodeType.Element, "table", "");
XMLDOC.DocumentElement.AppendChild(newTable);
attr = XMLDOC.CreateAttribute("name");
attr.Value = tTable.Name;
newTable.Attributes.Append(attr);
attr = XMLDOC.CreateAttribute("columns");
attr.Value = Convert.ToString(tTable.Columns.Count);
newTable.Attributes.Append(attr);
attr = XMLDOC.CreateAttribute("primary");
attr.Value = tTable.PrimaryColumn;
newTable.Attributes.Append(attr);
foreach (BlackLight.Services.DB.Column tColumn in tTable.Columns)
{
newColumn = XMLDOC.CreateNode(XmlNodeType.Element, "column", "");
newTable.AppendChild(newColumn);
attr = XMLDOC.CreateAttribute("name");
attr.Value = tColumn.Name;
newColumn.Attributes.Append(attr);
attr = XMLDOC.CreateAttribute("type");
attr.Value = Convert.ToString(tColumn.DType);
newColumn.Attributes.Append(attr);
}
foreach (BlackLight.Services.DB.Row tRow in tTable)
{
newRow = XMLDOC.CreateNode(XmlNodeType.Element, "row", "");
newTable.AppendChild(newRow);
foreach (BlackLight.Services.DB.Column tColumn in tTable.Columns)
{
attr = XMLDOC.CreateAttribute(tColumn.Name);
attr.Value = System.Convert.ToString(tRow[tColumn.Name]);
newRow.Attributes.Append(attr);
}
}
}
if (System.IO.Directory.Exists("data") == false)
{
System.IO.Directory.CreateDirectory("data");
}
XMLDOC.Save("data\\" + filename);
}
示例15: CreatePlist
private void CreatePlist()
{
var doc = new System.Xml.XmlDocument();
// don't resolve any URLs, or if there is no internet, the process will pause for some time
doc.XmlResolver = null;
{
var type = doc.CreateDocumentType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
doc.AppendChild(type);
}
var plistEl = doc.CreateElement("plist");
{
var versionAttr = doc.CreateAttribute("version");
versionAttr.Value = "1.0";
plistEl.Attributes.Append(versionAttr);
}
var dictEl = doc.CreateElement("dict");
plistEl.AppendChild(dictEl);
doc.AppendChild(plistEl);
#if true
// TODO: this seems to be the only way to get the target settings working
CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "UseTargetSettings");
#else
// build and intermediate file locations
CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "CustomLocation");
CreateKeyValuePair(doc, dictEl, "CustomBuildIntermediatesPath", "XcodeIntermediates"); // where xxx.build folders are stored
CreateKeyValuePair(doc, dictEl, "CustomBuildLocationType", "RelativeToWorkspace");
CreateKeyValuePair(doc, dictEl, "CustomBuildProductsPath", "."); // has to be the workspace folder, in order to write files to expected locations
// derived data
CreateKeyValuePair(doc, dictEl, "DerivedDataCustomLocation", "XcodeDerivedData");
CreateKeyValuePair(doc, dictEl, "DerivedDataLocationStyle", "WorkspaceRelativePath");
#endif
this.Document = doc;
}