System.Xml.XmlNode.AppendChild(System.Xml.XmlNode)

Here are the examples of the csharp api System.Xml.XmlNode.AppendChild(System.Xml.XmlNode) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

954 Examples 7

19 View Source File : CompositeType.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Category.cs
License : MIT License
Project Creator : alexleen

public override void Save(XmlDoreplacedent xmlDoc, XmlNode newNode)
        {
            if (string.IsNullOrWhiteSpace(Value) || Value == DefaultValue)
            {
                return;
            }

            XmlNode categoryNode = xmlDoc.CreateElementWithAttribute(ElementName, Log4NetXmlConstants.Type, LayoutDescriptor.Pattern.TypeNamespace);
            xmlDoc.CreateElementWithValueAttribute(Log4NetXmlConstants.ConversionPattern, Value).AppendTo(categoryNode);
            newNode.AppendChild(categoryNode);
        }

19 View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private void OpenStructuringElement(XmlElement htmlElement)
        {
            // Close all pending inline elements
            // All block elements are considered as delimiters for inline elements
            // which forces all inline elements to be closed and re-opened in the following
            // structural element (if any).
            // By doing that we guarantee that all inline elements appear only within most nested blocks
            if (HtmlSchema.IsBlockElement(htmlElement.LocalName))
            {
                while (_openedElements.Count > 0 && HtmlSchema.IsInlineElement(_openedElements.Peek().LocalName))
                {
                    XmlElement htmlInlineElement = _openedElements.Pop();
                    Invariantreplacedert(_openedElements.Count > 0, "OpenStructuringElement: stack of opened elements cannot become empty here");

                    _pendingInlineElements.Push(CreateElementCopy(htmlInlineElement));
                }
            }

            // Add this block element to its parent
            if (_openedElements.Count > 0)
            {
                XmlElement htmlParent = _openedElements.Peek();

                // Check some known block elements for auto-closing (LI and P)
                if (HtmlSchema.ClosesOnNextElementStart(htmlParent.LocalName, htmlElement.LocalName))
                {
                    _openedElements.Pop();
                    htmlParent = _openedElements.Count > 0 ? _openedElements.Peek() : null;
                }

                if (htmlParent != null)
                {
                    // NOTE:
                    // Actually we never expect null - it would mean two top-level P or LI (without a parent).
                    // In such weird case we will loose all paragraphs except the first one...
                    htmlParent.AppendChild(htmlElement);
                }
            }

            // Push it onto a stack
            _openedElements.Push(htmlElement);
        }

19 View Source File : Model.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private void OpenPendingInlineElements()
        {
            if (_pendingInlineElements.Count > 0)
            {
                XmlElement htmlInlineElement = _pendingInlineElements.Pop();

                OpenPendingInlineElements();

                Invariantreplacedert(_openedElements.Count > 0, "OpenPendingInlineElements: Stack of opened elements cannot be empty, as we have at least one artificial root element");

                XmlElement htmlParent = _openedElements.Peek();
                htmlParent.AppendChild(htmlInlineElement);
                _openedElements.Push(htmlInlineElement);
            }
        }

19 View Source File : Serialization.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : AppendReplaceSaveStrategyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void Execute_ShouldReplace_WhenOriginalNodeIsNotNull()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetElement = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);
            XmlElement origElement = xmlDoc.CreateElement("origAppender");
            log4NetElement.AppendChild(origElement);
            XmlElement newElement = xmlDoc.CreateElement("newAppender");

            IElementConfiguration config = Subsreplacedute.For<IElementConfiguration>();
            config.Log4NetNode.Returns(log4NetElement);
            config.OriginalNode.Returns(origElement);
            config.NewNode.Returns(newElement);

            ISaveStrategy strategy = new AppendReplaceSaveStrategy(config, false);
            strategy.Execute();

            replacedert.AreEqual(1, log4NetElement.ChildNodes.Count);
            replacedert.AreEqual(newElement, log4NetElement.FirstChild);
        }

19 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteServices(XmlNode doreplacedentNode, IEnumerable<ServiceDefinition> serviceDefinitions)
        {
            XmlDoreplacedent doreplacedent = doreplacedentNode.OwnerDoreplacedent;

            XmlNode servicesNode = doreplacedent.CreateNode(XmlNodeType.Element, s_services, null);
            doreplacedentNode.AppendChild(servicesNode);

            foreach (ServiceDefinition definition in serviceDefinitions)
            {
                XmlNode serviceDefinitionNode = doreplacedent.CreateNode(XmlNodeType.Element, s_serviceDefinition, null);
                servicesNode.AppendChild(serviceDefinitionNode);

                XmlNode serviceTypeNode = doreplacedent.CreateNode(XmlNodeType.Element, s_serviceType, null);
                serviceDefinitionNode.AppendChild(serviceTypeNode);
                serviceTypeNode.InnerText = definition.ServiceType;

                XmlNode identifierNode = doreplacedent.CreateNode(XmlNodeType.Element, s_identifier, null);
                serviceDefinitionNode.AppendChild(identifierNode);
                identifierNode.InnerText = XmlConvert.ToString(definition.Identifier);

                if (definition.DisplayName != null)
                {
                    XmlNode displayNameNode = doreplacedent.CreateNode(XmlNodeType.Element, s_displayName, null);
                    serviceDefinitionNode.AppendChild(displayNameNode);
                    displayNameNode.InnerText = definition.DisplayName;
                }

                if (definition.Description != null)
                {
                    XmlNode descriptionNode = doreplacedent.CreateNode(XmlNodeType.Element, s_description, null);
                    serviceDefinitionNode.AppendChild(descriptionNode);
                    descriptionNode.InnerText = definition.Description;
                }

                XmlNode relativePathNode = doreplacedent.CreateNode(XmlNodeType.Element, s_relativePath, null);
                serviceDefinitionNode.AppendChild(relativePathNode);
                relativePathNode.InnerText = definition.RelativePath;

                XmlUtility.AddXmlAttribute(relativePathNode, s_relativeTo, definition.RelativeToSetting.ToString());

                XmlNode parentServiceTypeNode = doreplacedent.CreateNode(XmlNodeType.Element, s_parentServiceType, null);
                serviceDefinitionNode.AppendChild(parentServiceTypeNode);
                parentServiceTypeNode.InnerText = definition.ParentServiceType;

                XmlNode parentIdentifierNode = doreplacedent.CreateNode(XmlNodeType.Element, s_parentIdentifier, null);
                serviceDefinitionNode.AppendChild(parentIdentifierNode);
                parentIdentifierNode.InnerText = XmlConvert.ToString(definition.ParentIdentifier);

                if (definition.RelativeToSetting == RelativeToSetting.FullyQualified)
                {
                    XmlNode locationMappingsNode = doreplacedent.CreateNode(XmlNodeType.Element, s_locationMappings, null);
                    serviceDefinitionNode.AppendChild(locationMappingsNode);

                    foreach (LocationMapping mapping in definition.LocationMappings)
                    {
                        XmlNode locationMappingNode = doreplacedent.CreateNode(XmlNodeType.Element, s_locationMapping, null);
                        locationMappingsNode.AppendChild(locationMappingNode);

                        XmlNode accessMappingNode = doreplacedent.CreateNode(XmlNodeType.Element, s_accessMapping, null);
                        locationMappingNode.AppendChild(accessMappingNode);
                        accessMappingNode.InnerText = mapping.AccessMappingMoniker;

                        XmlNode locationNode = doreplacedent.CreateNode(XmlNodeType.Element, s_location, null);
                        locationMappingNode.AppendChild(locationNode);
                        locationNode.InnerText = mapping.Location;
                    }
                }

                if (definition.ResourceVersion > 0)
                {
                    XmlNode resourceVersionNode = doreplacedent.CreateNode(XmlNodeType.Element, s_resourceVersion, null);
                    serviceDefinitionNode.AppendChild(resourceVersionNode);
                    resourceVersionNode.InnerText = XmlConvert.ToString(definition.ResourceVersion);
                }

                if (definition.MinVersionString != null)
                {
                    XmlNode minVersionNode = doreplacedent.CreateNode(XmlNodeType.Element, s_minVersion, null);
                    serviceDefinitionNode.AppendChild(minVersionNode);
                    minVersionNode.InnerText = definition.MinVersionString;
                }

                if (definition.MaxVersionString != null)
                {
                    XmlNode maxVersionNode = doreplacedent.CreateNode(XmlNodeType.Element, s_maxVersion, null);
                    serviceDefinitionNode.AppendChild(maxVersionNode);
                    maxVersionNode.InnerText = definition.MaxVersionString;
                }

                if (definition.ReleasedVersionString != null)
                {
                    XmlNode releasedVersionNode = doreplacedent.CreateNode(XmlNodeType.Element, s_releasedVersion, null);
                    serviceDefinitionNode.AppendChild(releasedVersionNode);
                    releasedVersionNode.InnerText = definition.ReleasedVersionString;
                }
            }
        }

19 View Source File : Mapping.cs
License : MIT License
Project Creator : alexleen

public override void Save(XmlDoreplacedent xmlDoc, XmlNode newNode)
        {
            foreach (MappingModel mappingModel in Mappings)
            {
                newNode.AppendChild(mappingModel.Node);
            }
        }

19 View Source File : ObjectCacheExtensions.cs
License : MIT License
Project Creator : 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 View Source File : Model.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : DelegateType.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : RSA.cs
License : GNU General Public License v3.0
Project Creator : aiportal

private static XmlDoreplacedent RsaSign(XmlDoreplacedent doc, string privateKey)
		{
			RSACryptoServiceProvider key = new RSACryptoServiceProvider();
			key.FromXmlString(privateKey);

			SignedXml signedXml = new SignedXml(doc);
			signedXml.SigningKey = key;
			Reference reference = new Reference();
			reference.Uri = "";
			reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
			signedXml.AddReference(reference);
			signedXml.ComputeSignature();
			XmlElement signElement = signedXml.GetXml();

			doc.DoreplacedentElement.AppendChild(doc.ImportNode(signElement, true));
			return doc;
		}

19 View Source File : Project.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteVirtualDirectory(XmlNode doreplacedentNode, String virtualDirectory)
        {
            XmlNode virtualDirectoryNode = doreplacedentNode.OwnerDoreplacedent.CreateNode(XmlNodeType.Element, s_virtualDirectory, null);
            doreplacedentNode.AppendChild(virtualDirectoryNode);
            virtualDirectoryNode.InnerText = virtualDirectory;
        }

19 View Source File : BendPoint.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : XmlNodeConverter.cs
License : MIT License
Project Creator : akaskela

public IXmlNode AppendChild(IXmlNode newChild)
        {
            XmlNodeWrapper xmlNodeWrapper = (XmlNodeWrapper)newChild;
            _node.AppendChild(xmlNodeWrapper._node);
            _childNodes = null;
            _attributes = null;

            return newChild;
        }

19 View Source File : EnumPropertyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void Load_ShouldLoadValue()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();

            XmlAttribute valueAttribute = xmlDoc.CreateAttribute("value");
            valueAttribute.Value = MailPriority.High.ToString();

            XmlElement encodingElement = xmlDoc.CreateElement("elementName");
            encodingElement.Attributes.Append(valueAttribute);

            XmlElement appenderElement = xmlDoc.CreateElement("appender");
            appenderElement.AppendChild(encodingElement);

            mSut.Load(appenderElement);

            replacedert.AreEqual(MailPriority.High.ToString(), mSut.SelectedValue);
        }

19 View Source File : LocationServerMapCache.cs
License : MIT License
Project Creator : actions

private static void AddMappingNode(XmlNode parentNode, String location, Guid guid, Guid owner)
        {
            XmlNode mappingNode = parentNode.OwnerDoreplacedent.CreateNode(XmlNodeType.Element, s_mappingXmlText, null);
            parentNode.AppendChild(mappingNode);

            // Write the mapping as attributes
            XmlUtility.AddXmlAttribute(mappingNode, s_locationAttribute, location);
            XmlUtility.AddXmlAttribute(mappingNode, s_guidAttribute, XmlConvert.ToString(guid));

            // For compatibility with older OMs with the same major version, persist the on-prem service owner as empty.
            if (ServiceInstanceTypes.TFSOnPremises == owner)
            {
                owner = Guid.Empty;
            }

            // Legacy server case: If the server did not send back ServiceOwner in the connectionData
            // let's just do what we used to do to not break anything.
            // Eventually we can remove this if-guard
            if (owner != Guid.Empty)
            {
                XmlUtility.AddXmlAttribute(mappingNode, s_ownerAttribute, XmlConvert.ToString(owner));
            }
        }

19 View Source File : Layout.cs
License : MIT License
Project Creator : alexleen

public override void Save(XmlDoreplacedent xmlDoc, XmlNode newNode)
        {
            if (SelectedLayout == LayoutDescriptor.None)
            {
                return;
            }

            XmlNode layoutNode = xmlDoc.CreateElementWithAttribute(LayoutName, "type", SelectedLayout.TypeNamespace);

            if (SelectedLayout != LayoutDescriptor.Simple)
            {
                xmlDoc.CreateElementWithValueAttribute(Log4NetXmlConstants.ConversionPattern, Pattern).AppendTo(layoutNode);
            }

            newNode.AppendChild(layoutNode);

            if (Pattern != mOriginalPattern)
            {
                mHistoryManager.Save(Pattern);
            }
        }

19 View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private void AddComment(string comment)
        {
            OpenPendingInlineElements();

            Invariantreplacedert(_openedElements.Count > 0, "AddComment: Stack of opened elements cannot be empty, as we have at least one artificial root element");

            XmlElement htmlParent = _openedElements.Peek();
            XmlComment xmlComment = _doreplacedent.CreateComment(comment);
            htmlParent.AppendChild(xmlComment);
        }

19 View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private void AddTextContent(string textContent)
        {
            OpenPendingInlineElements();

            Invariantreplacedert(_openedElements.Count > 0, "AddTextContent: Stack of opened elements cannot be empty, as we have at least one artificial root element");

            XmlElement htmlParent = _openedElements.Peek();
            XmlText textNode = _doreplacedent.CreateTextNode(textContent);
            htmlParent.AppendChild(textNode);
        }

19 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteLastChangeId(XmlNode doreplacedentNode, Int32 lastChangeId)
        {
            XmlNode lastChangeIdNode = doreplacedentNode.OwnerDoreplacedent.CreateNode(XmlNodeType.Element, s_lastChangeId, null);
            doreplacedentNode.AppendChild(lastChangeIdNode);
            lastChangeIdNode.InnerText = XmlConvert.ToString(lastChangeId);
        }

19 View Source File : ClassType.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : EpubBuilder.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Relationship.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : EnumType.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : XmlHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static XmlNode Write(XmlDoreplacedent doc , XmlNode par , string name , object value = null)
        {
            var sc = doc.CreateNode(XmlNodeType.Element , name , "") ;
            par.AppendChild(sc) ;
            if(value != null)
            {
                sc.InnerText = value.ToString() ;
            }
            return sc ;
        }

19 View Source File : Project.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteDefaultAccessMappingMoniker(XmlNode doreplacedentNode, String defaultAccessMappingMoniker)
        {
            XmlNode defaultAccessMappingMonikerNode = doreplacedentNode.OwnerDoreplacedent.CreateNode(XmlNodeType.Element, s_defaultAccessMappingMoniker, null);
            doreplacedentNode.AppendChild(defaultAccessMappingMonikerNode);
            defaultAccessMappingMonikerNode.InnerText = defaultAccessMappingMoniker;
        }

19 View Source File : Model.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ConfigurationBase.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Comment.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : LocationServerMapCache.cs
License : MIT License
Project Creator : actions

private static Boolean TryWriteMappingToDisk(String location, Guid serverGuid, Guid serviceOwner, Boolean isNew)
        {
            if (s_cacheUnavailable)
            {
                return false;
            }

            FileStream file = null;

            try
            {
                // Open the file with an exclusive lock                
                XmlDoreplacedent existingDoreplacedent = XmlUtility.OpenXmlFile(out file, FilePath, FileShare.None, true);

                // Only allow one writer at a time
                lock (s_cacheMutex)
                {
                    XmlNode doreplacedentNode = null;
                    if (existingDoreplacedent == null)
                    {
                        // This is a new doreplacedent, create the xml
                        existingDoreplacedent = new XmlDoreplacedent();

                        // This is the first entry, create the doreplacedent node and add the child
                        doreplacedentNode = existingDoreplacedent.CreateNode(XmlNodeType.Element, s_doreplacedentXmlText, null);
                        existingDoreplacedent.AppendChild(doreplacedentNode);

                        AddMappingNode(doreplacedentNode, location, serverGuid, serviceOwner);
                    }
                    else
                    {
                        // Get the root doreplacedent node
                        doreplacedentNode = existingDoreplacedent.ChildNodes[0];

                        // If this is a new mapping, just add it to the doreplacedent node
                        if (isNew)
                        {
                            AddMappingNode(doreplacedentNode, location, serverGuid, serviceOwner);
                        }
                        else
                        {
                            // This is some form of update.  Find the node with the location and update
                            // the guid.  
                            foreach (XmlNode mappingNode in doreplacedentNode.ChildNodes)
                            {
                                if (StringComparer.OrdinalIgnoreCase.Equals(mappingNode.Attributes[s_locationAttribute].InnerText, location))
                                {
                                    // This is the one we have to update, do so now
                                    mappingNode.Attributes[s_guidAttribute].InnerText = XmlConvert.ToString(serverGuid);

                                    // For compatibility with older OMs with the same major version, persist the on-prem service owner as empty.
                                    if (ServiceInstanceTypes.TFSOnPremises == serviceOwner)
                                    {
                                        serviceOwner = Guid.Empty;
                                    }

                                    // Legacy server case: Let's be resilient to the persisted doreplacedent not already having an owner attribute
                                    XmlAttribute ownerAttribute = existingDoreplacedent.CreateAttribute(s_ownerAttribute);
                                    ownerAttribute.InnerText = XmlConvert.ToString(serviceOwner);
                                    mappingNode.Attributes.Append(ownerAttribute);
                                }
                            }
                        }
                    }

                    // Reset the file stream.
                    file.SetLength(0);
                    file.Position = 0;

                    // Save the file.
                    existingDoreplacedent.Save(file);

                    return true;
                }
            }
            catch (Exception)
            {
                // It looks like we are being denied access to the cache, lets just hide this
                // exception and work without it.
                s_cacheUnavailable = true;
                return false;
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }
        }

19 View Source File : TypeBase.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ConfigurationBase.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : PersistentSettings.cs
License : MIT License
Project Creator : 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 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteAccessMappings(XmlNode doreplacedentNode, IEnumerable<AccessMapping> accessMappings)
        {
            XmlDoreplacedent doreplacedent = doreplacedentNode.OwnerDoreplacedent;

            XmlNode accessMappingsNode = doreplacedent.CreateNode(XmlNodeType.Element, s_accessMappings, null);
            doreplacedentNode.AppendChild(accessMappingsNode);

            foreach (AccessMapping accessMapping in accessMappings)
            {
                XmlNode accessMappingNode = doreplacedent.CreateNode(XmlNodeType.Element, s_accessMapping, null);
                accessMappingsNode.AppendChild(accessMappingNode);

                XmlNode monikerNode = doreplacedent.CreateNode(XmlNodeType.Element, s_moniker, null);
                accessMappingNode.AppendChild(monikerNode);
                monikerNode.InnerText = accessMapping.Moniker;

                XmlNode accessPointNode = doreplacedent.CreateNode(XmlNodeType.Element, s_accessPoint, null);
                accessMappingNode.AppendChild(accessPointNode);
                accessPointNode.InnerText = accessMapping.AccessPoint;

                XmlNode displayNameNode = doreplacedent.CreateNode(XmlNodeType.Element, s_displayName, null);
                accessMappingNode.AppendChild(displayNameNode);
                displayNameNode.InnerText = accessMapping.DisplayName;

                if (accessMapping.VirtualDirectory != null)
                {
                    XmlNode virtualDirectoryNode = doreplacedent.CreateNode(XmlNodeType.Element, s_virtualDirectory, null);
                    accessMappingNode.AppendChild(virtualDirectoryNode);
                    virtualDirectoryNode.InnerText = accessMapping.VirtualDirectory;
                }
            }
        }

19 View Source File : EncodingTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("", "")]
        [TestCase("us-ascii", "us-ascii")]
        [TestCase("utf-16", "utf-16")]
        [TestCase("utf-16BE", "utf-16BE")]
        [TestCase("utf-7", "utf-7")]
        [TestCase("utf-8", "utf-8")]
        [TestCase("utf-32", "utf-32")]
        [TestCase("unknown", "")]
        public void Load_ShouldLoadCorrectValue(string value, string expected)
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();

            XmlAttribute valueAttribute = xmlDoc.CreateAttribute("value");
            valueAttribute.Value = value;

            XmlElement encodingElement = xmlDoc.CreateElement("encoding");
            encodingElement.Attributes.Append(valueAttribute);

            XmlElement appenderElement = xmlDoc.CreateElement("appender");
            appenderElement.AppendChild(encodingElement);

            mSut.Load(appenderElement);

            replacedert.AreEqual(expected, mSut.SelectedValue);
        }

19 View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private void AddEmptyElement(XmlElement htmlEmptyElement)
        {
            Invariantreplacedert(_openedElements.Count > 0, "AddEmptyElement: Stack of opened elements cannot be empty, as we have at least one artificial root element");
            XmlElement htmlParent = _openedElements.Peek();
            htmlParent.AppendChild(htmlEmptyElement);
        }

19 View Source File : EnumPropertyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void Load_ShouldNotLoadValuesItCannotParse()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();

            XmlAttribute valueAttribute = xmlDoc.CreateAttribute("value");
            valueAttribute.Value = "whatev"; // Not a valid MailPriority enum value

            XmlElement encodingElement = xmlDoc.CreateElement("elementName");
            encodingElement.Attributes.Append(valueAttribute);

            XmlElement appenderElement = xmlDoc.CreateElement("appender");
            appenderElement.AppendChild(encodingElement);

            mSut.Load(appenderElement);

            replacedert.AreEqual(mSut.Values.First(), mSut.SelectedValue);
        }

19 View Source File : GameSaveLoadInMem.cs
License : Apache License 2.0
Project Creator : 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 View Source File : Filters.cs
License : MIT License
Project Creator : alexleen

public override void Save(XmlDoreplacedent xmlDoc, XmlNode newNode)
        {
            foreach (FilterModel filter in ExistingFilters)
            {
                newNode.AppendChild(filter.Node);
            }
        }

19 View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private void CloseElement(string htmlElementName)
        {
            // Check if the element is opened and already added to the parent
            Invariantreplacedert(_openedElements.Count > 0, "CloseElement: Stack of opened elements cannot be empty, as we have at least one artificial root element");

            // Check if the element is opened and still waiting to be added to the parent
            if (_pendingInlineElements.Count > 0 && _pendingInlineElements.Peek().LocalName == htmlElementName)
            {
                // Closing an empty inline element.
                // Note that HtmlConverter will skip empty inlines, but for completeness we keep them here on parser level.
                XmlElement htmlInlineElement = _pendingInlineElements.Pop();
                Invariantreplacedert(_openedElements.Count > 0, "CloseElement: Stack of opened elements cannot be empty, as we have at least one artificial root element");
                XmlElement htmlParent = _openedElements.Peek();
                htmlParent.AppendChild(htmlInlineElement);
                return;
            }
            else if (IsElementOpened(htmlElementName))
            {
                while (_openedElements.Count > 1) // we never pop the last element - the artificial root
                {
                    // Close all unbalanced elements.
                    XmlElement htmlOpenedElement = _openedElements.Pop();

                    if (htmlOpenedElement.LocalName == htmlElementName)
                    {
                        return;
                    }

                    if (HtmlSchema.IsInlineElement(htmlOpenedElement.LocalName))
                    {
                        // Unbalances Inlines will be transfered to the next element content
                        _pendingInlineElements.Push(CreateElementCopy(htmlOpenedElement));
                    }
                }
            }

            // If element was not opened, we simply ignore the unbalanced closing tag
            return;
        }

19 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteCachedMisses(XmlNode doreplacedentNode, IEnumerable<String> cachedMisses)
        {
            XmlDoreplacedent doreplacedent = doreplacedentNode.OwnerDoreplacedent;

            XmlNode cacheMissesNode = doreplacedent.CreateNode(XmlNodeType.Element, s_cachedMisses, null);
            doreplacedentNode.AppendChild(cacheMissesNode);

            foreach (String cacheMiss in cachedMisses)
            {
                XmlNode cacheMissNode = doreplacedent.CreateNode(XmlNodeType.Element, s_cachedMiss, null);
                cacheMissNode.InnerText = cacheMiss;
                cacheMissesNode.AppendChild(cacheMissNode);
            }
        }

19 View Source File : DotNetToJScript.cs
License : MIT License
Project Creator : 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 View Source File : LocationCacheManager.cs
License : MIT License
Project Creator : actions

private void WriteCacheToDisk()
        {
            Debug.replacedert(m_accessLock.IsWriteLockHeld);

            if (!m_cacheAvailable)
            {
                return;
            }

            try
            {
                Debug.replacedert(m_lastChangeId == -1 || m_services.Count > 0);
                // Get an exclusive lock on the file
                using (FileStream file = XmlUtility.OpenFile(m_cacheFilePath, FileShare.None, true))
                {
                    XmlDoreplacedent doreplacedent = new XmlDoreplacedent();

                    XmlNode doreplacedentNode = doreplacedent.CreateNode(XmlNodeType.Element, s_docStartElement, null);
                    doreplacedent.AppendChild(doreplacedentNode);

                    m_locationXmlOperator.WriteLastChangeId(doreplacedentNode, m_lastChangeId);
                    m_locationXmlOperator.WriteCacheExpirationDate(doreplacedentNode, m_cacheExpirationDate);
                    m_locationXmlOperator.WriteDefaultAccessMappingMoniker(doreplacedentNode, m_defaultAccessMapping.Moniker);
                    m_locationXmlOperator.WriteVirtualDirectory(doreplacedentNode, m_webApplicationRelativeDirectory);
                    m_locationXmlOperator.WriteAccessMappings(doreplacedentNode, m_accessMappings.Values);

                    // Build up a list of the service definitions for writing
                    List<ServiceDefinition> serviceDefinitions = new List<ServiceDefinition>();
                    foreach (Dictionary<Guid, ServiceDefinition> serviceTypeSet in m_services.Values)
                    {
                        serviceDefinitions.AddRange(serviceTypeSet.Values);
                    }

                    m_locationXmlOperator.WriteServices(doreplacedentNode, serviceDefinitions);
                    m_locationXmlOperator.WriteCachedMisses(doreplacedentNode, m_cachedMisses);

                    // Reset the file stream.
                    file.SetLength(0);
                    file.Position = 0;

                    // Save the file.
                    doreplacedent.Save(file);
                }
            }
            catch (Exception)
            {
                // It looks as though we don't have access to the cache file.  Eat
                // this exception and mark the cache as unavailable so we don't
                // repeatedly try to access it
                m_cacheAvailable = false;
            }
        }

19 View Source File : LocationXmlOperator.cs
License : MIT License
Project Creator : actions

public void WriteCacheExpirationDate(XmlNode doreplacedentNode, DateTime cacheExpirationDate)
        {
            XmlNode cacheExpirationDateNode = doreplacedentNode.OwnerDoreplacedent.CreateNode(XmlNodeType.Element, s_cacheExpirationDate, null);
            doreplacedentNode.AppendChild(cacheExpirationDateNode);
            cacheExpirationDateNode.InnerText = XmlConvert.ToString(cacheExpirationDate, XmlDateTimeSerializationMode.Utc);
        }

19 View Source File : EpubBuilder.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : AssociationRelationship.cs
License : GNU General Public License v3.0
Project Creator : 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);
			}
		}

See More Examples