static void Main(string[] args) { ITracer tracer = new Tracer.Tracer(); ISerializer serializerJSON = new SerializerJSON(); ISerializer serializerXML = new SerializerXML(); IOutputWriter writer = new OutputWriter.OutputWriter(); //Process var test = new Foo(tracer); test.MyMethod(); Thread thread = new Thread(test.MyMethod); thread.Start(); thread.Join(); //Serialize string result = serializerXML.Serialize(tracer.GetTraceResult()); StreamWriter fs = new StreamWriter("test.xml"); //Write writer.Write(result, fs); writer.Write(result); //Serialize result = serializerJSON.Serialize(tracer.GetTraceResult()); StreamWriter fs2 = new StreamWriter("test.json"); //Write writer.Write(result, fs2); writer.Write(result); fs.Close(); fs2.Close(); }
public static T ConsumeServiceUserByAction <T>(string action, string serialize, string service) where T : class { T response = Activator.CreateInstance <T>(); string result = string.Empty; HttpWebRequestServiceSOAP HttpWebReq = HttpWebRequestServiceSOAP.GetInstance("text/xml;charset=\"utf-8\"", "text/xml", "POST", service); result = HttpWebReq.ConsumeServiceUserByAction(action, serialize); response = SerializerXML.Deserialize <T>(result); return(response); }
/// <summary> /// 反序列化Site配置文件 /// </summary> /// <returns></returns> public SiteConfigInfo LoadConfig() { SiteConfigInfo siteConfigInfo = (SiteConfigInfo)CacheAccess.GetFromCache("SITECONFIG"); if (siteConfigInfo == null) { siteConfigInfo = (SiteConfigInfo)SerializerXML.Load(typeof(SiteConfigInfo), path); CacheDependency cmsConfigDependency = new CacheDependency(path); CacheAccess.SaveToCache("SITECONFIG", siteConfigInfo, cmsConfigDependency); } return(siteConfigInfo); }
/// <summary> /// 反序列化CMS配置文件 /// </summary> /// <returns></returns> public CMSConfigInfo LoadConfig() { CMSConfigInfo cmsConfigInfo = (CMSConfigInfo)CacheAccess.GetFromCache("CMSCONFIG"); if (cmsConfigInfo == null) { cmsConfigInfo = (CMSConfigInfo)SerializerXML.Load(typeof(CMSConfigInfo), path); CacheDependency cmsConfigDependency = new CacheDependency(path); CacheAccess.SaveToCache("CMSCONFIG", cmsConfigInfo, cmsConfigDependency); } return(cmsConfigInfo); }
/// <summary> /// 获取配置文件信息工厂 /// </summary> /// <param name="configName">配置文件类名</param> /// <returns>数据访问类对象</returns> public static T LoadConfig <T>(string configName) where T : IConfigInfo { string path = GetPath(configName); object configObj = CacheAccess.GetFromCache(configName); if (configObj == null) { configObj = SerializerXML.Load(typeof(T), path); CacheDependency configDependency = new CacheDependency(path); CacheAccess.SaveToCache(configName, configObj, configDependency); } return((T)configObj); }
public static T GetConfig() { if (_instance == null) { lock (lockHelper) { Type type = typeof(T); _instance = (T)SerializerXML.Load(type, GetPath(type.Name)); return(_instance); } } return(_instance); }
public static Settings GetFrameworkSettings() { var configFile = TestContext.Parameters["configFileName"]; if (string.IsNullOrEmpty(configFile)) { configFile = "ChromeConfig.xml"; } string path = AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\" + $"\\Config\\{configFile}"; string xmlInputData = File.ReadAllText(path); return(SerializerXML.Deserialize <Settings>(xmlInputData)); }
public T GetRemoteData(string apiUrl) { WebRequest wrq = WebRequest.Create(apiUrl); wrq.Timeout = 6000; wrq.Method = "GET"; WebResponse wrp = wrq.GetResponse(); using (Stream sr = wrp.GetResponseStream()) { T instance; Type type = typeof(T); instance = (T)SerializerXML.Load(type, sr); return(instance); } }
public void Save() { SerializerXML _stream = null; try { _stream = new SerializerXML("UserDat", "1.0.0.0"); _stream.OpenOutputStream(s_UserFilePath); _stream.WriteElementStart("Application"); WriteToSerializer(_stream); _stream.WriteElementEnd("Application"); _stream.CloseOutputStream(); _stream = null; } catch (Exception e) { DlgError.HandleException(e); } finally { if (_stream != null) { _stream.CloseOutputStream(); } } }
public ActionResult Login(LoginModel login) { if (ModelState.IsValid) { //Consultar Service Nutresa. ParGetUserData par = new ParGetUserData { Body = new ParGetUserDataBody { usuario = Convert.ToString(ConfigurationHelper.Get("ServNutresa.Usuario")), clave = Convert.ToString(ConfigurationHelper.Get("ServNutresa.Clave")), password = login.Password, userName = login.Email } }; string serialize = SerializerXML.Serialize <ParGetUserData>(par); string action = Convert.ToString(ConfigurationHelper.Get("ServNutresa.GetUserData")); string service = Convert.ToString(ConfigurationHelper.Get("ServNutresa.UrlUserData")); UserData userData = new UserData(); RespUser envelope = HttpWebRequestGeneric.ConsumeServiceUserByAction <RespUser>(action, serialize, service); userData = CastObjects.ConvertItemValueItemItem <UserData>(envelope.Body.getUserDataReturn); FormsAuthentication.SetAuthCookie("221ea0b2-6a56-450d-bcb7-7fa110ea0da1", true); //if (Url.IsLocalUrl(ReturnUrl)) // //return Redirect(ReturnUrl); // return RedirectToAction("MyRedemptions", "Redemption"); //else // //return RedirectToAction("Index", "Profile"); // return RedirectToAction("MyRedemptions", "Redemption"); return(RedirectToAction("MyRedemptions", "Redemption")); } else { return(View()); } }
public void Load() { string DocType = string.Empty; SerializerXML _stream = null; try { _stream = new SerializerXML("UserDat", "1.0.0.0"); _stream.OpenInputStream(s_UserFilePath); if (_stream.GetDetectedSerializerName() != "UserDat") { throw new FormatException(""); } string NodeGroup; do { NodeGroup = _stream.GetNodeName(); if (_stream.GetNodeType() != SerializerBase.NodeType.NodeEnd) { if (NodeGroup == "Application") { ReadFromSerializer(_stream); } } } while (_stream.ReadNext()); _stream.CloseInputStream(); _stream = null; } catch (Exception e) { DlgError.HandleException(e); } finally { if (_stream != null) { _stream.CloseInputStream(); } } }
/// <summary> ///序列化Site配置文件 /// </summary> public void SaveConfig(SiteConfigInfo siteConfigInfo) { SerializerXML.Save(siteConfigInfo, path); }
/// <summary> ///序列化CMS配置文件 /// </summary> public void SaveConfig(CMSConfigInfo cmsConfigInfo) { SerializerXML.Save(cmsConfigInfo, path); }
/// <summary> ///序列化配置文件 /// </summary> public static void SaveConfig <T>(IConfigInfo configInfo, string configName) where T : IConfigInfo { SerializerXML.Save((T)configInfo, GetPath(configName)); }
public void ManejadorVoto(string senador, Votacion.EVoto voto) { if (this.groupBox2.InvokeRequired) { Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto); this.Invoke(recall, new object[] { senador, voto }); } else { // Leo la banca del Senador actual PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1); switch (voto) { case Votacion.EVoto.Afirmativo: // Sumo votantes al Label correspondiente lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString(); // Marco la banca con color Verde p.BackColor = Color.Green; break; case Votacion.EVoto.Negativo: // Sumo votantes al Label correspondiente lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString(); // Marco la banca con color Rojo p.BackColor = Color.Red; break; case Votacion.EVoto.Abstencion: // Sumo votantes al Label correspondiente lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString(); // Marco la banca con color Amarillo p.BackColor = Color.Yellow; break; } // Quito un Senador de los que un no votaron, para marcar cuando termina la votación int aux = int.Parse(lblEsperando.Text) - 1; lblEsperando.Text = aux.ToString(); // Si finaliza la votación, muestro si Es Ley o No Es Ley if (aux == 0) { MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text); // Guardar resultados string conection = "Data Source=.\\SQLEXPRESS; Initial Catalog=votacion-sp-2018; Integrated Security=True"; Dao guardarSql = new Dao(); SerializerXML <Votacion> guardar = new SerializerXML <Votacion>(); try { guardarSql.Guardar(conection, this.votacion); } catch (Exception) { } try { guardar.Guardar("VotacionActual.txt", this.votacion); } catch (ErrorArchivoException) { } } } }
public static void SaveConfig(IConfigInfo configInfo) { SerializerXML.Save((T)configInfo, GetPath(typeof(T).Name)); }