コード例 #1
0
 public void AddNewSubElement(DateTime date, decimal totalSum)
 {
     XAttribute dateAttribute = new XAttribute("date", date.ToString("dd-MMM-yyyy", Culture));
     XAttribute sumAttribute = new XAttribute("total-sum", totalSum);
     XElement newElement = new XElement("summary",dateAttribute,sumAttribute);
     this.SubRootElement.Add(newElement);
 }
コード例 #2
0
    private string SerializeXmlNode(XmlNode node)
    {
      string json = JsonConvert.SerializeXmlNode(node, Formatting.Indented);
      XmlNodeReader reader = new XmlNodeReader(node);

#if !NET20
      XObject xNode;
      if (node is XmlDocument)
      {
        xNode = XDocument.Load(reader);
      }
      else if (node is XmlAttribute)
      {
        XmlAttribute attribute = (XmlAttribute) node;
        xNode = new XAttribute(XName.Get(attribute.LocalName, attribute.NamespaceURI), attribute.Value);
      }
      else
      {
        reader.MoveToContent();
        xNode = XNode.ReadFrom(reader);
      }

      string linqJson = JsonConvert.SerializeXNode(xNode, Formatting.Indented);

      Assert.AreEqual(json, linqJson);
#endif

      return json;
    }
コード例 #3
0
        public BodyType ToEntity(XAttribute xAttribute)
        {
            if (xAttribute == null)
            {
                throw new ArgumentNullException("xAttribute");
            }

            BodyType entity;

            switch (xAttribute.Value)
            {
                case STR_Dynamic:
                    entity = BodyType.Dynamic;
                    break;
                case STR_Kinematic:
                    entity = BodyType.Kinematic;
                    break;
                case STR_Static:
                    entity = BodyType.Static;
                    break;
                default:
                    throw new NotSupportedException(String.Format("BodyType '{0}' is not supported.", xAttribute.Value));
            }
            return entity;
        }
コード例 #4
0
 public static XElement AddAttribute(this XElement element, XAttribute attribute)
 {
     if (attribute != null)
         element.Add(attribute);
     
     return element;
 }
コード例 #5
0
        protected override XElement ExportNewTOC()
        {
            List<XElement> list = new List<XElement>();

            foreach (Node item in Model.Nodes)
            {
                XElement navPoint = ConvertToXElement(item);
                if (navPoint != null)
                {
                    list.Add(navPoint);
                }
            }
            IEnumerable<XAttribute> spine = TOC.Attributes();
            XElement navMap = null;

            if (spine.Count()>0)
            {
                navMap = new XElement(ns + "spine", spine, list);
            } else
            {
                //There is no spine elements
                OpfDocument doc = new OpfDocument();
                XAttribute TocRef = new XAttribute("toc", doc.GetNCXid());

                navMap = new XElement(ns + "spine", TocRef, list);
            }

            OnSave(new ExportTocEventArgs(navMap));

            //_NewTOC = navMap;
            return navMap;
        }
コード例 #6
0
		bool RewriteElement(XamlContext ctx, XElement parent, XElement elem) {
			var type = parent.Annotation<XamlType>();
			var property = elem.Annotation<XamlProperty>();
			if ((property == null || type == null) && elem.Name != key)
				return false;

			if (elem.Elements().Count() != 1 || elem.Attributes().Any(t => t.Name.Namespace != XNamespace.Xmlns))
				return false;

			var value = elem.Elements().Single();

			if (!CanInlineExt(ctx, value))
				return false;

			var ext = InlineExtension(ctx, value);
			if (ext == null)
				return false;

			ctx.CancellationToken.ThrowIfCancellationRequested();

			var extValue = ext.ToString(ctx, parent);

			var attrName = elem.Name;
			if (attrName != key)
				attrName = property.ToXName(ctx, parent, property.IsAttachedTo(type));
			var attr = new XAttribute(attrName, extValue);
			parent.Add(attr);
			elem.Remove();

			return true;
		}
コード例 #7
0
ファイル: DAISYUtils.cs プロジェクト: Notalib/DSync
 public static TimeSpan ParseClipAttribute(XAttribute attr)
 {
     if (attr == null) throw new ArgumentNullException("attr");
     var m = Regex.Match(attr.Value, @"^npt=(\d+(\.\d+)?)s$");
     if (!m.Success) throw new ApplicationException("Clip attribute " + attr.Name + " has invalid value " + attr.Value);
     return TimeSpan.FromSeconds(Double.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture));
 }
コード例 #8
0
        private static object GetValue(XElement node, XAttribute source)
        {
            if (source == null)
                return ExpandValue(node.Value);

            switch (source.Value)
            {
                case "file":
                    {
                        var path = Path.Combine(ApplicationInfo.RootDir, "tools-conf", "mistilteinn", node.Value);
                        if (File.Exists(path))
                            return File.ReadAllText(path);
                        return "";
                    }
                case "appdata":
                    {
                        var path = Path.Combine(Application.UserAppDataPath, node.Value);
                        if (File.Exists(path))
                            return File.ReadAllText(path);
                        return "";
                    }
                default:
                    throw new Exception(source.Value + " is not supported source.");
            }
        }
コード例 #9
0
ファイル: DefaultsLoader.cs プロジェクト: apetrovskiy/STUPS
 void SetWorkflowElement(XDocument xDocument)
 {
     var workflowElement = xDocument.Descendants(LogicConstants.DefaultsLoader_Workflow).FirstOrDefault();
     var defaultAttributeValue = new XAttribute(LogicConstants.DefaultsLoader_Workflow_Name, string.Empty);
     if (null != workflowElement)
         Defaults.Workflow = (workflowElement.Attribute(LogicConstants.DefaultsLoader_Workflow_Name) ?? defaultAttributeValue).Value;
 }
コード例 #10
0
ファイル: XmlUtils.cs プロジェクト: Notalib/DSync
 public static long ParseSyncAttribute(XAttribute syncAttr)
 {
     if (syncAttr == null) throw new ArgumentNullException("syncAttr");
     long res;
     if (Int64.TryParse(syncAttr.Value, out res)) return res;
     throw new XmlException(String.Format("Invalid synchronization attribute {0}", syncAttr));
 }
コード例 #11
0
ファイル: XmlExtensions.cs プロジェクト: kkalinowski/lib12
        public static XElement AddAttribute(this XElement element, string name, object value)
        {
            var attribute = new XAttribute(name, value);
            element.Add(attribute);

            return element;
        }
コード例 #12
0
ファイル: XMLBase.cs プロジェクト: Dazmo/Terraria-Map-Editor
 public FrameDirection XMLConvert(FrameDirection v, XAttribute attr)
 {
     if (attr == null) return v;
     FrameDirection f = FrameDirection.None;
     f = f.Convert<FrameDirection>(attr);
     return f;
 }
 private static void LogResult(Type result, XAttribute attr)
 {
     if (result == null)
         _log.Warn("Unable to load type from attribute named '" + attr.Name + "' with value '" + attr.Value + "'.");
     else if (_log.IsDebugEnabled)
         _log.Debug("Loaded type '" + result + "' from attribute named '" + attr.Name + "'.");
 }
コード例 #14
0
ファイル: XmlTree.Attribute.cs プロジェクト: Xtremrules/dot42
 /// <summary>
 /// Creation ctor
 /// </summary>
 internal Attribute(XmlTree tree, XAttribute attr)
 {
     this.tree = tree;
     Namespace = string.IsNullOrEmpty(attr.Name.NamespaceName) ? null : attr.Name.NamespaceName;
     Name = attr.Name.LocalName;
     RawValue = attr.Value;
 }
コード例 #15
0
ファイル: InspectCodeParser.cs プロジェクト: roh85/vika
        private Offset GetOffset(XAttribute offsetAttribute, string sourceFilePath, uint? lineNumber)
        {
            if (offsetAttribute == null || !_fileSystem.File.Exists(sourceFilePath))
            {
                return null;
            }

            string start = null;
            string end = null;

            var dashIndex = offsetAttribute.Value.IndexOf("-", StringComparison.OrdinalIgnoreCase);
            if (dashIndex > -1)
            {
                start = offsetAttribute.Value.Substring(0, dashIndex);
                end = offsetAttribute.Value.Substring(dashIndex + 1);
            }

            var lines = _fileSystem.File.ReadLines(sourceFilePath);
            var issueLineOffset = lines.Take((int)lineNumber.Value - 1).Sum(line => line.Length);

            return new Offset
            {
                Start = string.IsNullOrWhiteSpace(start) ? null : (uint?)(int.Parse(start) - (issueLineOffset + lineNumber.Value - 1)),
                End = string.IsNullOrWhiteSpace(end) ? null : (uint?)(int.Parse(end) - (issueLineOffset + lineNumber.Value - 1))
            };
        }
コード例 #16
0
ファイル: StringExtensions.cs プロジェクト: uwitec/O2O
        /// <summary>
        /// Get XAttribute Value
        /// </summary>
        /// <param name="XAttribute">xAttribute</param>
        /// <returns>Value</returns>
        public static string GetXAttributeValue(XAttribute xAttribute)
        {
            if (xAttribute == null)
              return string.Empty;

              return xAttribute.Value;
        }
コード例 #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Change any bogus non-owning footnote links in the vernacular (but NOT in the BT)
		/// to be owning links
		/// </summary>
		/// <param name="domainObjectDtoRepository">
		/// Repository of all CmObject DTOs available for one migration step.
		/// </param>
		/// ------------------------------------------------------------------------------------
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000034);

			foreach (var scrTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("ScrTxtPara"))
			{
				XElement para = XElement.Parse(scrTxtPara.Xml);
				XElement contents = para.Element("Contents");
				if (contents == null)
					continue;
				XElement str = contents.Element("Str");
				if (str == null)
					continue;

				foreach (XElement run in str.Elements("Run"))
				{
					XAttribute linkAttr = run.Attribute("link");
					if (linkAttr == null)
						continue; // Run doesn't contain an unowned hot-link
					XAttribute ownedLinkAttr = new XAttribute("ownlink", linkAttr.Value);
					run.Add(ownedLinkAttr);
					linkAttr.Remove();
					DataMigrationServices.UpdateDTO(domainObjectDtoRepository, scrTxtPara, para.ToString());
				}
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
コード例 #18
0
        protected virtual void AddAnnotations(AnnotatableElementClipboardFormat clipboardFormat, EFElement element)
        {
            foreach (var t in clipboardFormat.AdditionalAttributes)
            {
                var name = t.Item1;
                var value = t.Item2;
                var xn = XName.Get(name);
                var xa = new XAttribute(xn, value);
                element.XElement.Add(xa);
            }

            foreach (var s in clipboardFormat.AdditionalElements)
            {
                try
                {
                    var d = XDocument.Parse(s, LoadOptions.PreserveWhitespace);
                    var xe = d.Root;
                    xe.Remove();
                    element.XElement.Add(xe);
                }
                catch (XmlException)
                {
                    // ignore an XmlException.  There was probalby a problem parsing.
                }
            }
        }
コード例 #19
0
ファイル: MyXMLClass.cs プロジェクト: ahirugumi/CSharp-Study
        public XDocument GetXMLDocument()
        {
            var myxml = new XDocument ();
            var myele = new XElement ("myxmls");

            var ele100 = new XElement ("myxml");
            var idele100 = new XElement ("id", "100");
            var nameele100 = new XElement ("name", "hoge");
            var mailatt100 = new XAttribute ("mail", "*****@*****.**");
            myele.Add (ele100);
            ele100.Add (idele100);
            nameele100.Add (mailatt100);
            ele100.Add (nameele100);

            var ele200 = new XElement ("myxml");
            var idele200 = new XElement ("id", "200");
            var nameele200 = new XElement ("name", "bar");
            var mailatt200 = new XAttribute ("mail", "*****@*****.**");
            myele.Add (ele200);
            ele200.Add (idele200);
            nameele200.Add (mailatt200);
            ele200.Add (nameele200);

            var ele300 = new XElement ("myxml");
            var idele300 = new XElement ("id", "300");
            var nameele300 = new XElement ("name", "foo");
            var mailatt300 = new XAttribute ("mail", "*****@*****.**");
            myele.Add (ele300);
            ele300.Add (idele300);
            nameele300.Add (mailatt300);
            ele300.Add (nameele300);

            myxml.Add (myele);
            return myxml;
        }
コード例 #20
0
        //метод сохранения в файле XML данных компании
        public void CreateInXML(string email, string RashetnSchet,string passw)
        {
            //создали контекст объекта

                XDocument Doc = new XDocument();

                XElement RshCompany = new XElement("RshCompany");
                XAttribute NameRsc = new XAttribute("nameRsc", "RscCompanyForWork");
                XElement RscValue = new XElement("Rsc", RashetnSchet);
                XElement EmailValue = new XElement("Em", email);
                XElement ParolValue = new XElement("Pasw", passw);
                RshCompany.Add(NameRsc);
                RshCompany.Add(RscValue);
                RshCompany.Add(EmailValue);
                RshCompany.Add(ParolValue);
            // создаем корневой элемент
                XElement about = new XElement("about");
                // добавляем в корневой элемент
                about.Add(RshCompany);
                //about.Add(EmailCompany);
                // добавляем корневой элемент в документ
                Doc.Add(about);
                string path = Server.MapPath("~//App_Data//AboutCompany.xml");

                //сохраняем документ
                if(path!=null)
                {
                    Doc.Save(path);
                }
        }
コード例 #21
0
		public CandidateElimination(string fileName) : base(fileName) {
			//setup current hypothesis
			XName name = "row";
			_currentHypothesis = new XElement(name);
			XAttribute newAttribute = null;
			_attributeList = new List<XName>();
			//initialize the most specific hypothesis set
			foreach (XAttribute a in _dataSet.SampleRowElement.Attributes()) {
				newAttribute = new XAttribute(a.Name, "");
				_attributeList.Add(a.Name);
				_currentHypothesis.Add(newAttribute);
			}
			_specificHypotheses = new List<XElement>();
			_specificHypotheses.Add(new XElement(_currentHypothesis));

			//setup current hypothesis
			_currentHypothesis = new XElement(name);
			//initialize the most specific hypothesis set
			foreach (XAttribute a in _dataSet.SampleRowElement.Attributes()) {
				newAttribute = new XAttribute(a.Name, "Q");
				_currentHypothesis.Add(newAttribute);
			}
			_generalHypotheses = new List<XElement>();
			_generalHypotheses.Add(new XElement(_currentHypothesis));
			_targetConcept = _attributeList[_attributeList.Count - 1];
			eliminateCandidates();
		}
コード例 #22
0
ファイル: XAttribute.cs プロジェクト: nguyenkien/api
 /// <summary>
 /// Copy ctor
 /// </summary>
 public XAttribute(XAttribute source)
 {
     if (source == null)
         throw new ArgumentNullException("source");
     value = source.value;
     name = source.name;
 }
コード例 #23
0
 /// <summary>
 /// Checks if the files exist.
 /// </summary>
 private void CheckForFiles()
 {
     if (!File.Exists(@"..\..\Resources\OptionsSettings.xml"))
     {
         if (MessageBox.Show("Couldn't find the xml file for the settings. \n Would you like to create a new with default settings?", "Error", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             XElement mouseElement = new XElement("mouse", "true");
             XElement keyboardElement = new XElement("keyboard", "true");
             XElement soundElement = new XElement("sound", "true");
             XElement resolutionElement = new XElement("resolution", "1024x768");
             XElement leftkeyElement = new XElement("leftkey", "Left");
             XElement rightkeyElement = new XElement("rightkey", "Right");
             XElement firekeyElement = new XElement("firekey", "Space");
             XElement pausekeyElement = new XElement("pausekey", "P");
             XElement difficultyElement = new XElement("difficulty", "1");
             XElement mapElement = new XElement("map", "1");
             XAttribute newAttribute = new XAttribute("id", 1);
             XElement newElements = new XElement("option", newAttribute, mouseElement, keyboardElement, soundElement, resolutionElement, leftkeyElement, rightkeyElement, firekeyElement, pausekeyElement, difficultyElement, mapElement);
             XElement newOptions = new XElement("Options", newElements);
             XDocument newDocument = new XDocument(newOptions);
             newDocument.Save(@"..\..\Resources\OptionsSettings.xml");
         }
         else
         {
             MapSelection returnToMap = new MapSelection();
             returnToMap.Show();
             Close();
         }
     }
     // If the OptionsSettings xml doesn't exist, then send message.
 }
コード例 #24
0
        private static IEnumerable <object> GetStyleAttributes(XAttribute attribute)
        {
            var result = new List <object>();

            if (!attribute.Name.LocalName.Contains("style"))
            {
                return(result);
            }
            try
            {
                var nameValuePairs = attribute.Value.Split(';');
                foreach (var nameValuePair in nameValuePairs)
                {
                    var trimmedNameValue = nameValuePair.Trim().Split(':');
                    if (trimmedNameValue.Length == 2)
                    {
                        var attributeName  = trimmedNameValue[0].Trim();
                        var attributeValue = trimmedNameValue[1].Trim();
                        result.Add(AttributeFactory.GetAttribute(attributeName, attributeValue));
                    }
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
コード例 #25
0
ファイル: Clues.cs プロジェクト: borgidiom/UC-Scanager-Hunt
        // this code is modfied code from the following tutorial
        // http://blogs.msdn.com/b/mingfeis_code_block/archive/2010/10/03/windows-phone-7-how-to-store-data-and-pass-data-between-pages.aspx
        public void LoadClues()
        {
            EnterClues();
            string elementNumber;

            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                for (int i=0; i < noClues; i++)
                {
                    elementNumber = "number"+clueId[i].ToString();
                    XDocument _doc = new XDocument();
                    XElement _clue = new XElement(elementNumber);
                    XAttribute _clueId = new XAttribute("clueId", clueId[i]);
                    XAttribute _clueText = new XAttribute("clueText", clueText[i]);
                    XAttribute _barcodeRef = new XAttribute("barcodeRef", barcodeRef[i]);
                    XAttribute _location = new XAttribute("location", location[i]);
                    XAttribute _locInfo = new XAttribute("locInfo", locInfo[i]);
                    XAttribute _latitude = new XAttribute("latitude", latitude[i]);
                    XAttribute _longitude = new XAttribute("longitude", longitude[i]);

                    _clue.Add(_clueId, _clueText, _barcodeRef, _location, _locInfo, _latitude, _longitude);

                    _doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), _clue);
                    IsolatedStorageFileStream memory = new IsolatedStorageFileStream(elementNumber + ".clue", System.IO.FileMode.Create, storage);

                    System.IO.StreamWriter file = new System.IO.StreamWriter(memory);
                    _doc.Save(file);

                    file.Dispose();
                    memory.Dispose();
                }

            }
        }
コード例 #26
0
ファイル: XMLBase.cs プロジェクト: Dazmo/Terraria-Map-Editor
 public PointShort XMLConvert(PointShort v, XAttribute attr)
 {
     if (attr == null) return v;
     var ps = PointShort.TryParseInline((string)attr);
     if (attr.Name == "size" && ps == new PointShort()) ps = new PointShort(1, 1);
     return ps;
 }
コード例 #27
0
 public XAttribute(XAttribute other)
 {
     if (other == null)
         throw new ArgumentNullException ("other");
     name = other.name;
     value = other.value;
 }
コード例 #28
0
ファイル: XMLBase.cs プロジェクト: Dazmo/Terraria-Map-Editor
 public FramePlacement XMLConvert(FramePlacement v, XAttribute attr)
 {
     if (attr == null) return v;
     FramePlacement f = FramePlacement.Any;
     f = f.Convert<FramePlacement>(attr);
     return f;
 }
コード例 #29
0
        public static dynamic CreateInstance(XAttribute attribute)
        {
            Contract.Requires(attribute != null);
            Contract.Ensures(Contract.Result<object>() != null);

            return new DynamicXAttribute(attribute);
        }
コード例 #30
0
ファイル: XmlHelper.cs プロジェクト: Zolniu/DigitalRune
        /// <summary>
        /// Gets the message text including line info for exceptions that occur when parsing XML.
        /// </summary>
        /// <param name="attribute">The current attribute.</param>
        /// <param name="format">The format string.</param>
        /// <param name="args">An object array that contains zero or more objects to format.</param>
        /// <returns>The exception message including line info.</returns>
        public static string GetExceptionMessage(XAttribute attribute, string format, params object[] args)
        {
            if (attribute == null)
            throw new ArgumentNullException("attribute");

              var cultureInfo = CultureInfo.InvariantCulture;
              string message = string.Format(cultureInfo, format, args);

              // Append line info, if available.
              var lineInfo = (IXmlLineInfo)attribute;
              if (lineInfo.HasLineInfo())
              {
            message += string.Format(
              cultureInfo,
              " (Attribute: \"{0}\", Line: {1}, Position: {2})",
              attribute.Name, lineInfo.LineNumber, lineInfo.LinePosition);
              }
              else
              {
            message += string.Format(
              cultureInfo,
              " (Attribute: \"{0}\")",
              attribute.Name);
              }

              return message;
        }
コード例 #31
0
 public void ExitSave()
 {
     XElement xRoot = new XElement("ChosenPath");
     XAttribute xPath = new XAttribute("Path", filepath);
     xRoot.Add(xPath);
     xRoot.Save("Config.xml");
 }
コード例 #32
0
        static void MoveAttributeIfAny(System.Xml.Linq.XName attributeName, System.Xml.Linq.XElement from, System.Xml.Linq.XElement to)
        {
            System.Xml.Linq.XAttribute attr = from.Attribute(attributeName);
            if (attr != null)
            {
                // Remove the attribute from its current parent:
                attr.Remove();

                // Add the attribute to its new parent
                to.Add(attr);
            }
        }
コード例 #33
0
        public Vertices ToEntity(System.Xml.Linq.XAttribute attribute)
        {
            string data = (string)attribute.Value;

            data = Regex.Replace(data, "[ \t]+", " ");
            data = data.Trim();

            string[] vertices = data.Split(new char[] { ' ' });

            Vertices ret = new Vertices(vertices.Length);

            foreach (string vertex in data.Split(new char[] { ' ' }))
            {
                string[] points = vertex.Split(new char[] { ',' });
                ret.Add(new Vector2(System.Convert.ToSingle(points[0]), System.Convert.ToSingle(points[1])));
            }

            return(ret);
        }
コード例 #34
0
 public void ToEntity(System.Xml.Linq.XAttribute attribute, Vertices entity)
 {
     throw new NotImplementedException();
 }
コード例 #35
0
 internal virtual void AddAttributeSkipNotify(XAttribute a)
 {
 }
コード例 #36
0
        internal void ReadContentFrom(XmlReader r, LoadOptions o)
        {
            if ((o & (LoadOptions.SetBaseUri | LoadOptions.SetLineInfo)) == 0)
            {
                ReadContentFrom(r);
                return;
            }
            if (r.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
            }
            XContainer     c       = this;
            XNode          n       = null;
            NamespaceCache eCache  = new NamespaceCache();
            NamespaceCache aCache  = new NamespaceCache();
            string         baseUri = (o & LoadOptions.SetBaseUri) != 0 ? r.BaseURI : null;
            IXmlLineInfo   li      = (o & LoadOptions.SetLineInfo) != 0 ? r as IXmlLineInfo : null;

            do
            {
                string uri = r.BaseURI;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                {
                    XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
                    if (baseUri != null && baseUri != uri)
                    {
                        e.SetBaseUri(uri);
                    }
                    if (li != null && li.HasLineInfo())
                    {
                        e.SetLineInfo(li.LineNumber, li.LinePosition);
                    }
                    if (r.MoveToFirstAttribute())
                    {
                        do
                        {
                            XAttribute a = new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value);
                            if (li != null && li.HasLineInfo())
                            {
                                a.SetLineInfo(li.LineNumber, li.LinePosition);
                            }
                            e.AppendAttributeSkipNotify(a);
                        } while (r.MoveToNextAttribute());
                        r.MoveToElement();
                    }
                    c.AddNodeSkipNotify(e);
                    if (!r.IsEmptyElement)
                    {
                        c = e;
                        if (baseUri != null)
                        {
                            baseUri = uri;
                        }
                    }
                    break;
                }

                case XmlNodeType.EndElement:
                {
                    if (c.content == null)
                    {
                        c.content = string.Empty;
                    }
                    // Store the line info of the end element tag.
                    // Note that since we've got EndElement the current container must be an XElement
                    XElement e = c as XElement;
                    Debug.Assert(e != null, "EndElement received but the current container is not an element.");
                    if (e != null && li != null && li.HasLineInfo())
                    {
                        e.SetEndElementLineInfo(li.LineNumber, li.LinePosition);
                    }
                    if (c == this)
                    {
                        return;
                    }
                    if (baseUri != null && c.HasBaseUri)
                    {
                        baseUri = c.parent.BaseUri;
                    }
                    c = c.parent;
                    break;
                }

                case XmlNodeType.Text:
                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.Whitespace:
                    if ((baseUri != null && baseUri != uri) ||
                        (li != null && li.HasLineInfo()))
                    {
                        n = new XText(r.Value);
                    }
                    else
                    {
                        c.AddStringSkipNotify(r.Value);
                    }
                    break;

                case XmlNodeType.CDATA:
                    n = new XCData(r.Value);
                    break;

                case XmlNodeType.Comment:
                    n = new XComment(r.Value);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    n = new XProcessingInstruction(r.Name, r.Value);
                    break;

                case XmlNodeType.DocumentType:
                    n = new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value);
                    break;

                case XmlNodeType.EntityReference:
                    if (!r.CanResolveEntity)
                    {
                        throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
                    }
                    r.ResolveEntity();
                    break;

                case XmlNodeType.EndEntity:
                    break;

                default:
                    throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
                }
                if (n != null)
                {
                    if (baseUri != null && baseUri != uri)
                    {
                        n.SetBaseUri(uri);
                    }
                    if (li != null && li.HasLineInfo())
                    {
                        n.SetLineInfo(li.LineNumber, li.LinePosition);
                    }
                    c.AddNodeSkipNotify(n);
                    n = null;
                }
            } while (r.Read());
        }
コード例 #37
0
 public void SerializeToAttribute(string objectToSerialize, System.Xml.Linq.XAttribute attrToFill)
 {
 }
コード例 #38
0
ファイル: XElementEx.cs プロジェクト: lanicon/Cinchoo
        public static string GetName(this XElement xmlNode)
        {
            XAttribute attr = xmlNode.Attribute("name");

            return(attr != null ? attr.Value : null);
        }
コード例 #39
0
 internal virtual void AddAttribute(XAttribute a)
 {
 }