static void Main(string[] args) { //1. Referenciar el ensamblado Framework //2. Importar el namespace Framework.Comun var noExiste = HelperConfig.GetString("NoExiste"); Console.WriteLine(noExiste); var existe = HelperConfig.GetString("Existe"); Console.WriteLine(existe); var valorEntero = HelperConfig.GetInt32("valorEntero"); Console.WriteLine(valorEntero); var valorInt16 = HelperConfig.GetInt16("valorInt16"); Console.WriteLine(valorInt16); var valorBool = HelperConfig.GetBool("valorBool"); Console.WriteLine(valorBool); var valorDecimal = HelperConfig.GetDecimal("valorDecimal"); Console.WriteLine(valorDecimal); Console.ReadLine(); }
public string PostImpresion(Documento texto) { cf = new HelperConfig(); Impresor = new HelperPrinterClass(); if (texto.Impresor == "Cocina" || texto.Impresor == "cocina") { Impresor.PrinterSettings.PrinterName = cf.Configuracion.ImpresoraCocina; } else { Impresor.PrinterSettings.PrinterName = cf.Configuracion.ImpresoraBar; } if (cf.Configuracion.UsarMargenes == 1) { Impresor.DefaultPageSettings.Margins.Left = cf.Configuracion.MargenIzquierdo; Impresor.DefaultPageSettings.Margins.Right = cf.Configuracion.MargenDerecho; } Impresor.PrinterFont = new Font(cf.Configuracion.Fuente, cf.Configuracion.NumeroFuente); Impresor.TextToPrint = texto.Contenido; Impresor.Print(); return(texto.Contenido); }
public static Helper CreateHelper(string name, Character owner) { HelperConfig config = ConfigReader.Parse <HelperConfig>(FileReader.Read("Helpers/" + name + "/" + name + ".def")); ActionsConfig actionsConfig = ConfigReader.Parse <ActionsConfig>(FileReader.Read(config.action)); config.SetActions(actionsConfig.actions.ToArray()); Helper helper = new Helper(config, owner); return(helper); }
public Helper(HelperConfig config, Character owner) : base(config) { this.owner = owner; /* * SetConfig(config); * moveCtr = new MoveCtrl(this); * animCtr = new AnimationController(config.actions, this); * fsmMgr = new FsmManager(config.fsm, this); */ }
public DefaultShortStringHelper WithConfig(CultureInfo culture, CleanStringType stringRole, Func <string, string> preFilter = null, bool breakTermsOnUpper = true, bool allowLeadingDigits = false, bool allowUnderscoreInTerm = false) { EnsureNotFrozen(); if (_configs.ContainsKey(culture) == false) { _configs[culture] = new Dictionary <CleanStringType, HelperConfig>(); } _configs[culture][stringRole] = new HelperConfig(preFilter, breakTermsOnUpper, allowLeadingDigits, allowUnderscoreInTerm); return(this); }
public void BeforeSendReply(ref Message reply, object correlationState) { var parametro = (EnvoltorioMensaje)correlationState; if (reply != null) { parametro.Response = reply.IsFault ? "Ocurrió un error en el servicio. Revise el log de errores." : reply.ToString(); } parametro.FechaFin = DateTime.Now; if (_enabled) { CustomLogManager.Instancia.RegistrarTraza( new InformacionLog { Mensaje = "Traza de mensajes de entrada", DatosAdicionales = parametro.InformacionAdicional() }); } //Si la llamada demora mas del tiempo configurado se envia a una tarza especial int tiempoSegundosLimiteLlamada = HelperConfig.GetInt32("Wcf:InspectorServicio:LimiteTiempoLLamada"); if (tiempoSegundosLimiteLlamada <= 0 || tiempoSegundosLimiteLlamada >= parametro.Duracion) { return; } string mensaje = string.Format( "Tiempo Limite por Llamada excedido(max {0} seg) {4}Duracion: {1} seg {4}Accion : {2}{4}[Request]{4}{3}{4}[Response]{4}{5}", tiempoSegundosLimiteLlamada, parametro.Duracion, parametro.Accion, parametro.Request, Environment.NewLine, parametro.Response); CustomLogManager.Instancia.RegistrarAdvertencia( new InformacionLog { Mensaje = mensaje, DatosAdicionales = new Dictionary <string, object> { { "Identificador", parametro.Identificador }, { "Ip", parametro.Ip }, { "Tipo", "Tiempo Limite excedido" } } }); }
internal string CleanUtf8String(string text, CleanStringType caseType, char separator, CultureInfo culture, HelperConfig config) { int opos = 0, ipos = 0; var state = StateBreak; caseType &= CleanStringType.CaseMask; // if we apply global ToUpper or ToLower to text here // then we cannot break words on uppercase chars var input = text; // it's faster to use an array than a StringBuilder var ilen = input.Length; var output = new char[ilen * 2]; // twice the length should be OK in all cases //var termFilter = config.TermFilter; for (var i = 0; i < ilen; i++) { var c = input[i]; var isDigit = char.IsDigit(c); var isUpper = char.IsUpper(c); // false for digits, symbols... var isLower = char.IsLower(c); // false for digits, symbols... var isUnder = config.AllowUnderscoreInTerm && c == '_'; var isTerm = char.IsLetterOrDigit(c) || isUnder; switch (state) { case StateBreak: if (isTerm && (opos > 0 || (isUnder == false && (config.AllowLeadingDigits || isDigit == false)))) { ipos = i; if (opos > 0 && separator != char.MinValue) output[opos++] = separator; state = isUpper ? StateUp : StateWord; } break; case StateWord: if (isTerm == false || (config.BreakTermsOnUpper && isUpper)) { CopyUtf8Term(input, ipos, output, ref opos, i - ipos, caseType, culture, /*termFilter,*/ false); ipos = i; state = isTerm ? StateUp : StateBreak; if (state != StateBreak && separator != char.MinValue) output[opos++] = separator; } break; case StateAcronym: if (isTerm == false || isLower || isDigit) { if (isLower && config.GreedyAcronyms == false) i -= 1; CopyUtf8Term(input, ipos, output, ref opos, i - ipos, caseType, culture, /*termFilter,*/ true); ipos = i; state = isTerm ? StateWord : StateBreak; if (state != StateBreak && separator != char.MinValue) output[opos++] = separator; } break; case StateUp: if (isTerm) { state = isUpper ? StateAcronym : StateWord; } else { CopyUtf8Term(input, ipos, output, ref opos, 1, caseType, culture, /*termFilter,*/ false); state = StateBreak; } break; default: throw new Exception("Invalid state."); } } switch (state) { case StateBreak: break; case StateWord: CopyUtf8Term(input, ipos, output, ref opos, input.Length - ipos, caseType, culture, /*termFilter,*/ false); break; case StateAcronym: case StateUp: CopyUtf8Term(input, ipos, output, ref opos, input.Length - ipos, caseType, culture, /*termFilter,*/ true); break; default: throw new Exception("Invalid state."); } return new string(output, 0, opos); }
/// <summary> /// Cleans a string in the context of a specified culture, using a specified separator and configuration. /// </summary> /// <param name="text">The text to clean.</param> /// <param name="stringType">A flag indicating the target casing and encoding of the string. By default, /// strings are cleaned up to camelCase and Ascii.</param> /// <param name="separator">The separator.</param> /// <param name="culture">The culture.</param> /// <param name="config">The configuration.</param> /// <returns>The clean string.</returns> private string CleanString(string text, CleanStringType stringType, char separator, CultureInfo culture, HelperConfig config) { // be safe if (text == null) throw new ArgumentNullException("text"); if (culture == null) throw new ArgumentNullException("culture"); // apply defaults if ((stringType & CleanStringType.CaseMask) == CleanStringType.None) stringType |= CleanStringType.CamelCase; if ((stringType & CleanStringType.CodeMask) == CleanStringType.None) stringType |= CleanStringType.Ascii; var codeType = stringType & CleanStringType.CodeMask; // apply pre-filter if (config.PreFilter != null) text = config.PreFilter(text); // apply replacements //if (config.Replacements != null) // text = ReplaceMany(text, config.Replacements); // recode text = Recode(text, stringType); // clean switch (codeType) { case CleanStringType.Ascii: // see note below - don't use CleanAsciiString //text = CleanAsciiString(text, stringType, separator); //break; case CleanStringType.Utf8: text = CleanUtf8String(text, stringType, separator, culture, config); break; case CleanStringType.Unicode: throw new NotImplementedException("DefaultShortStringHelper does not handle unicode yet."); default: throw new ArgumentOutOfRangeException("stringType"); } return text; }
public DefaultShortStringHelper WithConfig(CultureInfo culture, CleanStringType stringRole, Func<string, string> preFilter = null, bool breakTermsOnUpper = true, bool allowLeadingDigits = false, bool allowUnderscoreInTerm = false) { EnsureNotFrozen(); if (_configs.ContainsKey(culture) == false) _configs[culture] = new Dictionary<CleanStringType, HelperConfig>(); _configs[culture][stringRole] = new HelperConfig(preFilter, breakTermsOnUpper, allowLeadingDigits, allowUnderscoreInTerm); return this; }
internal string CleanUtf8String(string text, CleanStringType caseType, char separator, CultureInfo culture, HelperConfig config) { int opos = 0, ipos = 0; var state = StateBreak; caseType &= CleanStringType.CaseMask; // if we apply global ToUpper or ToLower to text here // then we cannot break words on uppercase chars var input = text; // it's faster to use an array than a StringBuilder var ilen = input.Length; var output = new char[ilen * 2]; // twice the length should be OK in all cases //var termFilter = config.TermFilter; for (var i = 0; i < ilen; i++) { var c = input[i]; var isDigit = char.IsDigit(c); var isUpper = char.IsUpper(c); // false for digits, symbols... var isLower = char.IsLower(c); // false for digits, symbols... var isUnder = config.AllowUnderscoreInTerm && c == '_'; var isTerm = char.IsLetterOrDigit(c) || isUnder; switch (state) { case StateBreak: if (isTerm && (opos > 0 || (isUnder == false && (config.AllowLeadingDigits || isDigit == false)))) { ipos = i; if (opos > 0 && separator != char.MinValue) { output[opos++] = separator; } state = isUpper ? StateUp : StateWord; } break; case StateWord: if (isTerm == false || (config.BreakTermsOnUpper && isUpper)) { CopyUtf8Term(input, ipos, output, ref opos, i - ipos, caseType, culture, /*termFilter,*/ false); ipos = i; state = isTerm ? StateUp : StateBreak; if (state != StateBreak && separator != char.MinValue) { output[opos++] = separator; } } break; case StateAcronym: if (isTerm == false || isLower || isDigit) { if (isLower && config.GreedyAcronyms == false) { i -= 1; } CopyUtf8Term(input, ipos, output, ref opos, i - ipos, caseType, culture, /*termFilter,*/ true); ipos = i; state = isTerm ? StateWord : StateBreak; if (state != StateBreak && separator != char.MinValue) { output[opos++] = separator; } } break; case StateUp: if (isTerm) { state = isUpper ? StateAcronym : StateWord; } else { CopyUtf8Term(input, ipos, output, ref opos, 1, caseType, culture, /*termFilter,*/ false); state = StateBreak; } break; default: throw new Exception("Invalid state."); } } switch (state) { case StateBreak: break; case StateWord: CopyUtf8Term(input, ipos, output, ref opos, input.Length - ipos, caseType, culture, /*termFilter,*/ false); break; case StateAcronym: case StateUp: CopyUtf8Term(input, ipos, output, ref opos, input.Length - ipos, caseType, culture, /*termFilter,*/ true); break; default: throw new Exception("Invalid state."); } return(new string(output, 0, opos)); }
/// <summary> /// Cleans a string in the context of a specified culture, using a specified separator and configuration. /// </summary> /// <param name="text">The text to clean.</param> /// <param name="stringType">A flag indicating the target casing and encoding of the string. By default, /// strings are cleaned up to camelCase and Ascii.</param> /// <param name="separator">The separator.</param> /// <param name="culture">The culture.</param> /// <param name="config">The configuration.</param> /// <returns>The clean string.</returns> private string CleanString(string text, CleanStringType stringType, char separator, CultureInfo culture, HelperConfig config) { // be safe if (text == null) { throw new ArgumentNullException("text"); } if (culture == null) { throw new ArgumentNullException("culture"); } // apply defaults if ((stringType & CleanStringType.CaseMask) == CleanStringType.None) { stringType |= CleanStringType.CamelCase; } if ((stringType & CleanStringType.CodeMask) == CleanStringType.None) { stringType |= CleanStringType.Ascii; } var codeType = stringType & CleanStringType.CodeMask; // apply pre-filter if (config.PreFilter != null) { text = config.PreFilter(text); } // apply replacements //if (config.Replacements != null) // text = ReplaceMany(text, config.Replacements); // recode text = Recode(text, stringType); // clean switch (codeType) { case CleanStringType.Ascii: // see note below - don't use CleanAsciiString //text = CleanAsciiString(text, stringType, separator); //break; case CleanStringType.Utf8: text = CleanUtf8String(text, stringType, separator, culture, config); break; case CleanStringType.Unicode: throw new NotImplementedException("DefaultShortStringHelper does not handle unicode yet."); default: throw new ArgumentOutOfRangeException("stringType"); } return(text); }