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);
        }
Ejemplo n.º 2
0
        /// <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)));
 }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 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();
 }
Ejemplo n.º 6
0
		///<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;
		}
Ejemplo n.º 7
0
        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)));
        }
 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;
 }
Ejemplo n.º 9
0
        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;
        }
Ejemplo n.º 11
0
 /// <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;
 }
Ejemplo n.º 12
0
        /// <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);
         }
     }
 }
Ejemplo n.º 14
0
        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 { }
            }
        }
Ejemplo n.º 16
0
        // 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 = "";
                }
            }
        }
Ejemplo n.º 17
0
        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)
            {

            }
        }
Ejemplo n.º 18
0
    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 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);
        }
Ejemplo n.º 20
0
 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;
 }
Ejemplo n.º 21
0
 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;
     }
 }
        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;
        }
Ejemplo n.º 23
0
        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("'", "&apos;"));

                    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
                    {
                    }
                }
            }
        }
Ejemplo n.º 24
0
 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;
 }
Ejemplo n.º 25
0
 /// <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;
     }
 }
Ejemplo n.º 26
0
 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;
     }
 }
        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);
         }
     }
 }
Ejemplo n.º 29
0
        /// <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]);
        }
Ejemplo n.º 30
0
 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;
 }