/// <summary> /// 从HTML读取器中加载对象数据 /// </summary> /// <param name="myReader"></param> /// <returns></returns> internal override bool InnerRead(HTMLTextReader myReader) { strLoadErrorMsg = null; strSourceXML = myReader.ReadToEndTag(this.TagName); try { myXMLDocument.RemoveAll(); System.Xml.XmlNamespaceManager nsm = new System.Xml.XmlNamespaceManager(myXMLDocument.NameTable); foreach (HTMLAttribute attr in myOwnerDocument.Attributes) { string vName = attr.Name; if (vName.ToLower().StartsWith(StringConstAttributeName.XMLNS)) { int index = vName.IndexOf(":"); if (index > 0) { string NsName = vName.Substring(index + 1); nsm.AddNamespace(NsName, attr.Value); } } } System.Xml.XmlParserContext pc = new System.Xml.XmlParserContext(myXMLDocument.NameTable, nsm, null, System.Xml.XmlSpace.None); System.Xml.XmlTextReader myXMLReader = new System.Xml.XmlTextReader(strSourceXML, System.Xml.XmlNodeType.Element, pc); myXMLDocument.Load(myXMLReader); myXMLReader.Close(); } catch (Exception ext) { myXMLDocument.RemoveAll(); strLoadErrorMsg = "加载XML数据岛信息错误 - " + ext.Message; } return(true); }
/// <summary> /// Validates the given XML document. /// </summary> /// <param name="input">XML document as stream.</param> /// <param name="ser">Serialiser.</param> /// <exception cref="InvalidOperationException">Thrown if the document is invalid.</exception> public void Validate(System.IO.Stream input, Type type) { var settings = GetSettings(); // Adding the event handler of this object settings.ValidationEventHandler += Settings_ValidationEventHandler; // Clearing validation messages m_validationMessages.Clear(); // Out of the box, XLink attributes have not worked as they should. // They exist as default attributes in some places (have forgotten if // this is in the XML schemata or added manually in MessageSerialiser). // Anyway, because XLink attributes come from a namespace unknown to the parser, // there must be a namespace manager to explicitly declare the XLink namespace. var nametable = new System.Xml.NameTable(); var xmlNsManager = new System.Xml.XmlNamespaceManager(nametable); xmlNsManager.AddNamespace("xlink", "http://www.w3.org/1999/xlink"); // This context object is mandatory to pass the namespace manager to the parser. var parserContext = new System.Xml.XmlParserContext(null, xmlNsManager, null, System.Xml.XmlSpace.None); using (var reader = System.Xml.XmlReader.Create(input, settings, parserContext)) { // Deserialising the document var serializer = new System.Xml.Serialization.XmlSerializer(type); serializer.Deserialize(reader); } // Removing the event handler of this object (this would // otherwise cause conflicts when multiple documents are validated) settings.ValidationEventHandler -= Settings_ValidationEventHandler; if (m_validationMessages.Count > 0) { var msg = string.Format("The XML document has {0} errors. First error: {1}", m_validationMessages.Count, m_validationMessages[0]); throw new InvalidOperationException(msg); } }
/// <summary> /// Validates the given XML document. /// </summary> /// <param name="input">XML document as stream.</param> /// <param name="ser">Serialiser.</param> /// <exception cref="InvalidOperationException">Thrown if the document is invalid.</exception> public void Validate(System.IO.Stream input, Type type) { var settings = GetSettings(); // Adding the event handler of this object settings.ValidationEventHandler += Settings_ValidationEventHandler; // Clearing validation messages m_validationMessages.Clear(); // Declaring a prefix for the XLink namespace explicitly. // This is necessary to support scheduling parameters of type // Item_DataRecord from the library "Cocop.MessageSerialiser.Meas". var nametable = new System.Xml.NameTable(); var xmlNsManager = new System.Xml.XmlNamespaceManager(nametable); xmlNsManager.AddNamespace("xlink", "http://www.w3.org/1999/xlink"); // Declaring a context object to pass the namespace manager to the parser var parserContext = new System.Xml.XmlParserContext(null, xmlNsManager, null, System.Xml.XmlSpace.None); using (var reader = System.Xml.XmlReader.Create(input, settings, parserContext)) { // Deserialising the document var serializer = new System.Xml.Serialization.XmlSerializer(type); serializer.Deserialize(reader); } // Removing the event handler of this object (the event handler would // otherwise cause conflicts when multiple documents are validated) settings.ValidationEventHandler -= Settings_ValidationEventHandler; if (m_validationMessages.Count > 0) { var msg = string.Format("The XML document has {0} errors. First error: {1}", m_validationMessages.Count, m_validationMessages[0]); throw new InvalidOperationException(msg); } }
public static bool _ctor_System_Xml_XmlTextReader_System_String_System_Xml_XmlNodeType_System_Xml_XmlParserContext( ) { //Parameters System.String xmlFragment = null; System.Xml.XmlNodeType fragType = null; System.Xml.XmlParserContext context = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.Xml.XmlTextReader.ctor(xmlFragment, fragType, context); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.Xml.XmlTextReader.ctor(xmlFragment, fragType, context); } catch (Exception e) { exception_Intercepted = e; } }
public static System.Xml.XmlReader Create(System.IO.TextReader input, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext inputContext) { throw null; }
public ParserContext(System.Xml.XmlParserContext xmlParserContext) { Contract.Requires(xmlParserContext != null); }
public static System.Xml.XmlReader Create(System.IO.TextReader input, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext inputContext) { return(default(System.Xml.XmlReader)); }
public static eagle Deserialize(string xml) { System.IO.StringReader stringReader = null; try { stringReader = new System.IO.StringReader(xml); // add a settings to allow DTD System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings(); settings.DtdProcessing = System.Xml.DtdProcessing.Ignore; // map empty namespace to eagle for DTD based XML var nsmgr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable()); // Add your namespaces used in the XML nsmgr.AddNamespace(String.Empty, "eagle"); // Create the XmlParserContext using the previous declared XmlNamespaceManager var ctx = new System.Xml.XmlParserContext(null, nsmgr, null, System.Xml.XmlSpace.None); return ((eagle)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader, settings, ctx)))); } finally { if ((stringReader != null)) { stringReader.Dispose(); } } }
public HttpResponseMessage SSOLogin(JObject ticketInfo) { var jsonParams = HttpUtil.Deserialize(ticketInfo); string ticket = jsonParams.ticket; string url = SSOServer + "serviceValidate?ticket=" + ticket + "&" + "service=" + MyServer; System.IO.StreamReader Reader = new System.IO.StreamReader(new System.Net.WebClient().OpenRead(url)); string resp = Reader.ReadToEnd(); Reader.Close(); System.Xml.NameTable nt = new System.Xml.NameTable(); System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(nt); System.Xml.XmlParserContext context = new System.Xml.XmlParserContext(null, nsmgr, null, System.Xml.XmlSpace.None); System.Xml.XmlTextReader reader1 = new System.Xml.XmlTextReader(resp, System.Xml.XmlNodeType.Element, context); string netid = null; string debugMsg = ""; while (reader1.Read()) { debugMsg += reader1.LocalName + reader1.ReadString(); if (reader1.IsStartElement()) { string tag = reader1.LocalName; if (tag == "employeeNumber") { netid = reader1.ReadString(); } } } if (netid == null) { LogUtil.Log(Request, "登录", "Unknown", "Unknown", 0, "Fail", debugMsg, DateTime.Now.ToString()); return(new Response(2002, "请重试").Convert()); } User user = UserDao.GetUserById(netid.ToUpper()); if (user != null) { bool login = redis.IsSet(user.id); if (login) { string expiredToken = redis.Get <string>(user.id); redis.Delete(expiredToken); redis.Delete(user.id); } string uuid = System.Guid.NewGuid().ToString(); redis.Set(uuid, user.id, 15); redis.Set(user.id, uuid, 15); Dictionary <string, string> retData = new Dictionary <string, string> { { "authorization", uuid }, { "userId", user.id }, { "role", user.role.ToString() }, { "name", user.name }, { "is_accept", user.is_accept.ToString() } }; LogUtil.Log(Request, "登录", user.id, user.id, user.role, "", "SSO登录" + SSOServer, DateTime.Now.ToString()); return(new Response(1001, "登录成功", retData).Convert()); } return(new Response(2002, "ID不存在").Convert()); }
public ParserContext(System.Xml.XmlParserContext xmlParserContext) { }