Here are the examples of the csharp api System.Xml.XmlDocument.CreateElement(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
629 Examples
19
Source : DotNetToJScript.cs
with MIT License
from 1y0n
with MIT License
from 1y0n
static string CreateScriptlet(string script, string script_name, bool register_script, Guid clsid)
{
XmlDoreplacedent doc = new XmlDoreplacedent();
doc.LoadXml(Global_Var.scriptlet_template);
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = true;
settings.Encoding = new UTF8Encoding(false);
XmlElement reg_node = (XmlElement)doc.SelectSingleNode("/package/component/registration");
XmlNode root_node = register_script ? reg_node : doc.SelectSingleNode("/package/component");
XmlNode script_node = root_node.AppendChild(doc.CreateElement("script"));
script_node.Attributes.Append(doc.CreateAttribute("language")).Value = script_name;
script_node.AppendChild(doc.CreateCDataSection(script));
if (clsid != Guid.Empty)
{
reg_node.SetAttribute("clreplacedid", clsid.ToString("B"));
}
using (MemoryStream stm = new MemoryStream())
{
using (XmlWriter writer = XmlWriter.Create(stm, settings))
{
doc.Save(writer);
}
return Encoding.UTF8.GetString(stm.ToArray());
}
}
19
Source : GameSaveLoadInMem.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
[HarmonyPrefix]
public static bool Prefix(ScribeLoader __instance, string filePath)
{
if (!ScribeLoader_InitLoading_Patch.Enable) return true;
Loger.Log("ScribeLoader_InitLoadingMetaHeaderOnly_Patch Start");
if (Scribe.mode != 0)
{
Log.Error("Called InitLoadingMetaHeaderOnly() but current mode is " + Scribe.mode);
Scribe.ForceStop();
}
try
{
using (var input = new MemoryStream(ScribeLoader_InitLoading_Patch.LoadData))
//using (StreamReader input = new StreamReader(filePath))
{
using (XmlTextReader xmlTextReader = new XmlTextReader(input))
{
if (!ScribeMetaHeaderUtility.ReadToMetaElement(xmlTextReader))
{
return false;
}
using (XmlReader reader = xmlTextReader.ReadSubtree())
{
XmlDoreplacedent xmlDoreplacedent = new XmlDoreplacedent();
xmlDoreplacedent.Load(reader);
XmlElement xmlElement = xmlDoreplacedent.CreateElement("root");
xmlElement.AppendChild(xmlDoreplacedent.DoreplacedentElement);
__instance.curXmlParent = xmlElement;
}
}
}
Scribe.mode = LoadSaveMode.LoadingVars;
}
catch (Exception ex)
{
Log.Error("Exception while init loading meta header: " + filePath + "\n" + ex);
__instance.ForceStop();
throw;
}
Loger.Log("ScribeLoader_InitLoadingMetaHeaderOnly_Patch End");
return false;
}
19
Source : ObjectCacheExtensions.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
public static XmlDoreplacedent GetCacheFootprintXml(this ObjectCache cache, bool expanded, Uri requestUrl)
{
var alternateLink = new Uri(requestUrl.GetLeftPart(UriPartial.Path));
var doc = new XmlDoreplacedent();
var rootElement = doc.CreateElement("CacheFootprint");
var enreplacedyElements = new List<XmlElement>();
var footprint = GetCacheFootprint(cache, alternateLink);
foreach (var enreplacedyType in footprint)
{
var enreplacedyElement = doc.CreateElement("Enreplacedy");
enreplacedyElement.SetAttribute("Name", enreplacedyType.Name);
enreplacedyElement.SetAttribute("Count", enreplacedyType.GetCount().ToString());
enreplacedyElement.SetAttribute("Size", enreplacedyType.GetSize().ToString());
if (expanded)
{
foreach (var item in enreplacedyType.Items)
{
var itemElement = doc.CreateElement("Item");
itemElement.SetAttribute("LogicalName", item.Enreplacedy.LogicalName);
itemElement.SetAttribute("Name", item.Enreplacedy.GetAttributeValueOrDefault("adx_name", string.Empty));
itemElement.SetAttribute("Id", item.Enreplacedy.Id.ToString());
var cacheElement = doc.CreateElement("Cache");
cacheElement.SetAttribute("Id", item.CacheItemKey);
cacheElement.SetAttribute("Type", item.CacheItemType.ToString());
cacheElement.SetAttribute("Link", item.Link.ToString());
cacheElement.SetAttribute("Size", GetEnreplacedySizeInMemory(item.Enreplacedy).ToString());
itemElement.AppendChild(cacheElement);
enreplacedyElement.AppendChild(itemElement);
}
}
enreplacedyElements.Add(enreplacedyElement);
}
// Sort the enreplacedies by descending size
enreplacedyElements = enreplacedyElements.OrderByDescending(el => int.Parse(el.GetAttribute("Size"))).ToList();
var enreplacediesElement = doc.CreateElement("Enreplacedies");
foreach (var enreplacedyElement in enreplacedyElements)
{
enreplacediesElement.AppendChild(enreplacedyElement);
}
if (!expanded)
{
// Add link to the Expanded view with enreplacedy record details
var query = System.Web.HttpUtility.ParseQueryString(requestUrl.Query);
query[Web.Handlers.CacheFeedHandler.QueryKeys.Expanded] = bool.TrueString;
var uriBuilder = new UriBuilder(requestUrl.ToString()) { Query = query.ToString() };
var expandedView = doc.CreateElement("expandedView");
expandedView.InnerText = uriBuilder.ToString();
rootElement.AppendChild(expandedView);
}
rootElement.AppendChild(enreplacediesElement);
doc.AppendChild(rootElement);
return doc;
}
19
Source : EpubBuilder.cs
with GNU General Public License v3.0
from Aeroblast
with GNU General Public License v3.0
from Aeroblast
void ProcTextRef(XmlAttribute attr)
{
Regex reg_link = new Regex("kindle:flow:([0-9|A-V]+)\\?mime=.*?/(.*)");
Match m = reg_link.Match(attr.Value);
if (!m.Success)
{ Log.log("[Error]link unsolved"); return; }
int flowid = (int)Util.DecodeBase32(m.Groups[1].Value);
string mime = m.Groups[2].Value;
if (flowid < 0)
{
attr.Value = "flow" + (10000 + flowid);
Log.log("[Warn]placeholder link: " + m.Value);
return;
}
switch (mime)
{
case "css":
string name = "flow" + Util.Number(flowid) + ".css";
if (css_names.Find(s => s == name) == null)
{
string csstext = azw3.flows[flowid - 1];
csstext = ProcCSS(csstext);
csss.Add(csstext);
css_names.Add(name);
azw3.flowProcessLog[flowid - 1] = name;
}
attr.Value = "../Styles/" + name;
break;
case "svg+xml":
{
string text = azw3.flows[flowid - 1];
XmlElement svg = attr.OwnerDoreplacedent.CreateElement("temp");
svg.InnerXml = text;
foreach (XmlNode n in svg.ChildNodes)
{
if (n.Name == "svg")
{
attr.OwnerElement.ParentNode.InsertBefore(n, attr.OwnerElement);
attr.OwnerElement.ParentNode.RemoveChild(attr.OwnerElement);
ProcNodes(n);
}
if (n.Name == "xml-stylesheet")
{
Regex reg_link2 = new Regex("kindle:flow:([0-9|A-V]+)\\?mime=.*?/(.*?)\"");
Match ml = reg_link2.Match(n.OuterXml);
if (ml.Success && ml.Groups[2].Value == "css")
{
int flowid_ = (int)Util.DecodeBase32(ml.Groups[1].Value);
string name_ = "flow" + Util.Number(flowid_) + ".css";
bool alreadyHave = false;
foreach (XmlElement linktag in n.OwnerDoreplacedent.GetElementsByTagName("link"))
{
if (linktag.GetAttribute("href") == "../Styles/" + name_)
{ alreadyHave = true; break; }
}
if (!alreadyHave)
{
//rel="stylesheet" type="text/css"
XmlElement l = n.OwnerDoreplacedent.CreateElement("link");
l.SetAttribute("href", "../Styles/" + name_);
l.SetAttribute("type", "text/css");
l.SetAttribute("rel", "stylesheet");
n.OwnerDoreplacedent.GetElementsByTagName("head")[0].AppendChild(l);
if (css_names.Find(s => s == name_) == null)
{
string csstext = azw3.flows[flowid_ - 1];
csstext = ProcCSS(csstext);
csss.Add(csstext);
css_names.Add(name_);
azw3.flowProcessLog[flowid_ - 1] = name_;
}
}
}
else
{ Log.log("cannot find css link in xml-stylesheet"); }
}
}
azw3.flowProcessLog[flowid - 1] = "Flow" + Util.Number(flowid) + " svg has been put into xhtmls";
}
break;
}
}
19
Source : EpubBuilder.cs
with GNU General Public License v3.0
from Aeroblast
with GNU General Public License v3.0
from Aeroblast
void CreateOPF()
{
if (azw3.resc != null)
{
string t = File.ReadAllText("template\\template_opf.txt");
XmlDoreplacedent manifest = new XmlDoreplacedent();
XmlElement mani_root = manifest.CreateElement("manifest");
manifest.AppendChild(mani_root);
int i = 0;
foreach (XmlNode itemref in azw3.resc.spine.FirstChild.ChildNodes)
{
if (itemref.NodeType != XmlNodeType.Element) continue;
itemref.Attributes.RemoveNamedItem("skelid");
string idref = itemref.Attributes.GetNamedItem("idref").Value;
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "Text/" + xhtml_names[i]);
item.SetAttribute("id", idref);
item.SetAttribute("media-type", "application/xhtml+xml");
if (ContainsSVG(xhtmls[i]))
{
item.SetAttribute("properties", "svg");
}
mani_root.AppendChild(item);
i++;
}
if (i > xhtmls.Count) Log.log("[Warn] Missing Parts. Ignore if this is a book sample.");
if (i < xhtmls.Count)
{
Log.log("[Warn]Not all xhtmls are refered in spine.");
for (; i < xhtmls.Count; i++)
{
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "Text/" + xhtml_names[i]);
item.SetAttribute("id", xhtml_names[i]);
item.SetAttribute("media-type", "application/xhtml+xml");
if (ContainsSVG(xhtmls[i]))
{
item.SetAttribute("properties", "svg");
}
mani_root.AppendChild(item);
XmlElement itemref = azw3.resc.spine.CreateElement("itemref");
itemref.SetAttribute("idref", xhtml_names[i]);
itemref.SetAttribute("linear", "yes");
azw3.resc.spine.FirstChild.AppendChild(itemref);
Log.log("[Warn]Added " + xhtml_names[i] + " to spine and item");
}
}
foreach (string imgname in img_names)
{
string ext = Path.GetExtension(imgname).ToLower().Substring(1);
if (ext == "jpg") ext = "jpeg";
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "Images/" + imgname);
if (imgname == cover_name) { item.SetAttribute("properties", "cover-image"); }
item.SetAttribute("id", Path.GetFileNameWithoutExtension(imgname));
item.SetAttribute("media-type", "image/" + ext);
mani_root.AppendChild(item);
}
foreach (string cssname in css_names)
{
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "Styles/" + cssname);
item.SetAttribute("id", Path.GetFileNameWithoutExtension(cssname));
item.SetAttribute("media-type", "text/css");
mani_root.AppendChild(item);
}
foreach (string fontname in font_names)
{
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "Fonts/" + fontname);
item.SetAttribute("id", Path.GetFileNameWithoutExtension(fontname));
string mediaType = "";
switch (Path.GetExtension(fontname))
{
case ".ttf": mediaType = "application/font-sfnt"; break;
case ".otf": mediaType = "application/font-sfnt"; break;
}
item.SetAttribute("media-type", mediaType);
mani_root.AppendChild(item);
}
{
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "toc.ncx");
item.SetAttribute("id", "ncxuks");
item.SetAttribute("media-type", "application/x-dtbncx+xml");
mani_root.AppendChild(item);
}
{
XmlElement item = manifest.CreateElement("item");
item.SetAttribute("href", "nav.xhtml");
item.SetAttribute("id", "navuks");
item.SetAttribute("media-type", "application/xhtml+xml");
item.SetAttribute("properties", "nav");
mani_root.AppendChild(item);
}
t = t.Replace("{❕manifest}", manifest.OuterXml.Replace("><", ">\r\n<"));
XmlDoreplacedent meta = new XmlDoreplacedent();
meta.AppendChild(meta.CreateElement("metadata"));
((XmlElement)meta.FirstChild).SetAttribute("xmlns:dc", "http://purl");
{
XmlElement x = meta.CreateElement("dc:replacedle");
x.InnerText = azw3.replacedle;
x.SetAttribute("id", "replacedle");
meta.FirstChild.AppendChild(x);
if (azw3.mobi_header.extMeta.id_string.ContainsKey(508))
{
string z = azw3.mobi_header.extMeta.id_string[508];
XmlElement x2 = meta.CreateElement("meta");
x2.InnerText = z;
x2.SetAttribute("refines", "#replacedle");
x2.SetAttribute("property", "file-as");
meta.FirstChild.AppendChild(x2);
}
}
{
string lang = azw3.mobi_header.extMeta.id_string[524];
XmlElement x = meta.CreateElement("dc:language");
x.InnerXml = lang;
meta.FirstChild.AppendChild(x);
}
{
XmlElement x = meta.CreateElement("dc:identifier");
x.SetAttribute("id", "ASIN");
//x.SetAttribute("opf:scheme", "ASIN");
string z = azw3.mobi_header.extMeta.id_string[504];
x.InnerXml = z;
meta.FirstChild.AppendChild(x);
XmlElement xd = meta.CreateElement("meta");
xd.SetAttribute("property", "dcterms:modified");
xd.InnerText = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ");
meta.FirstChild.AppendChild(xd);
}
if (azw3.mobi_header.extMeta.id_string.ContainsKey(100))
{
string[] creatername = azw3.mobi_header.extMeta.id_string[100].Split('&');
string[] sortname = new string[0];
if (azw3.mobi_header.extMeta.id_string.ContainsKey(517))
sortname = azw3.mobi_header.extMeta.id_string[517].Split('&');
for (int l = 0; l < creatername.Length; l++)
{
XmlElement x = meta.CreateElement("dc:creator");
x.InnerText = creatername[l];
x.SetAttribute("id", "creator" + l);
meta.FirstChild.AppendChild(x);
if (l < sortname.Length)
{
XmlElement x2 = meta.CreateElement("meta");
x2.InnerText = sortname[l];
x2.SetAttribute("refines", "#creator" + l);
x2.SetAttribute("property", "file-as");
meta.FirstChild.AppendChild(x2);
}
}
}
if (azw3.mobi_header.extMeta.id_string.ContainsKey(101))
{
XmlElement x = meta.CreateElement("dc:publisher");
x.SetAttribute("id", "publisher");
x.InnerText = azw3.mobi_header.extMeta.id_string[101];
meta.FirstChild.AppendChild(x);
if (azw3.mobi_header.extMeta.id_string.ContainsKey(522))
{
string fileas = azw3.mobi_header.extMeta.id_string[522];
XmlElement x2 = meta.CreateElement("meta");
x2.InnerText = fileas;
x2.SetAttribute("refines", "#publisher");
x2.SetAttribute("property", "file-as");
meta.FirstChild.AppendChild(x2);
}
}
if (azw3.mobi_header.extMeta.id_string.ContainsKey(106))
{
XmlElement x = meta.CreateElement("dc:date");
string date = azw3.mobi_header.extMeta.id_string[106];
//x.SetAttribute("opf:event", "publication");
x.InnerText = date;
meta.FirstChild.AppendChild(x);
}
//fixed layout
if (azw3.mobi_header.extMeta.id_string.ContainsKey(122))
{
string v = azw3.mobi_header.extMeta.id_string[122];
if (v == "true")
{
//<meta property="rendition:layout">pre-paginated</meta>
//<meta property="rendition:orientation">auto</meta>
//<meta property="rendition:spread">landscape</meta>
XmlElement x;
x = meta.CreateElement("meta");
x.SetAttribute("property", "rendition:layout");
x.InnerText = "pre-paginated";
meta.FirstChild.AppendChild(x);
x = meta.CreateElement("meta");
x.SetAttribute("property", "rendition:orientation");
x.InnerText = "auto";
meta.FirstChild.AppendChild(x);
x = meta.CreateElement("meta");
x.SetAttribute("property", "rendition:spread");
x.InnerText = "landscape";
meta.FirstChild.AppendChild(x);
}
}
//normal meta
var normalMetas = new (uint, string)[] {
( 525, "primary-writing-mode" ),
( 123, "book-type" ),
( 124, "orientation-lock"),
( 126, "original-resolution" )
};
foreach (var nm in normalMetas)
{
if (azw3.mobi_header.extMeta.id_string.ContainsKey(nm.Item1))
{
string v = azw3.mobi_header.extMeta.id_string[nm.Item1];
{
XmlElement x = meta.CreateElement("meta");
x.SetAttribute("name", nm.Item2);
x.SetAttribute("content", v);
meta.FirstChild.AppendChild(x);
}
}
}
if (fonts.Count > 0)
{
XmlElement x = meta.CreateElement("meta");
x.SetAttribute("name", "ibooks:specified-fonts");
x.SetAttribute("content", "true");
meta.FirstChild.AppendChild(x);
}
{
string metaTemplate = "<meta name=\"{0}\" content=\"{1}\" />\n";
string tempstr = "";
if (azw3.mobi_header.extMeta.id_string.ContainsKey(503))
{ tempstr += string.Format(metaTemplate, IdMapping.id_map_strings[503], azw3.mobi_header.extMeta.id_string[503]); }
t = t.Replace("{❕othermeta}", tempstr);
}
t = t.Replace("{❕meta}", Util.GetInnerXML((XmlElement)meta.FirstChild));
//string metas = azw3.resc.metadata.OuterXml;
((XmlElement)(azw3.resc.spine.FirstChild)).SetAttribute("toc", "ncxuks"); ;
string spine = azw3.resc.spine.OuterXml;
t = t.Replace("{❕spine}", spine.Replace("><", ">\n<"));
t = t.Replace("{❕version}", Version.version);
opf = t;
}
else
{
throw new UnpackKindleSException("no resc info!");
}
}
19
Source : ConfigurationBase.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public void SaveConfiguration(string filename)
{
try
{
Dictionary<string, object> dic = this.GetConfigurations();
XmlDoreplacedent doc = new XmlDoreplacedent();
doc.LoadXml(string.Format(@"<{0}></{0}>", ROOT_ELEMENT));
foreach (string key in dic.Keys)
{
var node = doc.CreateElement(key);
node.InnerText = DataConverter.Serilize(dic[key]);
doc.DoreplacedentElement.AppendChild(node);
}
string xml;
using (StringWriter sw = new StringWriter())
using (XmlTextWriter tw = new XmlTextWriter(sw))
{
doc.WriteTo(tw);
xml = sw.GetStringBuilder().ToString();
}
byte[] bs = Convert.FromBase64String(Encryption.Encrypt(xml));
File.WriteAllBytes(filename, bs);
}
catch (Exception ex) { TraceLogger.Instance.WriteException(ex); throw; }
}
19
Source : Serialization.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public static string ToXml(object obj, string rootElement = null)
{
System.Xml.XmlDoreplacedent doc = new System.Xml.XmlDoreplacedent();
doc.LoadXml(string.Format(@"<{0}></{0}>", obj.GetType().Name));
PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
foreach (var p in props)
{
var node = doc.CreateElement(p.Name);
node.InnerText = Convert.ToString(p.GetValue(obj, null));
doc.DoreplacedentElement.AppendChild(node);
}
return doc.OuterXml;
}
19
Source : ConfigurationBase.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public void SaveConfiguration(string filename)
{
try
{
Dictionary<string, object> dic = this.GetConfigurations();
XmlDoreplacedent doc = new XmlDoreplacedent();
doc.LoadXml(string.Format(@"<{0}></{0}>", ROOT_ELEMENT));
foreach (string key in dic.Keys)
{
var node = doc.CreateElement(key);
node.InnerText = DataConverter.Serialize(dic[key]);
doc.DoreplacedentElement.AppendChild(node);
}
string xml;
using (StringWriter sw = new StringWriter())
using (XmlTextWriter tw = new XmlTextWriter(sw))
{
doc.WriteTo(tw);
xml = sw.GetStringBuilder().ToString();
}
byte[] bs = Convert.FromBase64String(Encryption.Encrypt(xml));
File.WriteAllBytes(filename, bs);
}
catch (Exception ex) { TraceLogger.Instance.WriteException(ex); throw; }
}
19
Source : XmlNodeConverter.cs
with MIT License
from akaskela
with MIT License
from akaskela
public IXmlElement CreateElement(string elementName)
{
return new XmlElementWrapper(_doreplacedent.CreateElement(elementName));
}
19
Source : ClassType.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
XmlElement child = node.OwnerDoreplacedent.CreateElement("Modifier");
child.InnerText = Modifier.ToString();
node.AppendChild(child);
// Save the stereotype.
XmlElement childStereotype = node.OwnerDoreplacedent.CreateElement("Stereotype");
childStereotype.InnerText = Stereotype;
node.AppendChild(childStereotype);
}
19
Source : DelegateType.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
XmlElement returnTypeNode = node.OwnerDoreplacedent.CreateElement("ReturnType");
returnTypeNode.InnerText = ReturnType.ToString();
node.AppendChild(returnTypeNode);
foreach (Parameter parameter in argumentList)
{
XmlElement paramNode = node.OwnerDoreplacedent.CreateElement("Param");
paramNode.InnerText = parameter.ToString();
node.AppendChild(paramNode);
}
}
19
Source : EnumType.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
foreach (EnumValue value in values) {
XmlElement child = node.OwnerDoreplacedent.CreateElement("Value");
child.InnerText = value.ToString();
node.AppendChild(child);
}
}
19
Source : Model.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
private void Serialize(XmlElement node)
{
if (node == null)
throw new ArgumentNullException("root");
XmlElement nameElement = node.OwnerDoreplacedent.CreateElement("Name");
nameElement.InnerText = Name;
node.AppendChild(nameElement);
XmlElement languageElement = node.OwnerDoreplacedent.CreateElement("Language");
languageElement.InnerText = Language.replacedemblyName;
node.AppendChild(languageElement);
SaveEnreplacedites(node);
SaveRelationships(node);
OnSerializing(new SerializeEventArgs(node));
}
19
Source : Model.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
private void SaveEnreplacedites(XmlElement node)
{
if (node == null)
throw new ArgumentNullException("root");
XmlElement enreplacediesChild = node.OwnerDoreplacedent.CreateElement("Enreplacedies");
foreach (IEnreplacedy enreplacedy in enreplacedies)
{
XmlElement child = node.OwnerDoreplacedent.CreateElement("Enreplacedy");
enreplacedy.Serialize(child);
child.SetAttribute("type", enreplacedy.EnreplacedyType.ToString());
if (enreplacedy is ClreplacedType)
{
child.SetAttribute("nhmTableName", enreplacedy.NHMTableName);
child.SetAttribute("idGenerator", enreplacedy.IdGenerator);
}
enreplacediesChild.AppendChild(child);
}
node.AppendChild(enreplacediesChild);
}
19
Source : AssociationRelationship.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
XmlElement directionNode = node.OwnerDoreplacedent.CreateElement("Direction");
directionNode.InnerText = Direction.ToString();
node.AppendChild(directionNode);
XmlElement aggregationNode = node.OwnerDoreplacedent.CreateElement("replacedociationType");
aggregationNode.InnerText = replacedociationType.ToString();
node.AppendChild(aggregationNode);
if (StartRole != null)
{
XmlElement roleNode = node.OwnerDoreplacedent.CreateElement("StartRole");
roleNode.InnerText = StartRole.ToString();
node.AppendChild(roleNode);
}
if (EndRole != null)
{
XmlElement roleNode = node.OwnerDoreplacedent.CreateElement("EndRole");
roleNode.InnerText = EndRole.ToString();
node.AppendChild(roleNode);
}
if (StartMultiplicity != null)
{
XmlElement multiplicityNode = node.OwnerDoreplacedent.CreateElement("StartMultiplicity");
multiplicityNode.InnerText = StartMultiplicity.ToString();
node.AppendChild(multiplicityNode);
}
if (EndMultiplicity != null)
{
XmlElement multiplicityNode = node.OwnerDoreplacedent.CreateElement("EndMultiplicity");
multiplicityNode.InnerText = EndMultiplicity.ToString();
node.AppendChild(multiplicityNode);
}
}
19
Source : Model.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
private void SaveRelationships(XmlNode root)
{
if (root == null)
throw new ArgumentNullException("root");
XmlElement relationsChild = root.OwnerDoreplacedent.CreateElement("Relationships");
foreach (Relationship relationship in relationships)
{
XmlElement child = root.OwnerDoreplacedent.CreateElement("Relationship");
int firstIndex = enreplacedies.IndexOf(relationship.First);
int secondIndex = enreplacedies.IndexOf(relationship.Second);
relationship.Serialize(child);
child.SetAttribute("type", relationship.RelationshipType.ToString());
child.SetAttribute("first", firstIndex.ToString());
child.SetAttribute("second", secondIndex.ToString());
relationsChild.AppendChild(child);
}
root.AppendChild(relationsChild);
}
19
Source : Project.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
public void Save(string fileName)
{
if (string.IsNullOrEmpty(fileName))
throw new ArgumentException(Strings.ErrorBlankFilename, "fileName");
XmlDoreplacedent doreplacedent = new XmlDoreplacedent();
XmlElement root = doreplacedent.CreateElement("Project");
doreplacedent.AppendChild(root);
Serialize(root);
try
{
doreplacedent.Save(fileName);
}
catch (Exception ex)
{
throw new IOException(Strings.ErrorCouldNotSaveFile, ex);
}
isReadOnly = false;
FilePath = fileName;
Clean();
}
19
Source : Project.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
private void Serialize(XmlElement node)
{
XmlElement nameElement = node.OwnerDoreplacedent.CreateElement("Name");
nameElement.InnerText = this.Name;
node.AppendChild(nameElement);
foreach (IProjecreplacedem item in Items)
{
XmlElement itemElement = node.OwnerDoreplacedent.CreateElement("Projecreplacedem");
item.Serialize(itemElement);
Type type = item.GetType();
XmlAttribute typeAttribute = node.OwnerDoreplacedent.CreateAttribute("type");
typeAttribute.InnerText = type.FullName;
itemElement.Attributes.Append(typeAttribute);
XmlAttribute replacedemblyAttribute = node.OwnerDoreplacedent.CreateAttribute("replacedembly");
replacedemblyAttribute.InnerText = type.replacedembly.FullName;
itemElement.Attributes.Append(replacedemblyAttribute);
node.AppendChild(itemElement);
}
}
19
Source : Comment.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
internal void Serialize(XmlElement node)
{
if (node == null)
throw new ArgumentNullException("node");
XmlElement child = node.OwnerDoreplacedent.CreateElement("Text");
child.InnerText = Text;
node.AppendChild(child);
OnSerializing(new SerializeEventArgs(node));
}
19
Source : CompositeType.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
foreach (Field field in FieldList)
{
XmlElement child = node.OwnerDoreplacedent.CreateElement("Member");
child.SetAttribute("type", field.MemberType.ToString());
child.InnerText = field.ToString();
node.AppendChild(child);
}
foreach (Operation operation in OperationList)
{
XmlElement child = node.OwnerDoreplacedent.CreateElement("Member");
child.SetAttribute("type", operation.MemberType.ToString());
if (operation is Property)
{
child.SetAttribute("nhmColumnName", operation.NHMColumnName);
child.SetAttribute("isIdenreplacedy", operation.IsIdenreplacedy.ToString());
child.SetAttribute("manyToOne", operation.ManyToOne);
child.SetAttribute("isUnique", operation.IsUnique.ToString());
child.SetAttribute("isNotNull", operation.IsNotNull.ToString());
}
child.InnerText = operation.ToString();
node.AppendChild(child);
}
}
19
Source : TypeBase.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal virtual void Serialize(XmlElement node)
{
if (node == null)
throw new ArgumentNullException("node");
XmlElement child;
child = node.OwnerDoreplacedent.CreateElement("GeneratorParameters");
child.InnerXml = GeneratorParameters;
node.AppendChild(child);
child = node.OwnerDoreplacedent.CreateElement("Name");
child.InnerText = Name;
node.AppendChild(child);
child = node.OwnerDoreplacedent.CreateElement("Access");
child.InnerText = AccessModifier.ToString();
node.AppendChild(child);
OnSerializing(new SerializeEventArgs(node));
}
19
Source : Relationship.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected internal virtual void Serialize(XmlElement node)
{
if (node == null)
throw new ArgumentNullException("node");
if (SupportsLabel && Label != null)
{
XmlElement labelNode = node.OwnerDoreplacedent.CreateElement("Label");
labelNode.InnerText = Label.ToString();
node.AppendChild(labelNode);
}
OnSerializing(new SerializeEventArgs(node));
}
19
Source : BendPoint.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
internal void Serialize(XmlElement node)
{
XmlDoreplacedent doreplacedent = node.OwnerDoreplacedent;
XmlElement xNode = doreplacedent.CreateElement("X");
xNode.InnerText = X.ToString();
node.AppendChild(xNode);
XmlElement yNode = doreplacedent.CreateElement("Y");
yNode.InnerText = Y.ToString();
node.AppendChild(yNode);
}
19
Source : Connection.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected virtual void OnSerializing(SerializeEventArgs e)
{
XmlDoreplacedent doreplacedent = e.Node.OwnerDoreplacedent;
XmlElement startNode = doreplacedent.CreateElement("StartOrientation");
startNode.InnerText = startOrientation.ToString();
e.Node.AppendChild(startNode);
XmlElement endNode = doreplacedent.CreateElement("EndOrientation");
endNode.InnerText = endOrientation.ToString();
e.Node.AppendChild(endNode);
foreach (BendPoint point in bendPoints)
{
if (!point.AutoPosition)
{
XmlElement node = doreplacedent.CreateElement("BendPoint");
node.SetAttribute("relativeToStartShape", point.RelativeToStartShape.ToString());
point.Serialize(node);
e.Node.AppendChild(node);
}
}
}
19
Source : PersistentSettings.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public void Save(string fileName) {
XmlDoreplacedent doc = new XmlDoreplacedent();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
XmlElement configuration = doc.CreateElement("configuration");
doc.AppendChild(configuration);
XmlElement appSettings = doc.CreateElement("appSettings");
configuration.AppendChild(appSettings);
foreach (KeyValuePair<string, string> keyValuePair in settings) {
XmlElement add = doc.CreateElement("add");
add.SetAttribute("key", keyValuePair.Key);
add.SetAttribute("value", keyValuePair.Value);
appSettings.AppendChild(add);
}
byte[] file;
using (var memory = new MemoryStream()) {
using (var writer = new StreamWriter(memory, Encoding.UTF8)) {
doc.Save(writer);
}
file = memory.ToArray();
}
string backupFileName = fileName + ".backup";
if (File.Exists(fileName)) {
try {
File.Delete(backupFileName);
} catch { }
try {
File.Move(fileName, backupFileName);
} catch { }
}
using (var stream = new FileStream(fileName,
FileMode.Create, FileAccess.Write))
{
stream.Write(file, 0, file.Length);
}
try {
File.Delete(backupFileName);
} catch { }
}
19
Source : BooleanPropertyBaseTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldIgnoreDefaultValue()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement node = xmlDoc.CreateElement("boolean");
mSut.Save(xmlDoc, node);
Collectionreplacedert.IsEmpty(node.ChildNodes);
}
19
Source : FileTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldNotSaveAppendTo_WhenOverwriteIsFalse()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Save(xmlDoc, appender);
//1 for file
replacedert.AreEqual(1, appender.ChildNodes.Count);
}
19
Source : FileTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldNotSavePatternString_WhenPatternStringIsFalse()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.PatternString = false;
mSut.Save(xmlDoc, appender);
XmlNode fileNode = appender.SelectSingleNode("file");
replacedert.IsNull(fileNode?.Attributes?["type"]);
}
19
Source : FileTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveAppendTo_WhenOverwriteIsTrue()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Overwrite = true;
mSut.Save(xmlDoc, appender);
XmlNode appendToNode = appender.SelectSingleNode("appendToFile");
replacedert.IsNotNull(appendToNode);
replacedert.AreEqual("false", appendToNode.Attributes?["value"].Value);
}
19
Source : FileTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveFilePath()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.FilePath = "filepath";
mSut.Save(xmlDoc, appender);
XmlNode fileNode = appender.SelectSingleNode("file");
replacedert.IsNotNull(fileNode);
replacedert.AreEqual("filepath", fileNode.Attributes?["value"].Value);
}
19
Source : FileTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSavePatternString_WhenPatternStringIsTrue()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.PatternString = true;
mSut.Save(xmlDoc, appender);
XmlNode fileNode = appender.SelectSingleNode("file");
replacedert.AreEqual("log4net.Util.PatternString", fileNode?.Attributes?["type"].Value);
}
19
Source : FileTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveToHistoricalFilePaths()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.FilePath = "file3";
mSut.Save(xmlDoc, appender);
mHistoryManager.Received(1).Save(mSut.FilePath);
}
19
Source : IncomingRefsTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldRemoveExistingRefs_WhenNotEnabled()
{
XmlElement loggerElement = mXmlDoc.CreateElement("logger");
mXmlDoc.CreateElementWithAttribute("appender-ref", "ref", mNameProperty.Value).AppendTo(loggerElement);
mXmlDoc.CreateElementWithAttribute("appender-ref", "ref", mNameProperty.Value).AppendTo(loggerElement);
mSut.RefsCollection = new ObservableCollection<IAcceptAppenderRef>
{
new LoggerModel(loggerElement, false, LoggerDescriptor.Logger)
};
mSut.Save(mXmlDoc, mXmlDoc.CreateElement("appender"));
XmlNodeList appenderRefs = loggerElement.SelectNodes($"appender-ref[@ref='{mNameProperty.Value}']");
replacedert.IsNotNull(appenderRefs);
replacedert.AreEqual(0, appenderRefs.Count);
}
19
Source : IncomingRefsTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldRemoveExistingRefs_WhenNotEnabled_AndNameHasChanged()
{
XmlElement loggerElement = mXmlDoc.CreateElement("logger");
mXmlDoc.CreateElementWithAttribute("appender-ref", "ref", mNameProperty.Value).AppendTo(loggerElement);
mXmlDoc.CreateElementWithAttribute("appender-ref", "ref", mNameProperty.Value).AppendTo(loggerElement);
mSut.RefsCollection = new ObservableCollection<IAcceptAppenderRef>
{
new LoggerModel(loggerElement, false, LoggerDescriptor.Logger)
};
//Original name is "appender0"
mNameProperty.Value = "someOtherName";
mSut.Save(mXmlDoc, mXmlDoc.CreateElement("appender"));
XmlNodeList appenderRefs = loggerElement.SelectNodes($"appender-ref[@ref='{mNameProperty.Value}' or @ref='{mNameProperty.OriginalName}']");
replacedert.IsNotNull(appenderRefs);
replacedert.AreEqual(0, appenderRefs.Count);
}
19
Source : IncomingRefsTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldRemoveOldIncomingRefs_WhenNameHasChanged_AndRefIsEnabled()
{
//Original name is "appender0"
mNameProperty.Value = "someOtherName";
//Let's try to add a ref to the asyncAppender (which already exists with the original name)
IAcceptAppenderRef loggerModel = mSut.RefsCollection.First(r => ((NamedModel)r).Name == "asyncAppender");
loggerModel.IsEnabled = true;
mSut.Save(mXmlDoc, mXmlDoc.CreateElement("appender"));
//Selects all "appender-ref" nodes with the "ref" attribute
XmlNodeList appenderRefs = loggerModel.Node.SelectNodes("appender-ref[@ref]");
replacedert.IsNotNull(appenderRefs);
replacedert.AreEqual(1, appenderRefs.Count);
replacedert.AreEqual("someOtherName", appenderRefs[0].Attributes["ref"].Value);
}
19
Source : IncomingRefsTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveRef_WhenNoneExist()
{
XmlElement loggerElement = mXmlDoc.CreateElement("logger");
mSut.RefsCollection = new ObservableCollection<IAcceptAppenderRef>
{
new LoggerModel(loggerElement, true, LoggerDescriptor.Logger)
};
mSut.Save(mXmlDoc, mXmlDoc.CreateElement("appender"));
XmlNodeList appenderRefs = loggerElement.SelectNodes($"appender-ref[@ref='{mNameProperty.Value}']");
replacedert.IsNotNull(appenderRefs);
replacedert.AreEqual(1, appenderRefs.Count);
}
19
Source : RollingStyleTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldNotSave_WhenComposite()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Save(xmlDoc, appender);
Collectionreplacedert.IsEmpty(appender.ChildNodes);
}
19
Source : RollingStyleTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSave_WhenNotComposite()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.SelectedMode = RollingFileAppender.RollingMode.Date;
mSut.Save(xmlDoc, appender);
XmlNode rollingStyleNode = appender.SelectSingleNode("rollingStyle");
replacedert.IsNotNull(rollingStyleNode);
replacedert.AreEqual("Date", rollingStyleNode.Attributes["value"].Value);
}
19
Source : StringMatchTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[TestCase(null)]
[TestCase("")]
public void Save_ShouldNotSaveStringMatch(string value)
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement filterElement = xmlDoc.CreateElement("filter");
mSut.Value = value;
mSut.Save(xmlDoc, filterElement);
Collectionreplacedert.IsEmpty(filterElement.ChildNodes);
}
19
Source : StringMatchTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSave()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement filterElement = xmlDoc.CreateElement("filter");
mSut.Value = "match";
mSut.Save(xmlDoc, filterElement);
XmlNode stringNode = filterElement.SelectSingleNode("stringToMatch");
replacedert.IsNotNull(stringNode);
replacedert.AreEqual(mSut.Value, stringNode.Attributes["value"].Value);
}
19
Source : TargetTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldNotSaveIfConsoleOut()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Save(xmlDoc, appender);
Collectionreplacedert.IsEmpty(appender.ChildNodes);
}
19
Source : TargetTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveIfConsoleError()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.SelectedItem = ConsoleError;
mSut.Save(xmlDoc, appender);
XmlNode targetNode = appender.SelectSingleNode("target");
replacedert.IsNotNull(targetNode);
replacedert.AreEqual(ConsoleError, targetNode.Attributes?["value"].Value);
}
19
Source : ThresholdTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldNotSave_WhenUnseleted()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Save(xmlDoc, appender);
Collectionreplacedert.IsEmpty(appender.ChildNodes);
}
19
Source : ThresholdTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveSelectedLevel()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.SelectedValue = Level.All.Name;
mSut.Save(xmlDoc, appender);
XmlNode thresholdNode = appender.SelectSingleNode("threshold");
replacedert.IsNotNull(thresholdNode);
replacedert.AreEqual(Level.All.Name, thresholdNode.Attributes?["value"].Value);
}
19
Source : TypeAttributeTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[TestCase(null)]
[TestCase("")]
public void Save_ShouldNotSaveValueToAttribute_WhenValueIsNullOrEmpty(string value)
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Value = value;
mSut.Save(xmlDoc, appender);
replacedert.IsNull(appender.Attributes["type"]);
}
19
Source : TypeAttributeTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveValueToAttribute()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
const string value = "type";
mSut.Value = value;
mSut.Save(xmlDoc, appender);
replacedert.AreEqual(value, appender.Attributes["type"].Value);
}
19
Source : ValueTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[TestCase(null)]
[TestCase("")]
public void Save_ShouldNotSaveValueToAttribute_WhenValueIsNullOrEmpty(string value)
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Value = value;
mSut.Save(xmlDoc, appender);
replacedert.IsNull(appender.Attributes["value"]);
}
19
Source : ValueTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Save_ShouldSaveValueToAttribute()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
XmlElement appender = xmlDoc.CreateElement("appender");
const string value = "whatev";
mSut.Value = value;
mSut.Save(xmlDoc, appender);
replacedert.AreEqual(value, appender.Attributes["value"].Value);
}
19
Source : AddSaveStrategyTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenModelIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new AddSaveStrategy<ModelBase>(null, model => { }, new XmlDoreplacedent().CreateElement("element")));
}
19
Source : AddSaveStrategyTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenAddCallbackIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new AddSaveStrategy<ModelBase>(new RendererModel(null), null, new XmlDoreplacedent().CreateElement("element")));
}
See More Examples