/// <summary> /// Creates a byte array from the hexadecimal string. Each two characters are combined /// to create one byte. First two hexadecimal characters become first byte in returned array. /// Non-hexadecimal characters are ignored. /// </summary> /// <param name="hexString">string to convert to byte array</param> /// <param name="discarded">number of characters in string ignored</param> /// <returns>byte array, in the same left-to-right order as the hexString</returns> public static byte[] GetBytes(string hexString, out int discarded) { discarded = 0; // XML Reader/Writer is highly optimized for BinHex conversions // use instead of byte/character replacement for performance on // arrays larger than a few dozen elements hexString = "<node>" + hexString + "</node>"; System.Xml.XmlTextReader tr = new System.Xml.XmlTextReader( hexString, System.Xml.XmlNodeType.Element, null); tr.Read(); System.IO.MemoryStream ms = new System.IO.MemoryStream(); int bufLen = 1024; int cap = 0; byte[] buf = new byte[bufLen]; do { cap = tr.ReadBinHex(buf, 0, bufLen); ms.Write(buf, 0, cap); } while (cap == bufLen); return ms.ToArray(); }
public static TransactionSpecification Deserialize(string xml) { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(TransactionSpecification)); return ((TransactionSpecification)(xmlSerializer.Deserialize(xmlTextReader))); }
public void PhotoInfoParseFull() { string x = "<photo id=\"7519320006\">" + "<location latitude=\"54.971831\" longitude=\"-1.612683\" accuracy=\"16\" context=\"0\" place_id=\"Ke8IzXlQV79yxA\" woeid=\"15532\">" + "<neighbourhood place_id=\"Ke8IzXlQV79yxA\" woeid=\"15532\">Central</neighbourhood>" + "<locality place_id=\"DW0IUrFTUrO0FQ\" woeid=\"20928\">Gateshead</locality>" + "<county place_id=\"myqh27pQULzLWcg7Kg\" woeid=\"12602156\">Tyne and Wear</county>" + "<region place_id=\"2eIY2QFTVr_DwWZNLg\" woeid=\"24554868\">England</region>" + "<country place_id=\"cnffEpdTUb5v258BBA\" woeid=\"23424975\">United Kingdom</country>" + "</location>" + "</photo>"; System.IO.StringReader sr = new System.IO.StringReader(x); System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr); xr.Read(); var info = new PhotoInfo(); ((IFlickrParsable)info).Load(xr); Assert.AreEqual("7519320006", info.PhotoId); Assert.IsNotNull(info.Location); Assert.AreEqual((GeoAccuracy)16, info.Location.Accuracy); Assert.IsNotNull(info.Location.Country); Assert.AreEqual("cnffEpdTUb5v258BBA", info.Location.Country.PlaceId); }
public static void IsolatedStorage_Read_and_Write_Sample() { string fileName = @"SelfWindow.xml"; IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain(); IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write); System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8); writer.WriteStartDocument(); writer.WriteStartElement("Settings"); writer.WriteStartElement("UserID"); writer.WriteValue(42); writer.WriteEndElement(); writer.WriteStartElement("UserName"); writer.WriteValue("kingwl"); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); writer.Close(); storStream.Close(); string[] userFiles = storFile.GetFileNames(); foreach(var userFile in userFiles) { if(userFile == fileName) { var storFileStreamnew = new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read); StreamReader storReader = new StreamReader(storFileStreamnew); System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader); int UserID = 0; string UserName = null; while(reader.Read()) { switch(reader.Name) { case "UserID": UserID = int.Parse(reader.ReadString()); break; case "UserName": UserName = reader.ReadString(); break; default: break; } } Console.WriteLine("{0} {1}", UserID, UserName); storFileStreamnew.Close(); } } storFile.Close(); }
public static SegmentSet Deserialize(string xml) { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SegmentSet)); return ((SegmentSet)(xmlSerializer.Deserialize(xmlTextReader))); }
private void LoadHighlightingDefinition() { var xshdUri = App.GetResourceUri("simai.xshd"); var rs = Application.GetResourceStream(xshdUri); var reader = new System.Xml.XmlTextReader(rs.Stream); definition = HighlightingLoader.Load(reader, HighlightingManager.Instance); reader.Close(); }
///<summary> ///Create a full copy of the current properties ///</summary> public MySection Copy() { MySection copy = new MySection(); string xml = SerializeSection(this, "MySection", ConfigurationSaveMode.Full); System.Xml.XmlReader rdr = new System.Xml.XmlTextReader(new System.IO.StringReader(xml)); copy.DeserializeSection(rdr); return copy; }
static public string[] NameAndCasNmber(string compoundName) { string[] retVal = new string[2]; gov.nih.nlm.chemspell.SpellAidService service = new gov.nih.nlm.chemspell.SpellAidService(); string response = service.getSugList(compoundName, "All databases"); var XMLReader = new System.Xml.XmlTextReader(new System.IO.StringReader(response)); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Synonym)); if (serializer.CanDeserialize(XMLReader)) { Synonym synonym = (Synonym)serializer.Deserialize(XMLReader); foreach (SynonymChemical chemical in synonym.Chemical) { int result = String.Compare(compoundName, chemical.Name, true); if (result == 0) { retVal[0] = chemical.CAS; retVal[1] = chemical.Name; return retVal; } } } serializer = new System.Xml.Serialization.XmlSerializer(typeof(SpellAid)); if (serializer.CanDeserialize(XMLReader)) { SpellAid aid = (SpellAid)serializer.Deserialize(XMLReader); bool different = true; retVal[0] = aid.Chemical[0].CAS; retVal[1] = aid.Chemical[0].Name; for (int i = 0; i < aid.Chemical.Length - 1; i++) { if (retVal[0] != aid.Chemical[i + 1].CAS) { different = false; retVal[0] = aid.Chemical[i].CAS; retVal[1] = aid.Chemical[i].Name; } } if (!different) { foreach (SpellAidChemical chemical in aid.Chemical) { int result = String.Compare(compoundName, 0, chemical.Name, 0, compoundName.Length, true); if (result == 0 && compoundName.Length >= chemical.Name.Length) { retVal[0] = chemical.CAS; retVal[1] = chemical.Name; return retVal; } } SelectChemicalForm form = new SelectChemicalForm(aid, compoundName); form.ShowDialog(); retVal[0] = form.SelectedChemical.CAS; retVal[1] = form.SelectedChemical.Name; return retVal; } } return retVal; }
public XmlActionResult GetXmlData() { LogInfo(); System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("~/Book.xml")); var xml = XElement.Load(reader); return new XmlActionResult(xml.ToString(), "book.xml"); }
public override WebServiceResponse Unmarshall(XmlUnmarshallerContext context) { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(context.ResponseStream); BatchReceiveMessageResponse batchReceiveMessageResponse = new BatchReceiveMessageResponse(); Message message = null; while (reader.Read()) { switch (reader.NodeType) { case System.Xml.XmlNodeType.Element: switch (reader.LocalName) { case MNSConstants.XML_ROOT_MESSAGE: message = new Message(); break; case MNSConstants.XML_ELEMENT_MESSAGE_ID: message.Id = reader.ReadElementContentAsString(); break; case MNSConstants.XML_ELEMENT_RECEIPT_HANDLE: message.ReceiptHandle = reader.ReadElementContentAsString(); break; case MNSConstants.XML_ELEMENT_MESSAGE_BODY_MD5: message.BodyMD5 = reader.ReadElementContentAsString(); break; case MNSConstants.XML_ELEMENT_MESSAGE_BODY: message.Body = reader.ReadElementContentAsString(); break; case MNSConstants.XML_ELEMENT_ENQUEUE_TIME: message.EnqueueTime = AliyunSDKUtils.ConvertFromUnixEpochSeconds(reader.ReadElementContentAsLong()); break; case MNSConstants.XML_ELEMENT_NEXT_VISIBLE_TIME: message.NextVisibleTime = AliyunSDKUtils.ConvertFromUnixEpochSeconds(reader.ReadElementContentAsLong()); break; case MNSConstants.XML_ELEMENT_FIRST_DEQUEUE_TIME: message.FirstDequeueTime = AliyunSDKUtils.ConvertFromUnixEpochSeconds(reader.ReadElementContentAsLong()); break; case MNSConstants.XML_ELEMENT_DEQUEUE_COUNT: message.DequeueCount = (uint)reader.ReadElementContentAsInt(); break; case MNSConstants.XML_ELEMENT_PRIORITY: message.Priority = (uint)reader.ReadElementContentAsInt(); break; } break; case System.Xml.XmlNodeType.EndElement: if (reader.LocalName == MNSConstants.XML_ROOT_MESSAGE) { batchReceiveMessageResponse.Messages.Add(message); } break; } } reader.Close(); return batchReceiveMessageResponse; }
/// <summary> /// Currently a naive implementation. Treats all fields under summary as text. /// </summary> /// <param name="xmlDocumentation"></param> /// <returns></returns> public string GetSummary(string xmlDocumentation) { var frag = new System.Xml.XmlTextReader(xmlDocumentation, System.Xml.XmlNodeType.Element, null); string result = ""; while (frag.Read()) { result += frag.Value; } frag.Close(); return result; }
/// <summary> /// loads a configuration from a xml-file - if there isn't one, use default settings /// </summary> public void ReadSettings() { bool dirty = false; Reset(); try { System.Xml.XmlTextReader xmlConfigReader = new System.Xml.XmlTextReader("settings.xml"); while (xmlConfigReader.Read()) { if (xmlConfigReader.NodeType == System.Xml.XmlNodeType.Element) { switch (xmlConfigReader.Name) { case "display": fullscreen = Convert.ToBoolean(xmlConfigReader.GetAttribute("fullscreen")); resolutionX = Convert.ToInt32(xmlConfigReader.GetAttribute("resolutionX")); resolutionY = Convert.ToInt32(xmlConfigReader.GetAttribute("resolutionY")); // validate resolution // TODO /* if (!GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Any(x => x.Format == SurfaceFormat.Color && x.Height == resolutionY && x.Width == resolutionX)) { ChooseStandardResolution(); dirty = true; } */ break; } } } xmlConfigReader.Close(); } catch { // error in xml document - write a new one with standard values try { Reset(); dirty = true; } catch { } } // override fullscreen resolutions if (fullscreen) { ResolutionX = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width; ResolutionY = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height; } if(dirty) Save(); }
private void Collection_Loaded(object sender, RoutedEventArgs e) { using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("a7DocumentDbStudio.Resources.avalonEditSql.xshd")) { using (var reader = new System.Xml.XmlTextReader(stream)) { this.sqlEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); } } }
public void TestADOTabularCSDLVisitor() { ADOTabularConnection c = new ADOTabularConnection("Data Source=localhost", AdomdType.AnalysisServices); MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(c); ADOTabularModel m = new ADOTabularModel(c, "Test","Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl.xml"); var tabs = new ADOTabularTableCollection(c,m); v.GenerateTablesFromXmlReader(tabs, xr); Assert.AreEqual(4, tabs.Count); Assert.AreEqual(8, tabs["Sales"].Columns.Count()); }
public SettingsServer(string profileFolderName, string profileDisplayName) { InitValues(); ProfileFolderName = profileFolderName; ProfileDisplayName = profileDisplayName; try { if (!Directory.Exists(ProfileFolder)) Directory.CreateDirectory(ProfileFolder); foreach (string path in new string[] { ProfileFolder, StoreToFileFolder }) { try { if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path); } catch (System.Exception ex) { GenLib.Log.LogService.LogException("Unable to create folder: " + path + "\nError: ", ex); } } if (File.Exists(Path.Combine(ProfileFolder, SettingsFileName))) { lock (lockObj) { using (System.Xml.XmlTextReader input = new System.Xml.XmlTextReader(Path.Combine(ProfileFolder, SettingsFileName))) { XmlSerializer serializer = new XmlSerializer(typeof(SettingsServer)); SettingsServer sett = (SettingsServer)serializer.Deserialize(input); InitValues(sett); } } } else { // since this is the first time we are loading this profile (settings don't exist yet) // create a new version file so that we know what version of data is contained in this folder WriteVersionData(ProfileFolder); SaveSettings(); } } catch (Exception ex) { GenLib.Log.LogService.LogException("Settings. LoadSettings failed.", ex); } try { File.Create(Path.Combine(ProfileFolder, "ProfileName-" + profileDisplayName + ".txt")); } // try creating the filename containing the profile name catch // if there are invalid chars then create a file and inside of it put the profile name { try { File.WriteAllText(Path.Combine(ProfileFolder, "ProfileName.txt"), profileDisplayName); } catch { } } }
// Lecture de la configuration static void ReadConfig() { string config_file = "config.xml"; if (!System.IO.File.Exists(config_file)) { var newconf = new System.Xml.XmlTextWriter(config_file, null); newconf.WriteStartDocument(); newconf.WriteStartElement("config"); newconf.WriteElementString("last_update", "0"); newconf.WriteElementString("auth_token", ""); newconf.WriteEndElement(); newconf.WriteEndDocument(); newconf.Close(); } var conf = new System.Xml.XmlTextReader(config_file); string CurrentElement = ""; while (conf.Read()) { switch(conf.NodeType) { case System.Xml.XmlNodeType.Element: CurrentElement = conf.Name; break; case System.Xml.XmlNodeType.Text: if (CurrentElement == "last_update") LastUpdate = DateTime.Parse(conf.Value); if (CurrentElement == "auth_token") AuthToken = conf.Value; break; } } conf.Close(); // On vérifie que le token est encore valide if (AuthToken.Length > 0) { var flickr = new Flickr(Program.ApiKey, Program.SharedSecret); try { Auth auth = flickr.AuthCheckToken(AuthToken); Username = auth.User.UserName; } catch (FlickrApiException ex) { //MessageBox.Show(ex.Message, "Authentification requise", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); AuthToken = ""; } } }
public AppSettings() { this.ProxySettings = new Proxy(); this.PathSettings = new PathSetting(); string proxySettingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperProxySettings.xml"; string pathSettingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperPathSettings.xml"; try { if (System.IO.File.Exists(proxySettingsFile)) { using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(proxySettingsFile)) { while (reader.Read()) { if (reader.Name == "ProxySettings") { this.ProxySettings.Server = reader[0]; this.ProxySettings.Port = reader[1]; this.ProxySettings.User = reader[2]; this.ProxySettings.Password = reader[3]; this.ProxySettings.UseProxy = Convert.ToBoolean(reader[4]); } } } } if (System.IO.File.Exists(pathSettingsFile)) { using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(pathSettingsFile)) { while (reader.Read()) { if (reader.Name == "PathSettings") { this.PathSettings.Path = reader[0]; this.PathSettings.CreateFolder = Boolean.Parse(reader[1]); } } } } } catch (Exception) { } }
public void PhotoInfoLocationParseShortTest() { string x = "<photo id=\"7519320006\">" + "<location latitude=\"-23.32\" longitude=\"-34.2\" accuracy=\"10\" context=\"1\" />" + "</photo>"; System.IO.StringReader sr = new System.IO.StringReader(x); System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr); xr.Read(); var info = new PhotoInfo(); ((IFlickrParsable)info).Load(xr); Assert.AreEqual("7519320006", info.PhotoId); Assert.IsNotNull(info.Location); Assert.AreEqual((GeoAccuracy)10, info.Location.Accuracy); }
public static int LoadTemplate(ref string err, ref DataSet rmdb, string file) { DataTable rmdb_set = new DataTable("fields"); rmdb_set.Columns.Add("id"); rmdb_set.Columns.Add("type"); rmdb_set.Columns.Add("value"); try { System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader( file ); string contents = ""; while (xmlReader.Read()) { xmlReader.MoveToContent(); string xmlId = null; string xmlType = null; string xmlValue = null; if (xmlReader.NodeType == System.Xml.XmlNodeType.Element) { // contents += "ELEMENT <"+xmlReader.Name + ">\n"; if (xmlReader.HasAttributes) { // contents += "Attributes of <" + xmlReader.Name + ">\n"; for (int i = 0; i < xmlReader.AttributeCount; i++) { // contents += xmlReader[i]; if (i == 0) xmlId = xmlReader[i]; if (i == 1) xmlType = xmlReader[i]; } } } if (xmlReader.NodeType == System.Xml.XmlNodeType.Text) { //contents += "TEXT " + xmlReader.Value + "\n"; xmlValue = xmlReader.Value; } // populate internal database if (xmlId != null && xmlType != null) { rmdb_set.Rows.Add(xmlId, xmlType, xmlValue); Console.Write(xmlId, xmlType, xmlValue); } } Console.Write(contents); rmdb.Tables.Add(rmdb_set); return 0; } catch (Exception e) { err = e.Source.ToString() + ": " + e.Message.ToString(); return 1; } }
private void button1_Click(object sender, EventArgs e) { System.IO.StreamReader sr = new System.IO.StreamReader(@"cars.xml"); System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr); System.Xml.XmlDocument carCollectionDoc = new System.Xml.XmlDocument(); carCollectionDoc.Load(xr); linkLabel1.Text = carCollectionDoc.InnerText; linkLabel2.Text = "First child node: " + carCollectionDoc.FirstChild.InnerText; linkLabel3.Text = "Second child node: " + carCollectionDoc.FirstChild.NextSibling.InnerText; System.Xml.XmlNode carcollection = carCollectionDoc.FirstChild.NextSibling; linkLabel4.Text = "Now that we have a reference to 'carcollection': " + carcollection.FirstChild.InnerText; linkLabel5.Text = "First child of collection: " + carcollection.FirstChild.InnerText; linkLabel6.Text = "First child of the first child of carcollection: " + carcollection.FirstChild.FirstChild.InnerText; System.Xml.XmlNodeList carCollectionItems = carCollectionDoc.SelectNodes("carcollection/car"); System.Xml.XmlNode make = carCollectionItems.Item(0).SelectSingleNode("make"); linkLabel7.Text = "make.InnerText: " + make.InnerText; }
public static void DoPreview(string title, System.Windows.Media.Visual visual) { string fileName = System.IO.Path.GetTempFileName(); try { // write the XPS document using (XpsDocument doc = new XpsDocument(fileName, FileAccess.ReadWrite)) { XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc); writer.Write(visual); } // Read the XPS document into a dynamically generated // preview Window using (XpsDocument doc = new XpsDocument(fileName, FileAccess.Read)) { FixedDocumentSequence fds = doc.GetFixedDocumentSequence(); string s = _previewWindowXaml; s = s.Replace("@@TITLE", title.Replace("'", "'")); using (var reader = new System.Xml.XmlTextReader(new StringReader(s))) { Window preview = System.Windows.Markup.XamlReader.Load(reader) as Window; DocumentViewer dv1 = LogicalTreeHelper.FindLogicalNode(preview, "dv1") as DocumentViewer; dv1.Document = fds as IDocumentPaginatorSource; preview.ShowDialog(); } } } finally { if (File.Exists(fileName)) { try { File.Delete(fileName); } catch//temporary file anyway so doesn't matter if can't delete { } } } }
public static List<ReturnsEval.DataSeriesEvaluator> GetEvalListFromArgs(string[] argsList_) { List<ReturnsEval.DataSeriesEvaluator> list = new List<ReturnsEval.DataSeriesEvaluator>(); foreach (string s in argsList_) { if (System.IO.Directory.Exists(s)) { foreach (string path in System.IO.Directory.GetFiles(s)) { ReturnsEval.DataSeriesEvaluator ev = ReturnsEval.DataSeriesEvaluator.ReadFromDisk(path); if (ev != null) list.Add(ev); KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator> kvp = ExtensionMethods.ReadFromDisk<KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator>>(path); if (kvp.Value != null) list.Add(kvp.Value); } } else if (System.IO.File.Exists(s)) { if (s.EndsWith(".xml")) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(string.Format(@"file://{0}", s.Replace(@"\", "/"))); reader.MoveToContent(); doc.Load(reader); reader.Close(); foreach (System.Xml.XmlNode node in doc.DocumentElement.SelectNodes("BloombergTicker")) { DatedDataCollectionGen<double> hist = BbgTalk.HistoryRequester.GetHistory(new DateTime(2000, 1, 1), node.InnerText, "PX_LAST", true); DatedDataCollectionGen<double> genHist = new DatedDataCollectionGen<double>(hist.Dates, hist.Data).ToReturns(); BbgTalk.RDResult nameData = BbgTalk.HistoryRequester.GetReferenceData(node.InnerText, "SHORT_NAME", null); ReturnsEval.DataSeriesEvaluator eval = new ReturnsEval.DataSeriesEvaluator(genHist.Dates, genHist.Data, nameData["SHORT_NAME"].GetValue<string>(), ReturnsEval.DataSeriesType.Returns); list.Add(eval); } } else { ReturnsEval.DataSeriesEvaluator ev = ReturnsEval.DataSeriesEvaluator.ReadFromDisk(s); if (ev != null) list.Add(ev); KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator> kvp = SI.ExtensionMethods.ReadFromDisk<KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator>>(s); if (kvp.Value != null) list.Add(kvp.Value); } } } return list; }
public ICollection<ProjectConstraint> GetDefaultContraints() { authorizationService.VerifyRequestAuthorizationToken(); ProjectConstraint[] constraints = new ProjectConstraint[0]; string path = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "Templates\\default-constraints.xml"; try { using (var f = new System.IO.FileStream(path, System.IO.FileMode.Open)) { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(f); System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(ProjectConstraint[])); constraints = (ProjectConstraint[])s.Deserialize(reader); } } catch (Exception ex) { ScrumFactory.Services.Logic.Helper.Log.LogError(ex); } return constraints; }
public static void loadData() { var file = "austria-latest.osm"; using (var fs = System.IO.File.OpenRead(file)) { using (var xml = new System.Xml.XmlTextReader(fs)) { while (xml.Read()) { if (xml.NodeType == System.Xml.XmlNodeType.Element && xml.Name == "osm") { parseOsm(xml); } } } // read from file } // open from file lastRefresh = DateTime.Now; }
/// <summary> /// Deserializes workflow markup into an ArrayOfMyElement object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output ArrayOfMyElement object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out ArrayOfMyElement obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(ArrayOfMyElement)); obj = ((ArrayOfMyElement)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public void TestCSDLDisplayFolders() { ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(c); ADOTabularModel m = new ADOTabularModel(c, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrksFoldersCsdl.xml"); var tabs = new ADOTabularTableCollection(c, m); v.GenerateTablesFromXmlReader(tabs, xr); var cmpyTab = tabs["Internet Sales"]; var cmpyCol = cmpyTab.Columns["Internet Current Quarter Sales"]; var cmpyCol2 = cmpyTab.Columns["Internet Current Quarter Margin"]; Assert.AreEqual("Internet Sales", cmpyTab.Caption, "Table Name is correct"); Assert.AreEqual("QTD Folder", cmpyCol2.DisplayFolder, "Column has display folder"); Assert.AreEqual("QTD Folder", cmpyCol.DisplayFolder, "Column has display folder"); }
public void TestCSDLDisplayFolders() { MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrksFoldersCsdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); var cmpyTab = tabs["Internet Sales"]; var cmpyCol = cmpyTab.Columns["Internet Current Quarter Sales"]; var cmpyCol2 = cmpyTab.Columns["Internet Current Quarter Margin"]; Assert.AreEqual("Internet Sales", cmpyTab.Caption, "Table Name is correct"); Assert.AreEqual("QTD Folder", cmpyTab.FolderItems[0].Name); Assert.AreEqual(8, ((IADOTabularFolderReference)cmpyTab.FolderItems[0]).FolderItems.Count); }
public void TestPowerBIVariationsVisitor() { //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object; MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); var promoTable = tabs["Promotion"]; Assert.IsNotNull(promoTable); Assert.AreEqual(0, promoTable.Columns["PromotionName"].Variations.Count); Assert.AreEqual(1, promoTable.Columns["StartDate"].Variations.Count); }
public void PhotoInfoLocationParseShortTest() { const string xml = "<photo id=\"7519320006\">" + "<location latitude=\"-23.32\" longitude=\"-34.2\" accuracy=\"10\" context=\"1\" />" + "</photo>"; var sr = new System.IO.StringReader(xml); var xr = new System.Xml.XmlTextReader(sr); xr.Read(); var info = new PhotoInfo(); ((IFlickrParsable)info).Load(xr); Assert.AreEqual("7519320006", info.PhotoId); Assert.IsNotNull(info.Location); Assert.AreEqual((GeoAccuracy)10, info.Location.Accuracy); }
/// <summary> /// Gets a token sequence from the TextReader /// </summary> /// <param name="reader"></param> /// <returns></returns> public IEnumerable <Token <MarkupTokenType> > GetTokens(TextReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } var xmlReader = System.Xml.XmlReader.Create(reader, this.Settings); #if !SILVERLIGHT System.Xml.XmlTextReader xmlTextReader = xmlReader as System.Xml.XmlTextReader; if (xmlTextReader != null) { xmlTextReader.Normalization = false; xmlTextReader.WhitespaceHandling = System.Xml.WhitespaceHandling.All; } #endif return(this.GetTokens(xmlReader)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ConsultaDirectaManager.Resources.sql.xshd")) { using (var reader = new System.Xml.XmlTextReader(stream)) { txtSQL.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ConsultaDirectaManager.Resources.ini.xshd")) { using (var reader = new System.Xml.XmlTextReader(stream)) { txtCfg.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } }
public void TestADOTabularCSDLVisitorMeasures() { //var c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); var v = new MetaDataVisitorCSDL(connection); var m = new ADOTabularModel(connection, "AdventureWorks", "AdventureWorks", "Test AdventureWorks", ""); var tabs = new ADOTabularTableCollection(connection, m); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml"); //ADOTabularModel m = new ADOTabularModel(connection, "Test", "Test Caption", "Test Description", ""); //var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); foreach (var table in tabs) { var measures = table.Measures; } }
public void LoadFromFile(string FilePath) { if (FilePath.Length == 0) { FilePath = m_FilePath; } System.Xml.XmlTextReader xml = new System.Xml.XmlTextReader(FilePath); try { LoadFromXml(xml); xml.Close(); } catch (Exception x) { xml.Close(); throw new Exception("Unable to load job definition file '" + FilePath + "'. " + x.ToString()); } m_FilePath = FilePath; }
public static DocsPAWA.DocsPaWR.FiltroRicerca[][] StringToFilters(string filtriRicerca) { DocsPaWR.FiltroRicerca[][] outcome = null; try { Type t = typeof(DocsPAWA.DocsPaWR.FiltroRicerca[][]); System.Xml.Serialization.XmlSerializer _serializer = new System.Xml.Serialization.XmlSerializer(t); System.IO.StringReader sr = new System.IO.StringReader(filtriRicerca); System.Xml.XmlTextReader _reader = new System.Xml.XmlTextReader(sr); outcome = ((DocsPAWA.DocsPaWR.FiltroRicerca[][])(_serializer.Deserialize(_reader))); } catch { Console.WriteLine("Fallita deserializzazione dei criteri di ricerca"); } return(outcome); }
public static SarcFileLocation GetFileLocation(string sarc_full_name, string relative_path) { if (SarcCatalog == null || SarcCatalog.Count > 100000) { SarcCatalog = new Dictionary <string, SarcFileLocation>(); } if (!SarcCatalog.ContainsKey(relative_path)) { Stream stream = new FileStream(sarc_full_name, FileMode.Open, FileAccess.Read); //stream.Seek(prologLength, SeekOrigin.Begin); long offset = 0L; for (int i = 0; i < 16; i++) { int b = stream.ReadByte(); if (b != 0) { offset = offset * 10 + (b - '0'); } } byte[] catalog_bytes = new byte[offset - 16]; var v = stream.Read(catalog_bytes, 0, (int)(offset - 16)); MemoryStream mem = new MemoryStream(catalog_bytes); //Encoding etable = Encoding.UTF8; //XElement cat = XElement.Parse(etable.GetString(catalog_bytes)); System.Xml.XmlReader xreader = new System.Xml.XmlTextReader(mem); //XElement catalog = XElement.Load(new StreamReader(stream, System.Text.Encoding.UTF8)); XElement catalog = XElement.Load(xreader); stream.Close(); foreach (XElement xfile in catalog.Elements("file")) { string r_path = xfile.Element("path").Value; SarcFileLocation sfl = new SarcFileLocation() { relative_path = r_path, sarc_full_name = sarc_full_name, file_offset = Int64.Parse(xfile.Element("start").Value) + offset, file_length = Int64.Parse(xfile.Element("length").Value) }; SarcCatalog.Add(r_path, sfl); } } return(SarcCatalog[relative_path]); }
public static IEnumerable <Entity> ReadRow(System.Xml.XmlTextReader r) { Entity lastEntity = null; while (r.Read()) { if (r.NodeType == System.Xml.XmlNodeType.Element) { if (r.Name.ToLower().Equals("row")) { if (lastEntity != null) { if (r.Depth == lastEntity.Depth) { yield return(lastEntity); lastEntity = ReadRow(null, r); } else { ReadRow(lastEntity, r); } } else { lastEntity = ReadRow(null, r); } } else { if (lastEntity != null && (r.Depth == lastEntity.Depth + 1)) { ReadRow(lastEntity, r); } } } } if (lastEntity != null) { yield return(lastEntity); } }
static private bool ExecuteReplaceAction(string inputDir, string inputName, string templateFilename, string outputFilename) { var xmlReader = new System.Xml.XmlTextReader(templateFilename); xmlReader.Namespaces = false; System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.Load(xmlReader); // delete xmlns attribute first var xmlns = xmlDocument.DocumentElement.GetAttribute("xmlns"); xmlDocument.DocumentElement.RemoveAttribute("xmlns"); var filelist = FormatCompileIncludes(inputDir, inputName); if (!ReplaceItemGroup(xmlDocument, filelist)) { return(false); } if (xmlns != null && xmlns.Length > 0) { xmlDocument.DocumentElement.SetAttribute("xmlns", xmlns); } var ProjectGuid = xmlDocument.SelectSingleNode("Project/PropertyGroup/ProjectGuid"); if (ProjectGuid != null) { ProjectGuid.InnerText = "{" + projectGuid + "}"; } if (System.IO.File.Exists(outputFilename)) { System.IO.File.Delete(outputFilename); } xmlDocument.Save(outputFilename); return(true); }
public void TestPowerBIOrderByVisitor() { //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object; MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); var localDateTable = tabs["LocalDateTable_697ceb23-7c16-46b1-a1ed-0100727de4c7"]; Assert.IsNotNull(localDateTable); Assert.AreEqual(localDateTable.Columns["MonthNo"], localDateTable.Columns["Month"].OrderBy); Assert.AreEqual(localDateTable.Columns["QuarterNo"], localDateTable.Columns["Quarter"].OrderBy); Assert.IsNull(localDateTable.Columns["Year"].OrderBy); }
public static System.Xml.XmlDocument GetReport(string reportPath) { // http://blogs.msdn.com/b/tolong/archive/2007/11/15/read-write-xml-in-memory-stream.aspx System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); // doc.Load(memorystream); // doc.Load(FILE_NAME); // doc.Load(strFileName); using (System.IO.Stream strm = System.IO.File.OpenRead(reportPath)) { using (System.Xml.XmlTextReader xtrReader = new System.Xml.XmlTextReader(strm)) { doc.Load(xtrReader); xtrReader.Close(); } // End Using xtrReader } // End Using strm return(doc); } // End Function GetReport
private static List <string> GetCitiesFromNodes(System.Xml.XmlTextReader xml, string street) { var cities = new List <string>(); using (var osm = xml.ReadSubtree()) { while (osm.Read()) { if (osm.NodeType == System.Xml.XmlNodeType.Element && (osm.Name == "node")) { var pair = GetCityAndStreet(osm); if (pair.Count == 2 && pair[1].ToLower() == street && !cities.Contains(pair[0])) { cities.Add(pair[0]); } } } } return(cities); }
public void TestPowerBIModelCapabilities() { //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object; MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); Assert.AreEqual(true, m.Capabilities.DAXFunctions.SubstituteWithIndex); Assert.AreEqual(true, m.Capabilities.DAXFunctions.SummarizeColumns); Assert.AreEqual(true, m.Capabilities.DAXFunctions.TreatAs); Assert.AreEqual(true, m.Capabilities.Variables); Assert.AreEqual(true, m.Capabilities.TableConstructor); }
public void TestADOTabularCSDLVisitorKPI() { ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(c); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml"); ADOTabularModel m = new ADOTabularModel(c, "Test", "Test Caption", "Test Description", ""); var tabs = new ADOTabularTableCollection(c, m); v.GenerateTablesFromXmlReader(tabs, xr); Assert.AreEqual(15, tabs.Count); Assert.AreEqual(24, tabs["Sales Territory"].Columns.Count()); Assert.AreEqual(1, tabs["Sales Territory"].Columns.Where((t) => t.ColumnType == ADOTabularColumnType.Hierarchy).Count()); var k = tabs["Sales Territory"].Columns["Total Current Quarter Sales Performance"] as ADOTabularKpi; Assert.AreEqual("Total Current Quarter Sales Performance", k.Caption); Assert.AreEqual("_Total Current Quarter Sales Performance Goal", k.Goal.Caption); Assert.AreEqual("_Total Current Quarter Sales Performance Status", k.Status.Caption); }
public static System.Xml.XmlDocument LoadFile(string xmlFileName, System.Xml.XmlDocument xsdDoc) { System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); System.Xml.XmlTextReader textReader = null; System.Xml.XmlValidatingReader validReader; xsdDoc = null; try { xmlFileName = xmlFileName; textReader = new System.Xml.XmlTextReader(xmlFileName); validReader = new System.Xml.XmlValidatingReader(textReader); validReader.ValidationType = System.Xml.ValidationType.Schema; xmlDoc.Load(validReader); } finally { textReader.Close(); } return(xmlDoc); }
public ShaderEditControl() { TextChanged += OnTextChanged; this.Options = new ICSharpCode.AvalonEdit.TextEditorOptions() { ConvertTabsToSpaces = true, EnableHyperlinks = true, EnableRectangularSelection = true, IndentationSize = 3, InheritWordWrapIndentation = true, RequireControlModifierForHyperlinkClick = true, }; using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("D3DLab.Debugger.Resources.ShaderSyntaxDef.xshd")) { using (var reader = new System.Xml.XmlTextReader(resource)) { this.SyntaxHighlighting = HighlightingLoader.Load(HighlightingLoader.LoadXshd(reader), HighlightingManager.Instance); } } }
public static Dictionary <String, String> ReadRegionalSettings(System.Xml.XmlTextReader r) { while (r.Read()) { if (r.NodeType == System.Xml.XmlNodeType.Element) { if (r.Name.ToLower().Equals("regionalsettings")) { Entity rs = ReadRow(null, r); return(rs.Attributes); } if (r.Name.ToLower().Equals("rows")) { return(null); } } } return(null); }
// public bool XMLFileExist // { // get // { // return System.IO.File.Exists(filename); // } // } /// <summary> /// Reads the XML file. /// </summary> /// <param name="myData">My data.</param> /// <param name="filename">The filename.</param> public void readXMLFile(DataSet myData, string filename) { //Create the FileStream to read from. myFileStream = new System.IO.FileStream(filename, System.IO.FileMode.Open); System.Xml.XmlTextReader myXmlReader; //Create an XmlTextWriter with the fileStream. myXmlReader = new System.Xml.XmlTextReader(myFileStream); try { myData.ReadXml(myXmlReader); } catch (Exception ex) { throw ex; } finally { myXmlReader.Close(); } }
public static DisplayItem DeSerializeToObject(string st, Type type) { var serializer = new DataContractSerializer(type); DisplayItem item = null; using (var backing = new System.IO.StringReader(st)) { try { using (var reader = new System.Xml.XmlTextReader(backing)) { item = serializer.ReadObject(reader) as DisplayItem; } } catch { } } return(item); }
/// <summary> /// Traverses the provided OSM file and creates a replica of the content within the Cities Dictionary /// </summary> public static void Update() { lock (Castle) { using (var fs = File.OpenRead(OsmFile)) using (var xml = new System.Xml.XmlTextReader(fs)) { while (xml.Read()) { if (xml.NodeType == System.Xml.XmlNodeType.Element && xml.Name == "osm") { Cities.Clear(); IsUpdated = false; FillCitiesDictionary(xml); IsUpdated = true; } } } } }
private void RegisterHighlightingDefinitions() { var assembly = Assembly.GetExecutingAssembly(); var definitionNames = assembly.GetManifestResourceNames() .Where(x => x.EndsWith(".xshd")); foreach (var fullName in definitionNames) { using var stream = assembly.GetManifestResourceStream(fullName); using var reader = new System.Xml.XmlTextReader(stream); var name = fullName.Split('.').Extract(s => s[s.Length - 2]); HighlightingManager.Instance.RegisterHighlighting( name, new string[0], HighlightingLoader.Load(reader, HighlightingManager.Instance) ); } }
protected void service2_btn(object sender, EventArgs e) { var url = "http://webstrar30.fulton.asu.edu/page3/Service1.svc/findNearestTransportStation/"; url += service2_input1.Text; System.Xml.XmlTextReader xmlreader = new System.Xml.XmlTextReader(url); while (xmlreader.Read()) { if (xmlreader.NodeType == System.Xml.XmlNodeType.Text) { foreach (var s in xmlreader.Value) { service2_outputbox.Text += s.ToString(); } } } }
public void TestPowerBITomModel_CSDL_2_0() { //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object; MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); Assert.IsNotNull(m.TOMModel); Assert.AreEqual(13, m.TOMModel.Tables.Count, "Table Counts are equal"); Assert.AreEqual(tabs["ProductCategory"].Columns.Count, m.TOMModel.Tables["ProductCategory"].Columns.Count, "ProductCategory column counts are equal"); Assert.AreEqual(tabs["Sales"].Relationships.Count, m.TOMModel.Relationships.Count(r => r.FromTable.Name == "Sales"), "Sales table relationships are equal"); Assert.AreEqual(2, m.TOMModel.Tables["Sales"].Measures.Count, "Sales table measure counts are equal"); }
public static int LoadConfig(ref string err, ref Hashtable settings, string file) { try { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader( file ); string contents = ""; while (reader.Read()) { reader.MoveToContent(); if (reader.NodeType == System.Xml.XmlNodeType.Element) contents += "<"+reader.Name + ">\n"; if (reader.NodeType == System.Xml.XmlNodeType.Text) contents += reader.Value + "\n"; } Console.Write(contents); return 0; } catch (Exception e) { err = e.Source.ToString() + ": " + e.Message.ToString(); return 1; } }
/// <summary> /// Occurs before a form is displayed for the first time. /// Contains code to update read an XML file and update /// the text of some form controls. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An EventArgs that contains the event data.</param> private void Form1_Load(object sender, System.EventArgs e) { // Set the default fonts for the header and text. headerFont = new Font("Arial", 14); bodyFont = new Font("Arial", 10); // Update the form controls to display the default font settings. headerFontDefinition.Text = headerFont.ToString(); bodyFontDefinition.Text = bodyFont.ToString(); // Perform the reading of the data file within a try block in case // the data file doesn't exist or an error is encountered reading the file. try { // The XmlTextReader reads the specified XML file and provides a way to // scroll through the data elements. xmlReader = new System.Xml.XmlTextReader("..\\..\\..\\Misc\\ReportData.xml"); // Call the Read method in order to position the reader at the // first element. xmlReader.Read(); // Show the entire contents of the data file in // a textbox for comparison to the printed report. reportData.Text = xmlReader.ReadOuterXml(); // Closes the XmlReader. xmlReader.Close(); } catch (Exception ex) { // An error was encountered opening or reading the data file. // Display an appropriate message to the user. MessageBox.Show("Error opening file: \r\n" + ex.Message); // Close the form since a report can't be printed without access // to the data file. this.Close(); } }
public void CreateEditor() { this.editor = new ICSharpCode.AvalonEdit.TextEditor(); using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Program.BasePath + "config/squirrel.xshd")) { try { this.editor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); } catch (System.IO.FileNotFoundException) { this.WriteToConsole("Could not read syntax highlighter definitions file."); } } editor.TextChanged += delegate(object s, System.EventArgs args) { this.EditorTextChanged(); }; editor.TextArea.TextEntered += delegate(object s, System.Windows.Input.TextCompositionEventArgs args) { this.EditorTextChanged(); }; this.RegisterCompletionEvents(); this.editor.FontFamily = new System.Windows.Media.FontFamily("Consolas, Courier New"); this.editor.WordWrap = false; this.editor.ShowLineNumbers = true; this.editor.FontSize = 13; // code folding foldingManager = ICSharpCode.AvalonEdit.Folding.FoldingManager.Install(editor.TextArea); foldingStrategy = new AvalonEdit.Sample.BraceFoldingStrategy(); this.foldingStrategy.UpdateFoldings(this.foldingManager, this.editor.Document); this.editorHost.Child = this.editor; }
protected void Page_Load(object sender, EventArgs e) { SectionReport rpt = new SectionReport(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("~") + @"\RpxReports\NwindLabels.rpx"); rpt.LoadLayout(xtr); xtr.Close(); try { rpt.Run(false); } catch (ReportException eRunReport) { // Show error message to the user when there is a failure in generating the report. Response.Clear(); Response.Write("<h1>Error running report:</h1>"); Response.Write(eRunReport.ToString()); return; } // Used when the page output is already getting created. Response.Buffer = true; // Clear the output contents from the buffer stream. Response.ClearContent(); // Clear any headers from the buffer stream (such as the content type for an HTML page). Response.ClearHeaders(); // Notify the browser that cache should not be created. Response.Cache.SetCacheability(HttpCacheability.NoCache); // Specify the appropriate viewer for the browser. Response.ContentType = "text/html"; // Create an instance of the HTMLExport class. HtmlExport html = new HtmlExport { IncludeHtmlHeader = true }; // Export the report to HTML in this session's webcache. RpxHandler.HtmlOutputHandler output = new RpxHandler.HtmlOutputHandler(Cache, "Custom HTML"); html.Export(rpt.Document, output, string.Empty); Response.BinaryWrite(output.MainPageData); // Send all buffered content to the client Response.End(); }
public void TestCSDLNestedMultipleDisplayFolders() { MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", ""); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\NestedMultipleFoldersCsdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); var cmpyTab = tabs["Table1"]; /* test folder structure should be: * * Folder 1 |- Measure * Folder 2 +- Folder 3 +- Measure * */ Assert.AreEqual("Table1", cmpyTab.Caption, "Table Name is correct"); Assert.AreEqual(2, cmpyTab.FolderItems.Count); var folder1 = ((IADOTabularFolderReference)cmpyTab.FolderItems[0]); Assert.AreEqual("Folder 1", folder1.Name); Assert.AreEqual(1, folder1.FolderItems.Count); Assert.AreEqual("Measure", folder1.FolderItems[0].InternalReference); var folder2 = ((IADOTabularFolderReference)cmpyTab.FolderItems[1]); Assert.AreEqual("Folder 2", folder2.Name); var folder3 = ((IADOTabularFolderReference)folder2.FolderItems[0]); Assert.AreEqual("Folder 3", folder3.Name); Assert.AreEqual("Measure", folder3.FolderItems[0].InternalReference); }
public static System.Xml.XmlDocument GetReport(string reportName) { // http://blogs.msdn.com/b/tolong/archive/2007/11/15/read-write-xml-in-memory-stream.aspx System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); // doc.Load(memorystream); // doc.Load(FILE_NAME); // doc.Load(strFileName); using (System.IO.Stream strm = GetEmbeddedReport(reportName)) { using (System.Xml.XmlTextReader xtrReader = new System.Xml.XmlTextReader(strm)) { doc.Load(xtrReader); xtrReader.Close(); } // End Using xtrReader } // End Using strm return doc; }
public BoolToJsonSyntaxHighliting() { using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("a7DocumentDbStudio.Resources.avalonEditJson.xshd")) { using (var reader = new System.Xml.XmlTextReader(stream)) { editableHighLighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); } } using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("a7DocumentDbStudio.Resources.avalonEditJsonReadOnly.xshd")) { using (var reader = new System.Xml.XmlTextReader(stream)) { readOnlyHighLighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); } } }
/// <summary> /// Get some DataTable from RSS file. /// </summary> /// <param name="location"></param> /// <param name="address"></param> /// <param name="feedType"></param> /// <returns></returns> public static System.Data.DataTable GetRSSFeed(RSSLocation location, string address, RSSFeedType feedType) { int intIndex = 0; int intItemTableIndex = -1; System.IO.StreamReader oStreamReader = null; System.Xml.XmlTextReader oXmlTextReader = null; switch(location) { case RSSLocation.URL: oXmlTextReader = new System.Xml.XmlTextReader(address); break; case RSSLocation.Drive: oStreamReader = new System.IO.StreamReader(address, System.Text.Encoding.UTF8); oXmlTextReader = new System.Xml.XmlTextReader(oStreamReader); break; } System.Data.DataSet oDataSet = new System.Data.DataSet(); oDataSet.ReadXml(oXmlTextReader, System.Data.XmlReadMode.Auto); oXmlTextReader.Close(); if(location == RSSLocation.Drive) oStreamReader.Close(); while((intIndex <= oDataSet.Tables.Count - 1) && (intItemTableIndex == -1)) { if(oDataSet.Tables[intIndex].TableName.ToUpper() == feedType.ToString().ToUpper()) intItemTableIndex = intIndex; intIndex++; } if(intItemTableIndex == -1) return(null); else return(oDataSet.Tables[intItemTableIndex]); }
public static void loadData(Mutex semaphore) { locked = true; semaphore.WaitOne(); var file = "austria-latest.osm"; using(var fs = System.IO.File.OpenRead(file)) { using(var xml = new System.Xml.XmlTextReader(fs)) { while(xml.Read()) { if(xml.NodeType == System.Xml.XmlNodeType.Element && xml.Name == "osm") { parseOsm(xml); } } } // read from file } // open from file semaphore.ReleaseMutex(); locked = false; lastRefresh = DateTime.Now; }