/// <summary> /// Fabrica de Itargets . Crea un ITarget sin basarce en archivo de configuración.- /// </summary> /// <param name="targetType"></param> /// <param name="key">Clave del Target. La clave sera ademas utiliza como /// Si es DatabaseTarget --> CnnStringName /// Si es TargetType --> FileName /// Si es Xml --> FileName /// </param> /// <returns></returns> public static ITarget TargetFactory(TargetType targetType, string key) { ITarget wITarget = null; if (_Targets.ContainsKey(key)) { wITarget = _Targets[key]; } //Si no existe se crea if (wITarget == null) { switch (targetType) { case TargetType.Database: { wITarget = new DatabaseTarget(); ((DatabaseTarget)wITarget).CnnStringName = key; break; } case TargetType.File: { wITarget = new FileTarget(); ((FileTarget)wITarget).FileName = key; //fullFileName; break; } case TargetType.WindowsEvent: { return(new WindowsEventTarget()); } case TargetType.Xml: { wITarget = new XmlTarget(); ((XmlTarget)wITarget).FileName = key; break; } } } //Si no existe ahora lo agrega if (!_Targets.ContainsKey(key)) { _Targets.Add(key, wITarget); } return(wITarget); }
ITarget GetTarget(string providerName) { ITarget target = null; LogProviderElement provider = _LoggingSection.GetProvider(providerName); switch (provider.Target) { case TargetType.Database: { target = new DatabaseTarget(); ((DatabaseTarget)target).CnnStringName = provider.CnnStringName; break; } case TargetType.Xml: { target = new XmlTarget(); ((XmlTarget)target).FileName = provider.FileName; break; } } return target; }
/// <summary> /// Fabrica de Itargets . Crea un ITarget sin basarce en archivo de configuración.- /// </summary> /// <param name="targetType"></param> /// <param name="key">Clave del Target. La clave sera ademas utiliza como /// Si es DatabaseTarget --> CnnStringName /// Si es TargetType --> FileName /// Si es Xml --> FileName /// </param> /// <returns></returns> public static ITarget TargetFactory(TargetType targetType, string key) { ITarget wITarget = null; if(_Targets.ContainsKey(key)) wITarget = _Targets[key]; //Si no existe se crea if (wITarget == null) { switch (targetType) { case TargetType.Database: { wITarget = new DatabaseTarget(); ((DatabaseTarget)wITarget).CnnStringName = key; break; } case TargetType.File: { wITarget = new FileTarget(); ((FileTarget)wITarget).FileName = key;//fullFileName; break; } case TargetType.WindowsEvent: { return new WindowsEventTarget(); } case TargetType.Xml: { wITarget = new XmlTarget(); ((XmlTarget)wITarget).FileName = key; break; } } } //Si no existe ahora lo agrega if (!_Targets.ContainsKey(key)) _Targets.Add(key, wITarget); return wITarget; }
/// <summary> /// /// </summary> /// <param name="providerElement"></param> /// <returns></returns> private Target GetTargetByProviderElement(LogProviderElement providerElement) { switch (providerElement.Target) { case TargetType.Database: { DatabaseTarget wDatabase = new DatabaseTarget(); wDatabase.CnnStringName = providerElement.CnnStringName; return wDatabase; } case TargetType.File: { FileTarget wFile = new FileTarget(); wFile.FileName = providerElement.FileName; return wFile; } case TargetType.WindowsEvent: { return new WindowsEventTarget(); } case TargetType.Xml: { XmlTarget wXml = new XmlTarget(); wXml.FileName = providerElement.FileName; return wXml; } } return null; }