public void PushInputDocument(string url) { // todo: detect recursion Uri baseUriObj = (Input.BaseURI == String.Empty) ? null : new Uri(Input.BaseURI); Uri absUri = res.ResolveUri(baseUriObj, url); string absUriString = absUri != null?absUri.ToString() : String.Empty; using (Stream s = (Stream)res.GetEntity(absUri, null, typeof(Stream))) { if (s == null) { throw new XsltCompileException("Can not access URI " + absUri.ToString(), null, Input); } XmlValidatingReader vr = new XmlValidatingReader(new XmlTextReader(absUriString, s, nsMgr.NameTable)); vr.ValidationType = ValidationType.None; XPathNavigator n = new XPathDocument(vr, XmlSpace.Preserve).CreateNavigator(); vr.Close(); n.MoveToFirstChild(); do { if (n.NodeType == XPathNodeType.Element) { break; } }while (n.MoveToNext()); PushInputDocument(n); } }
internal static CngKey FromXml(string xml) { CngKey key; using (TextReader reader = new StringReader(xml)) { using (XmlTextReader reader2 = new XmlTextReader(reader)) { BigInteger integer; BigInteger integer2; XPathNavigator navigator = new XPathDocument(reader2).CreateNavigator(); if (!navigator.MoveToFirstChild()) { throw new ArgumentException(System.SR.GetString("Cryptography_MissingDomainParameters")); } CngAlgorithm algorithm = ReadAlgorithm(navigator); if (!navigator.MoveToNext(XPathNodeType.Element)) { throw new ArgumentException(System.SR.GetString("Cryptography_MissingPublicKey")); } ReadPublicKey(navigator, out integer, out integer2); key = CngKey.Import(NCryptNative.BuildEccPublicBlob(algorithm.Algorithm, integer, integer2), CngKeyBlobFormat.EccPublicBlob); } } return(key); }
public void PushInputDocument(string url) { Uri baseUri = (!(this.Input.BaseURI == string.Empty)) ? new Uri(this.Input.BaseURI) : null; Uri uri = this.res.ResolveUri(baseUri, url); string url2 = (!(uri != null)) ? string.Empty : uri.ToString(); using (Stream stream = (Stream)this.res.GetEntity(uri, null, typeof(Stream))) { if (stream == null) { throw new XsltCompileException("Can not access URI " + uri.ToString(), null, this.Input); } XmlValidatingReader xmlValidatingReader = new XmlValidatingReader(new XmlTextReader(url2, stream, this.nsMgr.NameTable)); xmlValidatingReader.ValidationType = ValidationType.None; XPathNavigator xpathNavigator = new XPathDocument(xmlValidatingReader, XmlSpace.Preserve).CreateNavigator(); xmlValidatingReader.Close(); xpathNavigator.MoveToFirstChild(); while (xpathNavigator.NodeType != XPathNodeType.Element) { if (!xpathNavigator.MoveToNext()) { IL_F9: this.PushInputDocument(xpathNavigator); return; } } goto IL_F9; } }
public void SignificantWhitespaceConstruction() { string xml = @"<root> <child xml:space='preserve'> <!-- --> </child> <child xml:space='preserve'> </child> </root>"; XPathNavigator nav = new XPathDocument( new XmlTextReader(xml, XmlNodeType.Document, null), XmlSpace.Preserve).CreateNavigator(); nav.MoveToFirstChild(); nav.MoveToFirstChild(); Assert.AreEqual(XPathNodeType.Whitespace, nav.NodeType, "#1"); nav.MoveToNext(); nav.MoveToFirstChild(); Assert.AreEqual(XPathNodeType.SignificantWhitespace, nav.NodeType, "#2"); }
internal IEnumerable <T> Deserialize <T> (string filter, string xml) where T : Object { if (!object_cache.ContainsKey(filter)) { object_cache[filter] = new Dictionary <string, WeakReference> (); } using (var reader = new StringReader(xml)) { var navigator = new XPathDocument(reader).CreateNavigator(); if (navigator.MoveToChild("DIDL-Lite", Schemas.DidlLiteSchema) && navigator.MoveToFirstChild()) { do { yield return(DerserializeObject <T> (filter, navigator)); } while (navigator.MoveToNext()); } } }
public void XPathDocumentFragmentLoading() { string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>"; XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator(); // <customer> nav.MoveToFirstChild(); // <pp:order> nav.MoveToFirstChild(); // <order> nav.MoveToNext(); XmlReader reader = new XPathNavigatorReader(nav); XPathNavigator clone = new XPathDocument(reader).CreateNavigator(); clone.MoveToFirstChild(); Assert.AreEqual("order", clone.LocalName); Assert.AreEqual("urn-kzu", clone.NamespaceURI); }
public void XmlDocumentFragmentLoading() { string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>"; XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator(); // <customer> nav.MoveToFirstChild(); // <pp:order> nav.MoveToFirstChild(); // <order> nav.MoveToNext(); XmlReader reader = new XPathNavigatorReader(nav); XmlDocument doc = new XmlDocument(nav.NameTable); doc.Load(reader); Assert.AreEqual("order", doc.DocumentElement.LocalName); Assert.AreEqual("urn-kzu", doc.DocumentElement.NamespaceURI); Assert.AreEqual(1, doc.DocumentElement.Attributes.Count); }
public bool LoadProfile(string profileName, bool absolutepath = false) { string str = !absolutepath ? HotKeyManager._profileRootDirectory + "\\" + profileName + ".keys" : profileName; if (profileName == "~Default") { str = this._assetdir + "\\" + profileName + ".keys"; } if (!File.Exists(str)) { return(false); } this.HotKeys.Clear(); if (profileName == "~Default") { this.DefaultHotKeys.Clear(); } this._profileName = profileName; XPathNavigator navigator = new XPathDocument(App.GetStreamForFile(str) != null ? App.GetStreamForFile(str) : (Stream) new FileStream(str, FileMode.Open)).CreateNavigator(); navigator.MoveToFirstChild(); do { if (navigator.HasChildren) { navigator.MoveToFirstChild(); do { if (navigator.HasChildren) { HotKeyManager.KeyCombo keyCombo = new HotKeyManager.KeyCombo(); HotKeyManager.HotKeyActions key = HotKeyManager.HotKeyActions.NoAction; navigator.MoveToFirstChild(); do { switch (navigator.Name) { case "event": if (Enum.IsDefined(typeof(HotKeyManager.HotKeyActions), (object)navigator.Value)) { key = (HotKeyManager.HotKeyActions)Enum.Parse(typeof(HotKeyManager.HotKeyActions), navigator.Value, true); break; } break; case "states": keyCombo.states = navigator.Value; break; case "shift": keyCombo.shift = bool.Parse(navigator.Value); break; case "ctrl": keyCombo.control = bool.Parse(navigator.Value); break; case "alt": keyCombo.alt = bool.Parse(navigator.Value); break; case "key": keyCombo.key = !Enum.IsDefined(typeof(Keys), (object)navigator.Value) ? Keys.None : (Keys)Enum.Parse(typeof(Keys), navigator.Value, true); break; } }while (navigator.MoveToNext()); if (key != HotKeyManager.HotKeyActions.NoAction && !this.HotKeys.ContainsKey(key)) { this.HotKeys.Add(key, keyCombo); if (profileName == "~Default") { this.DefaultHotKeys.Add(key, keyCombo); } } navigator.MoveToParent(); } }while (navigator.MoveToNext()); } }while (navigator.MoveToNext()); this._loaded = true; foreach (HotKeyManager.HotKeyActions action in Enum.GetValues(typeof(HotKeyManager.HotKeyActions))) { if (!this.HotKeys.Keys.Contains <HotKeyManager.HotKeyActions>(action) && this.DefaultHotKeys.Keys.Contains <HotKeyManager.HotKeyActions>(action)) { this.SetHotKeyCombo(action, this.DefaultHotKeys[action]); } } this.SyncKeyProfile(""); this.SaveProfile(); return(true); }
public bool LoadProfile(string profileName, bool absolutepath = false) { string str1 = !absolutepath ? Profile._profileRootDirectory + "\\" + profileName + ".xml" : profileName; if (!File.Exists(str1)) { return(false); } XPathNavigator navigator = new XPathDocument(App.GetStreamForFile(str1) ?? (Stream) new FileStream(str1, FileMode.Open)).CreateNavigator(); navigator.MoveToFirstChild(); do { if (navigator.HasChildren) { navigator.MoveToFirstChild(); do { switch (navigator.Name) { case "name": this._profileName = navigator.Value; break; case "techs": string str2 = navigator.Value; this._researchedTechs.Clear(); string[] strArray = str2.Split('!'); for (int index = 0; index < strArray.Length; ++index) { if (strArray[index].Length > 0) { this._researchedTechs.Add(strArray[index]); } } break; case "username": this.Username = navigator.Value ?? string.Empty; break; case "password": this.Password = navigator.Value ?? string.Empty; break; case "last_game_played": this.LastGamePlayed = navigator.Value ?? string.Empty; break; case "auto_place_defenses": this.AutoPlaceDefenseAssets = bool.Parse(navigator.Value); break; case "auto_repair_fleets": this.AutoRepairFleets = bool.Parse(navigator.Value); break; case "auto_goop": this.AutoUseGoop = bool.Parse(navigator.Value); break; case "auto_joker": this.AutoUseJoker = bool.Parse(navigator.Value); break; case "auto_aoe": this.AutoAOE = bool.Parse(navigator.Value); break; case "auto_patrol": this.AutoPatrol = bool.Parse(navigator.Value); break; } }while (navigator.MoveToNext()); } }while (navigator.MoveToNext()); this._loaded = true; return(true); }