Beispiel #1
0
		public static Section Read (XmlReader reader)
		{
			Section result = new Section (reader.GetAttribute ("name"));
			result.Documentation = reader.ReadElementString ();
			return result;
		}
		public void Set (string name, string parameterName, string doc)
		{
			if (name.StartsWith ("param") && name.Length > "param".Length) {
				parameterName = ((IParameterizedMember)member).Parameters[int.Parse (name.Substring("param".Length))].Name;
				name = "param";
			}
			Section newSection = new Section (name);
			
			if (parameterName != null)
				newSection.SetAttribute (name == "exception" ? "cref" : "name", parameterName);
			
			newSection.Documentation = doc;
			
			for (int i = 0; i < sections.Count; i++) {
				if (sections[i].Name == name) {
					if (!string.IsNullOrEmpty (parameterName) && !sections[i].Attributes.Any (a => a.Value == parameterName))
						continue;
					sections[i] = newSection;
					return;
				}
			}
			
			sections.Add (newSection);
		}
		public void Set (string name, string parameterName, string doc)
		{
			if (name.StartsWith ("param", StringComparison.Ordinal) && name.Length > "param".Length) {
				var parameters = member.GetParameters ();
				var idx = int.Parse (name.Substring ("param".Length));
				parameterName = idx < parameters.Length ? parameters [idx].Name : "unknown";
				name = "param";
			}
			Section newSection = new Section (name);
			
			if (parameterName != null)
				newSection.SetAttribute (name == "exception" ? "cref" : "name", parameterName);
			
			newSection.Documentation = doc;
			
			for (int i = 0; i < sections.Count; i++) {
				if (sections[i].Name == name) {
					if (!string.IsNullOrEmpty (parameterName) && !sections[i].Attributes.Any (a => a.Value == parameterName))
						continue;
					sections[i] = newSection;
					return;
				}
			}
			
			sections.Add (newSection);
		}
		void FillDocumentation (string xmlDoc)
		{
			if (string.IsNullOrEmpty (xmlDoc))
				return;
			StringBuilder sb = new StringBuilder ();
			sb.Append ("<root>");
			bool wasWs = false;
			foreach (char ch in xmlDoc) {
				if (ch =='\r')
					continue;
				if (ch == ' ' || ch == '\t') {
					if (!wasWs)
						sb.Append (' ');
					wasWs = true;
					continue;
				}
				wasWs = false;
				sb.Append (ch);
			}
			sb.Append ("</root>");
			try {
				using (var reader = XmlTextReader.Create (new System.IO.StringReader (sb.ToString ()))) {
					while (reader.Read ()) {
						if (reader.NodeType != XmlNodeType.Element)
							continue;
						if (reader.LocalName == "root") {
							continue;
						}
						Section readSection = new Section (reader.LocalName);
						if (reader.MoveToFirstAttribute ()) {
							do {
								readSection.SetAttribute (reader.LocalName, reader.Value);
							} while (reader.MoveToNextAttribute ());
						}
						readSection.Documentation = reader.ReadElementString ().Trim ();
						sections.Add (readSection);
					}
				}
			} catch (Exception e) {
				LoggingService.LogError ("Error while filling documentation", e);
			}
		}
        void FillDocumentation(string xmlDoc)
        {
            if (string.IsNullOrEmpty(xmlDoc))
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("<root>");
            bool wasWs = false;

            foreach (char ch in xmlDoc)
            {
                if (ch == '\r')
                {
                    continue;
                }
                if (ch == ' ' || ch == '\t')
                {
                    if (!wasWs)
                    {
                        sb.Append(' ');
                    }
                    wasWs = true;
                    continue;
                }
                wasWs = false;
                sb.Append(ch);
            }
            sb.Append("</root>");
            try
            {
                using (var reader = XmlTextReader.Create(new System.IO.StringReader(sb.ToString())))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        if (reader.LocalName == "root")
                        {
                            continue;
                        }
                        Section readSection = new Section(reader.LocalName);
                        if (reader.MoveToFirstAttribute())
                        {
                            do
                            {
                                readSection.SetAttribute(reader.LocalName, reader.Value);
                            }while (reader.MoveToNextAttribute());
                        }
                        readSection.Documentation = reader.ReadElementString().Trim();
                        sections.Add(readSection);
                    }
                }
            }
            catch (Exception e)
            {
                LoggingService.LogError("Error while filling documentation", e);
            }
        }