public override void InitialiseFromXML(XmlTextReader reader, SvgDocument document) { base.InitialiseFromXML(reader, document); //read in the metadata just as a string ready to be written straight back out again Content = reader.ReadInnerXml(); }
public void FromFile(string filename, out string[] layerNameArray, out string[] collisionNameArray) { List<string> layerNames = new List<string>(); List<string> collisionNames = new List<string>(); XmlTextReader reader = new XmlTextReader(filename); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "CollisionLayer") { collisionNames.Add(reader.ReadInnerXml()); } if (reader.Name == "TileLayer") { layerNames.Add(reader.ReadInnerXml()); } } } reader.Close(); collisionNameArray = collisionNames.ToArray(); layerNameArray = layerNames.ToArray(); }
/// <summary> /// 字符资源 /// </summary> /// <param name="LanguageFileName">当前语言文件</param> public void InitLanguage(String LanguageFileName) { String tag = String.Empty; String text = String.Empty; XmlTextReader reader = new XmlTextReader(LanguageFileName); _stringDic.Clear(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "Language") { LanguageType = reader.GetAttribute("Type"); continue; } tag = reader.Name.Trim(); text = reader.ReadInnerXml().Trim(); if (!String.IsNullOrEmpty(tag) && !String.IsNullOrEmpty(text)) { _stringDic.Add(tag, text); } break; default: break; } } }
/// <summary> /// 字符资源 /// </summary> /// <param name="currentLanguage">当前语言</param> public void InitLanguage(Language currentLanguage) { string tag = string.Empty; string text = string.Empty; string fileName = string.Format("Language\\{0}.xml", currentLanguage.ToString()); XmlTextReader reader = new XmlTextReader(fileName); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "Language") { continue; } tag = reader.Name.Trim(); text = reader.ReadInnerXml().Trim(); if (!string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(text)) { _stringDic.Add(tag, text); //System.Diagnostics.Debug.WriteLine(tag + ","); } break; } } }
public XmlNode SerializeAsXmlNode(XmlDocument doc) { System.IO.MemoryStream ms = new MemoryStream(); XmlSerializer serializer = new XmlSerializer(typeof(ColumnCollection)); XmlTextReader xRead = null; XmlNode xTable = null; try { xTable = doc.CreateNode(XmlNodeType.Element, "TABLE", doc.NamespaceURI); serializer.Serialize(ms, this); ms.Position = 0; xRead = new XmlTextReader( ms ); xRead.MoveToContent(); string test = xRead.ReadInnerXml(); XmlDocumentFragment docFrag = doc.CreateDocumentFragment(); docFrag.InnerXml = test; xTable.AppendChild(docFrag); } catch(Exception ex) { throw new Exception("IdentityCollection Serialization Error.", ex); } finally { ms.Close(); if (xRead != null) xRead.Close(); } return xTable; }
void ReadDefects (string filename) { using (XmlTextReader reader = new XmlTextReader (filename)) { Dictionary<string, string> full_names = new Dictionary<string, string> (); // look for 'gendarme-output/rules/rule/' while (reader.Read () && (reader.Name != "rule")); do { full_names.Add (reader ["Name"], "R: " + reader.ReadInnerXml ()); } while (reader.Read () && reader.HasAttributes); // look for 'gendarme-output/results/ while (reader.Read () && (reader.Name != "results")); HashSet<string> defects = null; while (reader.Read ()) { if (!reader.HasAttributes) continue; switch (reader.Name) { case "rule": defects = new HashSet<string> (); ignore_list.Add (full_names [reader ["Name"]], defects); break; case "target": string target = reader ["Name"]; if (target.IndexOf (' ') != -1) defects.Add ("M: " + target); else defects.Add ("T: " + target); break; } } } }
/// <summary> /// 字符资源 /// </summary> /// <param name="languageFileName">当前语言文件</param> public static void InitLanguage(string languageFileName) { var tag = string.Empty; var text = string.Empty; var reader = new XmlTextReader(languageFileName); StringDic.Clear(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "Language") { LanguageType = reader.GetAttribute("Type"); continue; } tag = reader.Name.Trim().Replace("_","").ToUpper(); text = reader.ReadInnerXml().Trim(); if (!string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(text)) { StringDic.Add(tag, text); } break; default: break; } } }
//http request bt POST //to add new info of a student public String InsertStudentInfoByPost(string URL, String Info) { string strURL = URL+ "InsertStudentInfo"; Encoding myEncoding = Encoding.GetEncoding("utf-8"); string param = "Info="+ HttpUtility.UrlEncode(Info, myEncoding); byte[] bs = Encoding.ASCII.GetBytes(param); string result=""; //Initiate, DO NOT use constructor of HttwWebRequest //DO use constructor of WebRequest HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL); //POST request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded;charset=utf-8"; request.ContentLength = bs.Length; using (Stream reqStream = request.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); } using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { //DEAL with return values here Stream s = response.GetResponseStream(); XmlTextReader reader = new XmlTextReader(s); reader.MoveToContent(); result = reader.ReadInnerXml(); //////// result=result.Split(new Char[] { '<', '>' })[2]; ///////// } return result; }
/// <summary> /// Cache the xmld docs into a hashtable for faster access. /// </summary> /// <param name="reader">An XMLTextReader containg the docs the cache</param> private void CacheDocs(XmlTextReader reader) { object oMember = reader.NameTable.Add("member"); reader.MoveToContent(); while (!reader.EOF) { if ((reader.NodeType == XmlNodeType.Element) && (reader.Name.Equals(oMember))) { string ID = reader.GetAttribute("name"); string doc = reader.ReadInnerXml().Trim(); doc = PreprocessDoc(ID, doc); if (docs.ContainsKey(ID)) { Trace.WriteLine("Warning: Multiple <member> tags found with id=\"" + ID + "\""); } else { docs.Add(ID, doc); } } else { reader.Read(); } } }
//http request bt GET //to get info of a student public List<String> getStudentInfoByGet(string URL, string ID_No) { //Create the URL List<String> infos = new List<string>(); String[] functions = { "GetStudentName", "GetStudentGender", "GetStudentMajor", "GetStudentEmailAddress" }; string function = ""; for (int i = 0; i < functions.Length; i++) { function = functions[i]; string strURL = URL + function + "?ID_No=" + ID_No; //Initiate, DO NOT use constructor of HttwWebRequest //DO use constructor of WebRequest HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL); request.Method = "GET"; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream s = response.GetResponseStream(); XmlTextReader reader = new XmlTextReader(s); reader.MoveToContent(); string xml = reader.ReadInnerXml(); //////// xml = xml.Split(new Char[] { '<', '>' })[2]; ///////// infos.Add(xml); } } return infos; }
public static Location GetLocationData(string street, string zip, string city, string state, string country) { // Use an invariant culture for formatting numbers. NumberFormatInfo numberFormat = new NumberFormatInfo(); Location loc = new Location(); XmlTextReader xmlReader = null; try { HttpWebRequest webRequest = GetWebRequest(street, zip, city, state); HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); using (xmlReader = new XmlTextReader(response.GetResponseStream())) { while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Result") { XmlReader resultReader = xmlReader.ReadSubtree(); while (resultReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Latitude") loc.Latitude = Convert.ToDouble(xmlReader.ReadInnerXml(), numberFormat); if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Longitude") { loc.Longitude = Convert.ToDouble(xmlReader.ReadInnerXml(), numberFormat); break; } } } } } } finally { if (xmlReader != null) xmlReader.Close(); } // Return the location data. return loc; }
public static DataTable AsDataTable(this string xmlString) { DataSet dataSet = new DataSet(); XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xmlString)); reader.Read(); string inner = reader.ReadInnerXml(); dataSet.ReadXml(reader); return dataSet.Tables[0]; }
public DailyQueueConfiguration() { cookies = new CookieCollection(); try { //grab the user and password values from the config file using (XmlTextReader reader = new XmlTextReader(CONFIG_XML)) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == USER_NODE_NAME) { user = reader.ReadInnerXml(); } else if (reader.Name == PASSWORD_NODE_NAME) { password = reader.ReadInnerXml(); } break; } } reader.Close(); } } catch (FileNotFoundException e) { string msg = e.Message; //create the configuration file using (XmlWriter writer = XmlWriter.Create(CONFIG_XML)) { writer.WriteStartDocument(); writer.WriteStartElement("config"); writer.WriteElementString("user", ""); writer.WriteElementString("password", ""); writer.WriteEndElement(); writer.WriteEndDocument(); } } }
/// <summary> /// Read the specified xml and uri. /// </summary> /// <description>XML is the raw Note XML for each note in the system.</description> /// <description>uri is in the format of //tomboy:NoteHash</description> /// <param name='xml'> /// Xml. /// </param> /// <param name='uri'> /// URI. /// </param> public static Note Read(XmlTextReader xml, string uri) { Note note = new Note (uri); DateTime date; int num; string version = String.Empty; while (xml.Read ()) { switch (xml.NodeType) { case XmlNodeType.Element: switch (xml.Name) { case "note": version = xml.GetAttribute ("version"); break; case "title": note.Title = xml.ReadString (); break; case "text": // <text> is just a wrapper around <note-content> // NOTE: Use .text here to avoid triggering a save. note.Text = xml.ReadInnerXml (); break; case "last-change-date": if (DateTime.TryParse (xml.ReadString (), out date)) note.ChangeDate = date; else note.ChangeDate = DateTime.Now; break; case "last-metadata-change-date": if (DateTime.TryParse (xml.ReadString (), out date)) note.MetadataChangeDate = date; else note.MetadataChangeDate = DateTime.Now; break; case "create-date": if (DateTime.TryParse (xml.ReadString (), out date)) note.CreateDate = date; else note.CreateDate = DateTime.Now; break; case "x": if (int.TryParse (xml.ReadString (), out num)) note.X = num; break; case "y": if (int.TryParse (xml.ReadString (), out num)) note.Y = num; break; } break; } } return note; }
protected void btnXMLImport_Click(object sender, EventArgs e) { // string xmlfilename = //"D:\\LAVC computer Science\\CSIT 870Exercise\\Final Project\\Survey Prj\\Survey_Questions_e.xml"; // "D:\\LAVC computer Science\\CSIT 870Exercise\\XMLFile_and_Templates\\XMLFile.xml"; System.Xml.XmlTextReader xmlreader = new System.Xml.XmlTextReader (Server.MapPath("~/App_Data/Survey_Questions_e.xml")); SqlConnection connection = new System.Data.SqlClient.SqlConnection(); string con_string = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; connection.ConnectionString = con_string; //string cmd_string = "DELETE FROM Question"; // remove all records from the REGIONS table // System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmd_string, connection); /* command.Connection.Open(); * command.ExecuteNonQuery(); // execute the delete command * * xmlreader.MoveToContent(); */// skip over the XML header stuff while (xmlreader.Read()) { if (xmlreader.NodeType == System.Xml.XmlNodeType.Element) // only process the start tag of the element { string tag = xmlreader.Name; // get the tag name for the element if (tag == "Question") { string Focus_Group = xmlreader.GetAttribute("Focus_Group"); // get the Attribute values string Catagory = xmlreader.GetAttribute("Catagory"); string Questiontxt = xmlreader.ReadInnerXml(); // Build and execute the INSERT command string cmd_string = "INSERT INTO Question(Focus_Group,Catagory,Question) VALUES ('" + Focus_Group + "', '" + Catagory + "', '" + Questiontxt + "')"; System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmd_string, connection); command.CommandText = cmd_string; command.Connection.Open(); command.ExecuteNonQuery(); // execute the insert command command.Connection.Close(); } } } GridView1.Visible = true; }
private void ddd(XYSaleBill sb) { try { string url = Common.AppSetting.httpurl; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; string postdata = "body=" + JsonConvert.SerializeObject(sb); UTF8Encoding code = new UTF8Encoding(); //这里采用UTF8编码方式 byte[] data = code.GetBytes(postdata); request.ContentLength = data.Length; using (Stream stream = request.GetRequestStream()) //获取数据流,该流是可写入的 { stream.Write(data, 0, data.Length); //发送数据流 stream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream ss = response.GetResponseStream(); XmlTextReader Reader = new XmlTextReader(ss); Reader.MoveToContent(); string status = Reader.ReadInnerXml(); if (status == "302") { sb.UpDatePostInfo(1); Common.AppLog.CreateAppLog().Info(string.Format("编号为:{0} 的单据于 {1} 更新成功", sb.sheet_id, DateTime.Now)); } else { sb.UpDatePostInfo(0); Common.AppLog.CreateAppLog().Error(string.Format("编号为:{0} 的单据于 {1} 更新失败", sb.sheet_id, DateTime.Now)); } } } catch (Exception ex) { Common.AppLog.CreateAppLog().Error(ex.Message); } }
/// <summary> /// Reads the documentation from the XML file provided via <paramref name="fileName"/>. /// </summary> /// <param name="fileName">Full path to the file containing the documentation.</param> public Dictionary<string,string> ReadDocumentation(string fileName) { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreWhitespace = true; settings.CloseInput = true; if (!File.Exists(fileName)) { /// The file either doesn't exist, or JustDecompile doesn't have permissions to read it. return new Dictionary<string, string>(); } using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { Dictionary<string, string> documentationMap = new Dictionary<string, string>(); using (XmlTextReader reader = new XmlTextReader(fs, XmlNodeType.Element, null)) { try { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "member") { string elementName = reader.GetAttribute("name"); // The assembly member to which the following section is related. string documentation = RemoveLeadingLineWhitespaces(reader.ReadInnerXml()); // The documenting section. // Keep only the documentation from the last encountered documentation tag. (similar to VS Intellisense) documentationMap[elementName] = documentation; } } } } catch (XmlException e) { // the XML file containing the documentation is corrupt. return new Dictionary<string,string>(); } } return documentationMap; } }
public static void ReadXmlExpenses(string pathToFile) { XmlTextReader reader = new XmlTextReader(pathToFile); string vendorName = string.Empty; DateTime date = new DateTime(); decimal expenses = 0; using (reader) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.HasAttributes) { reader.MoveToNextAttribute(); if (reader.Name == "vendor") { vendorName = reader.Value; } else if (reader.Name == "month") { date = DateTime.Parse(reader.Value); } } reader.MoveToElement(); } if (reader.NodeType == XmlNodeType.Element && reader.Name == "expenses") { var expenseStr = reader.ReadInnerXml(); expenses = decimal.Parse(expenseStr); int vendorId = MsSqlManager.InsertExpenses(vendorName, date, expenses); MongoExpense mongoExpense = new MongoExpense(vendorId, date, expenses); MongoDbManager.IsertExpenses(mongoExpense, "mongodb://localhost", "SupermarketProductReports", "Expenses"); } } } }
public override void Parse(TestResultCollection collection) { // serge: now log output for dependent test cases supported, the have additional XML // element, that corrupts XML document structure using (XmlTextReader xtr = new XmlTextReader(this.InputStream, XmlNodeType.Element, null)) { while (xtr.Read()) { if (xtr.NodeType == XmlNodeType.Element && xtr.Name == Xml.TestLog) { XmlDocument doc = new XmlDocument(); XmlElement elemTestLog = doc.CreateElement(Xml.TestLog); elemTestLog.InnerXml = xtr.ReadInnerXml(); ParseTestUnitsLog(elemTestLog.ChildNodes, new QualifiedNameBuilder(), collection); break; } } } }
public void load(TextReader input) { XmlTextReader reader = new XmlTextReader(input); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "material") { string matName = ""; while (reader.MoveToNextAttribute()) { Utils.print(reader.Name); if (reader.Name == "name") { matName = reader.Value; } } reader.MoveToElement(); string matDefinitoion = reader.ReadInnerXml(); this.create(matName, matDefinitoion); } } }
public void ParsePlaylist(string content) { this.songs.Clear (); this.nextSong = 0; XmlTextReader reader = new XmlTextReader (content, XmlNodeType.Element, null); while (reader.Read ()) { reader.MoveToElement (); switch (reader.LocalName) { case "playlist": int version = Convert.ToInt32 (reader.GetAttribute ("version")); if (version > PLAYLIST_VERSION) { Console.WriteLine ("WARNING: Remote playlist version is: {0} - local version is {1}", version, PLAYLIST_VERSION); } break; case "title": string title = reader.ReadString (); station = HttpUtility.UrlDecode (title); break; case "creator": break; case "link": break; case "track": string xml = reader.ReadInnerXml (); this.songs.Add (ParseSong (xml, station)); break; } } }
/// <summary> /// Generate Section block in Content.xml. /// </summary> private void CreateSection() { if (_projInfo.ProjectInputType == "Scripture") RemoveScrSectionClass(_sectionName); foreach (string section in _sectionName) { string secName = "_" + section.Trim() + ".xml"; string path = Common.PathCombine(Path.GetTempPath(), secName); if (!File.Exists(path)) { return; } var xmlReader = new XmlTextReader(path); xmlReader.Read(); xmlReader.Read(); xmlReader.Read(); string xml = xmlReader.ReadInnerXml(); if (xml != "") { _writer.WriteRaw(xml); } xmlReader.Close(); // Clean UP File.Delete(path); } }
private void ParseNodeFirstPass(XmlTextReader reader, XMLTree parentNode, String parentTypeName) { INodeModel nodeModel = graph.Model.NodeModel; IEdgeModel edgeModel = graph.Model.EdgeModel; Dictionary<String, int> tagNameToNextIndex = new Dictionary<String, int>(); while(reader.Read()) { if(reader.NodeType == XmlNodeType.EndElement) break; // reached end of current nesting level if(reader.NodeType != XmlNodeType.Element) continue; bool emptyElem = reader.IsEmptyElement; // retard API designer String tagName = reader.Name; String id = null; if(reader.MoveToAttribute("xmi:id")) id = reader.Value; String elementName = null; if(reader.MoveToAttribute("name")) elementName = reader.Value; String typeName = null; if(reader.MoveToAttribute("xsi:type")) typeName = reader.Value; else if(reader.MoveToAttribute("xmi:type")) typeName = reader.Value; else { typeName = FindRefTypeName(parentTypeName, tagName); if(typeName == null) { // Treat it as an attribute AssignAttribute(parentNode.elementNode, tagName, reader.ReadInnerXml()); XMLTree attributeChild = new XMLTree(); attributeChild.elementNode = null; attributeChild.elementName = elementName; attributeChild.element = tagName; attributeChild.children = null; parentNode.children.Add(attributeChild); continue; } } INode gnode = graph.AddNode(nodeModel.GetType(GrGenTypeNameFromXmi(typeName))); XMLTree child = new XMLTree(); child.elementNode = gnode; child.elementName = elementName; child.element = tagName; child.children = new List<XMLTree>(); parentNode.children.Add(child); if(id != null) nodeMap[id] = gnode; String edgeTypeName = FindContainingTypeName(parentTypeName, tagName); String grgenEdgeTypeName = GrGenTypeNameFromXmi(edgeTypeName) + "_" + tagName; IEdge parentEdge = graph.AddEdge(edgeModel.GetType(grgenEdgeTypeName), parentNode.elementNode, gnode); if(IsRefOrdered(parentTypeName, tagName)) { int nextIndex = 0; tagNameToNextIndex.TryGetValue(tagName, out nextIndex); parentEdge.SetAttribute("ordering", nextIndex); tagNameToNextIndex[tagName] = nextIndex + 1; } if(!emptyElem) ParseNodeFirstPass(reader, child, typeName); } }
///<summary> ///getObservation method for retrieving a METAR observation based on parsed ICAO code. No return value, sets this.Metar directly ///</summary> public void getObservation() { try { string itemContent = ""; //Create URL to fetch XML with Observation METAR from Geonames, ICAO code and username is parsed String URLString = "http://api.geonames.org/weatherIcao?ICAO=" + this.ICAO + "&username=mercantec"; XmlTextReader reader = new XmlTextReader(URLString); //Read through the XML while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "observation") { //Found an element named observation reader.ReadToFollowing("observation"); //Read until next observation child element is found itemContent = reader.ReadInnerXml(); //Read the inner xml (content) of the element to the itemContent string variable } else if (reader.Name == "status") { //Found an element named status itemContent = reader.GetAttribute(0); //Status text is defined in xml as the first property of the status element } } this.Metar = itemContent; //Set the object Metar property to the resulting itemContent from the XML parser } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// This checks whether a field is a property backer, meaning /// it stores the information for the property. /// </summary> /// <remarks> /// <para>This takes advantage of the fact that most people /// have a simple convention for the names of the fields /// and the properties that they back. /// If the field doesn't have a summary already, and it /// looks like it backs a property, and the BaseDocumenterConfig /// property is set appropriately, then this adds a /// summary indicating that.</para> /// <para>Note that this design will call multiple fields the /// backer for a single property.</para> /// <para/>This also will call a public field a backer for a /// property, when typically that wouldn't be the case. /// </remarks> /// <param name="writer">The XmlWriter to write to.</param> /// <param name="memberName">The full name of the field.</param> /// <param name="type">The Type which contains the field /// and potentially the property.</param> /// <returns>True only if a property backer is auto-documented.</returns> private bool CheckForPropertyBacker( XmlWriter writer, string memberName, Type type) { if (!this.rep.AutoPropertyBackerSummaries) return false; // determine if field is non-public // (because public fields are probably not backers for properties) bool isNonPublic = true; // stubbed out for now //check whether or not we have a valid summary bool isMissingSummary = true; string xmldoc = assemblyDocCache.GetDoc(memberName); if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "summary") { string summarydetails = reader.ReadInnerXml(); if (summarydetails.Length > 0 && !summarydetails.Trim().StartsWith("Summary description for")) { isMissingSummary = false; } } } } } // only do this if there is no summary already if (isMissingSummary && isNonPublic) { // find the property (if any) that this field backs // generate the possible property names that this could back // so far have: property Name could be backed by _Name or name // but could be other conventions string[] words = memberName.Split('.'); string fieldBaseName = words[words.Length - 1]; string firstLetter = fieldBaseName.Substring(0, 1); string camelCasePropertyName = firstLetter.ToUpper() + fieldBaseName.Remove(0, 1); string usPropertyName = fieldBaseName.Replace("_", ""); // find it PropertyInfo propertyInfo; if (((propertyInfo = FindProperty(camelCasePropertyName, type)) != null) || ((propertyInfo = FindProperty(usPropertyName, type)) != null)) { WritePropertyBackerDocumentation(writer, "summary", propertyInfo); return true; } } return false; }
//if the constructor has no parameters and no summary, //add a default summary text. private bool DoAutoDocumentConstructor( XmlWriter writer, string memberName, ConstructorInfo constructor) { if (rep.AutoDocumentConstructors) { if (constructor.GetParameters().Length == 0) { string xmldoc = assemblyDocCache.GetDoc(memberName); bool bMissingSummary = true; if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "summary") { string summarydetails = reader.ReadInnerXml(); if (summarydetails.Length > 0 && !summarydetails.Trim().StartsWith("Summary description for")) { bMissingSummary = false; } } } } } if (bMissingSummary) { WriteStartDocumentation(writer); writer.WriteStartElement("summary"); if (constructor.IsStatic) { writer.WriteString("Initializes the static fields of the "); } else { writer.WriteString("Initializes a new instance of the "); } writer.WriteStartElement("see"); writer.WriteAttributeString("cref", MemberID.GetMemberID(constructor.DeclaringType)); writer.WriteEndElement(); writer.WriteString(" class."); writer.WriteEndElement(); return true; } } } return false; }
private void CheckForMissingValue( XmlWriter writer, string memberName) { if (this.rep.ShowMissingValues) { string xmldoc = assemblyDocCache.GetDoc(memberName); bool bMissingValues = true; if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "value") { string valuesdetails = reader.ReadInnerXml(); if (valuesdetails.Length > 0) { bMissingValues = false; break; // we can stop if we locate what we are looking for } } } } } if (bMissingValues) { WriteMissingDocumentation(writer, "values", null, "Missing <values> documentation for " + memberName); } } }
private void CheckForMissingReturns( XmlWriter writer, string memberName, MethodInfo method) { if (this.rep.ShowMissingReturns && !"System.Void".Equals(method.ReturnType.FullName)) { string xmldoc = assemblyDocCache.GetDoc(memberName); bool bMissingReturns = true; if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "returns") { string returnsdetails = reader.ReadInnerXml(); if (returnsdetails.Length > 0) { bMissingReturns = false; break; // we can stop if we locate what we are looking for } } } } } if (bMissingReturns) { WriteMissingDocumentation(writer, "returns", null, "Missing <returns> documentation for " + memberName); } } }
private void CheckForMissingParams( XmlWriter writer, string memberName, ParameterInfo[] parameters) { if (this.rep.ShowMissingParams) { string xmldoc = assemblyDocCache.GetDoc(memberName); foreach (ParameterInfo parameter in parameters) { bool bMissingParams = true; if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "param") { string name = reader.GetAttribute("name"); if (name == parameter.Name) { string paramsdetails = reader.ReadInnerXml(); if (paramsdetails.Length > 0) { bMissingParams = false; break; // we can stop if we locate what we are looking for } } } } } } if (bMissingParams) { WriteMissingDocumentation(writer, "param", parameter.Name, "Missing <param> documentation for " + parameter.Name); } } } }
private void CheckForMissingSummaryAndRemarks( XmlWriter writer, string memberName) { if (this.rep.ShowMissingSummaries) { bool bMissingSummary = true; string xmldoc = assemblyDocCache.GetDoc(memberName); if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "summary") { string summarydetails = reader.ReadInnerXml(); if (summarydetails.Length > 0 && !summarydetails.Trim().StartsWith("Summary description for")) { bMissingSummary = false; break; } } } } } if (bMissingSummary) { WriteMissingDocumentation(writer, "summary", null, "Missing <summary> documentation for " + memberName); //Debug.WriteLine("@@missing@@\t" + memberName); } } if (this.rep.ShowMissingRemarks) { bool bMissingRemarks = true; string xmldoc = assemblyDocCache.GetDoc(memberName); if (xmldoc != null) { XmlTextReader reader = new XmlTextReader(xmldoc, XmlNodeType.Element, null); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "remarks") { string remarksdetails = reader.ReadInnerXml(); if (remarksdetails.Length > 0) { bMissingRemarks = false; break; } } } } } if (bMissingRemarks) { WriteMissingDocumentation(writer, "remarks", null, "Missing <remarks> documentation for " + memberName); } } }
/// <summary> /// Main function that retrieves the list from API, including paging /// </summary> /// <param name="url">URL of API request</param> /// <param name="haveSoFar">Number of pages already retrieved, for upper limit control</param> /// <returns>List of pages</returns> public List<Article> ApiMakeList(string url, int haveSoFar) {// TODO: error handling List<Article> list = new List<Article>(); string postfix = ""; string newUrl = url; if (Hack1_12) newUrl = RemoveCmcategory.Replace(newUrl, ""); while (list.Count + haveSoFar < Limit) { string text = Tools.GetHTML(newUrl + postfix); if (text.Contains("code=\"cmtitleandcategory\"")) { if (Hack1_12) throw new ListProviderException("cmtitleandcategory persists."); Hack1_12 = true; newUrl = RemoveCmcategory.Replace(url, ""); text = Tools.GetHTML(newUrl + postfix); } XmlTextReader xml = new XmlTextReader(new StringReader(text)); xml.MoveToContent(); postfix = ""; while (xml.Read()) { if (xml.Name == "query-continue") { XmlReader r = xml.ReadSubtree(); r.Read(); while (r.Read()) { if (!r.IsStartElement()) continue; if (!r.MoveToFirstAttribute()) throw new FormatException("Malformed element '" + r.Name + "' in <query-continue>"); postfix += "&" + r.Name + "=" + HttpUtility.UrlEncode(r.Value); } } else if (PageElements.Contains(xml.Name) && xml.IsStartElement()) { //int ns = -1; //int.TryParse(xml.GetAttribute("ns"), out ns); string name = xml.GetAttribute("title"); if (string.IsNullOrEmpty(name)) { System.Windows.Forms.MessageBox.Show(xml.ReadInnerXml()); break; } // HACK: commented out until we make AWB always load namespaces from the wiki, // to avoid problems with unknown namespace //if (ns >= 0) list.Add(new Article(name, ns)); //else list.Add(new Article(name)); } } if (string.IsNullOrEmpty(postfix)) break; } return list; }
/// <summary> /// Import a Tomboy note file as note content for a new note. /// And set the new note title. /// </summary> /// <param name="reader">The streamreader to read the Tomboy note with.</param> /// <param name="tomboynotefile">The Tomboy note file full filepath and filename.</param> /// <param name="tbTitle">The textbox to set the title in.</param> /// <param name="rtbNewNote">The richedittextbox to set the content in.</param> public void ReadTomboyfile(StreamReader reader, string tomboynotefile, TextBox tbTitle, RichTextBox rtbNewNote) { tbTitle.Text = xmlUtil.GetContentString(tomboynotefile, "title"); rtbNewNote.Clear(); System.Xml.XmlTextReader xmlreader = new System.Xml.XmlTextReader(reader); xmlreader.ProhibitDtd = true; while (xmlreader.Read()) { if (xmlreader.Name == "note-content") { string tomboynotecontent = xmlreader.ReadInnerXml(); bool innode = false; bool begintag = false; int startnodepos = 0; int textpos = 0; List <string> formattype = new List <string>(); List <bool> formatisbegintag = new List <bool>(); List <int> formatstartpos = new List <int>(); for (int i = 0; i < tomboynotecontent.Length; i++) { if (tomboynotecontent[i] == '<' && !innode) { startnodepos = i; innode = true; begintag = true; if (i + 1 <= tomboynotecontent.Length) { if (tomboynotecontent[i + 1] == '/') { begintag = false; } } } else if (tomboynotecontent[i] == '>' && innode) { formatisbegintag.Add(begintag); if (begintag) { string tag = tomboynotecontent.Substring(startnodepos + 1, i - startnodepos - 1); for (int c = 0; c < tag.Length; c++) { if (tag[c] == ' ') { formattype.Add(tag.Substring(0, c)); break; } } formatstartpos.Add(textpos); } else { formattype.Add(tomboynotecontent.Substring(startnodepos + 2, i - startnodepos - 2)); formatstartpos.Add(textpos); } innode = false; } else if (!innode) { rtbNewNote.Text += tomboynotecontent[i]; textpos++; } } RTFDirectEdit rtfdirectedit = new RTFDirectEdit(); int poslastbold = int.MaxValue; int poslastitalic = int.MaxValue; int poslaststrikethrought = int.MaxValue; int poslastsizesmall = int.MaxValue; int poslastsizelarge = int.MaxValue; int poslastsizehuge = int.MaxValue; for (int i = 0; i < formattype.Count; i++) { switch (formattype[i]) { case "bold": if (formatisbegintag[i]) { poslastbold = formatstartpos[i]; } else if (poslastbold != int.MaxValue) { rtbNewNote.Rtf = rtfdirectedit.AddBoldTagInRTF(rtbNewNote.Rtf, poslastbold, formatstartpos[i] - poslastbold); } break; case "italic": if (formatisbegintag[i]) { poslastitalic = formatstartpos[i]; } else if (poslastitalic != int.MaxValue) { rtbNewNote.Rtf = rtfdirectedit.AddItalicTagInRTF(rtbNewNote.Rtf, poslastitalic, formatstartpos[i] - poslastitalic); } break; case "strikethrough": if (formatisbegintag[i]) { poslaststrikethrought = formatstartpos[i]; } else if (poslaststrikethrought != int.MaxValue) { rtbNewNote.Rtf = rtfdirectedit.AddStrikeTagInRTF(rtbNewNote.Rtf, poslaststrikethrought, formatstartpos[i] - poslaststrikethrought); } break; case "size:small": if (formatisbegintag[i]) { poslastsizesmall = formatstartpos[i]; } else if (poslastsizehuge != int.MaxValue) { int textlen = formatstartpos[i] - poslastsizesmall; rtbNewNote.Rtf = rtfdirectedit.SetSizeTagInRtf(rtbNewNote.Rtf, poslastsizesmall, textlen, 9); } break; case "size:large": if (formatisbegintag[i]) { poslastsizelarge = formatstartpos[i]; } else if (poslastsizelarge != int.MaxValue) { int textlen = formatstartpos[i] - poslastsizelarge; rtbNewNote.Rtf = rtfdirectedit.SetSizeTagInRtf(rtbNewNote.Rtf, poslastsizesmall, textlen, 14); } break; case "size:huge": if (formatisbegintag[i]) { poslastsizehuge = formatstartpos[i]; } else if (poslastsizehuge != int.MaxValue) { int textlen = formatstartpos[i] - poslastsizelarge; rtbNewNote.Rtf = rtfdirectedit.SetSizeTagInRtf(rtbNewNote.Rtf, poslastsizesmall, textlen, 16); } break; } } } } }
// Read the contents of the current node, including all markup. public override String ReadInnerXml() { return(reader.ReadInnerXml()); }