private static void Initialize() { if (_isInitialized) { return; } lock (_padLock) { if (_isInitialized) { return; } try { MetaDataFilepath = ConfigurationManager.AppSettings[PC_METADATA_FILEPATH_TAG]; if (MetaDataFilepath.IsNullOrWhiteSpace() || !File.Exists(MetaDataFilepath)) { MetaDataFilepath = ChoPath.AddExtension(Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(ChoApplication.ApplicationConfigFilePath), Path.GetFileNameWithoutExtension(ChoApplication.ApplicationConfigFilePath)), "perf"), ChoReservedFileExt.MetaData); } ChoXmlDocument.CreateXmlFileIfEmpty(MetaDataFilepath); Refresh(); } finally { _isInitialized = true; } } }
private static void Refresh() { try { LoadFile(); } catch (Exception ex) { ChoTrace.Error(ex); try { string newFile = ChoPath.AddExtension(MetaDataFilepath, ChoReservedFileExt.Err); if (File.Exists(newFile)) { File.Delete(newFile); } File.Move(MetaDataFilepath, newFile); ChoXmlDocument.CreateXmlFileIfEmpty(MetaDataFilepath); LoadFile(); } catch (Exception innerEx) { ChoTrace.Error(innerEx); } } }
public bool Initialize(bool beforeFieldInit, object state) { if (!beforeFieldInit) { ChoObjConfigurable.Load <IFormatProvider>(ChoPath.AddExtension(typeof(ChoFormatProviderSettings).FullName, ChoReservedFileExt.Log), ChoType.GetTypes <IFormatProvider>(), _formatProviders, FormatProviderTypes, ChoDefaultObjectKey.Name); } //else //ChoStreamProfile.Clean(ChoReservedDirectoryName.Settings, ChoPath.AddExtension(typeof(ChoFormatProviderSettings).FullName, ChoReservedFileExt.Err)); return(false); }
public void Initialize() { if (ConfigurationMetaDataFilePath.IsNullOrWhiteSpace()) { OverridenConfigurationMetaDataFilePath = ChoPath.AddExtension(Path.Combine(Path.GetDirectoryName(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath), ChoReservedDirectoryName.Meta, Path.GetFileNameWithoutExtension(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath)), ChoReservedFileExt.MetaData); } else { OverridenConfigurationMetaDataFilePath = ConfigurationMetaDataFilePath; } if (PCMetaDataFilePath.IsNullOrWhiteSpace()) { OverridenPCMetaDataFilePath = ChoPath.AddExtension(Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath), ChoReservedDirectoryName.Meta, Path.GetFileNameWithoutExtension(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath)), ChoReservedFileExt.Perf), ChoReservedFileExt.MetaData); } else { OverridenPCMetaDataFilePath = PCMetaDataFilePath; } if (ETLMetaDataFilePath.IsNullOrWhiteSpace()) { OverridenETLMetaDataFilePath = ChoPath.AddExtension(Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath), ChoReservedDirectoryName.Meta, Path.GetFileNameWithoutExtension(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath)), ChoReservedFileExt.ETL), ChoReservedFileExt.MetaData); } else { OverridenETLMetaDataFilePath = ETLMetaDataFilePath; } if (OverridenConfigurationMetaDataFilePath.IsNullOrWhiteSpace()) { throw new ApplicationException("ConfigurationMetaDataFilePath can not be null."); } if (OverridenPCMetaDataFilePath.IsNullOrWhiteSpace()) { throw new ApplicationException("PCMetaDataFilePath can not be null."); } if (OverridenETLMetaDataFilePath.IsNullOrWhiteSpace()) { throw new ApplicationException("ETLMetaDataFilePath can not be null."); } }
private void Refresh() { if (ChoAppFrxSettings.Me.DisableMetaDataConfig) { return; } try { LoadFile(); } catch (ChoFatalApplicationException) { throw; } catch (Exception ex) { ChoTrace.Error(ex); try { string newFile = ChoPath.AddExtension(MetaDataFilePath, ChoReservedFileExt.Err); if (File.Exists(newFile)) { File.Delete(newFile); } File.Move(MetaDataFilePath, newFile); ChoXmlDocument.CreateXmlFileIfEmpty(MetaDataFilePath); LoadFile(); } catch (Exception innerEx) { ChoTrace.Error(innerEx); } } }
public override ChoBaseConfigurationElement GetMe(Type type) { ChoGuard.ArgumentNotNull(type, "Type"); if (_configurationElement == null) { lock (SyncRoot) { if (_configurationElement == null) { object customConfigurationSectionHandler = Activator.CreateInstance(_configurationSectionHandlerType) as IChoCustomConfigurationSectionHandler; if (customConfigurationSectionHandler == null) { throw new ChoConfigurationConstructionException(String.Format("Missing {0} custom configuration section handler.", _configurationSectionHandlerType.FullName)); } if (!(customConfigurationSectionHandler is IChoCustomConfigurationSectionHandler)) { throw new ChoConfigurationConstructionException(String.Format("Mismatched {0} custom configuration section handler type specified.", _configurationSectionHandlerType.FullName)); } _configurationElement = new ChoCustomConfigurationElement(customConfigurationSectionHandler as IChoCustomConfigurationSectionHandler, _parameters); _configurationElement.DefaultConfigSectionHandlerType = ConfigSectionHandlerType; _configurationElement.ConfigFilePath = ConfigFilePath; ChoStandardConfigurationMetaDataInfo standardConfigurationMetaDataInfo = new ChoStandardConfigurationMetaDataInfo(); standardConfigurationMetaDataInfo.BindingMode = BindingMode; if (ConfigStorageType != null) { standardConfigurationMetaDataInfo.ConfigStorageType = ConfigStorageType.AssemblyQualifiedName; } standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo = new ChoConfigurationMetaDataLogInfo(); standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogCondition = LogCondition; standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogTimeStampFormat = LogTimeStampFormat; standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogDirectory = LogDirectory; standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogFileName = LogFileName.IsNullOrEmpty() ? ChoPath.AddExtension(type.FullName, ChoReservedFileExt.Log) : LogFileName; standardConfigurationMetaDataInfo.Defaultable = Defaultable; _configurationElement.MetaDataInfo = standardConfigurationMetaDataInfo; LoadParameters(_configurationElement); } } } return(_configurationElement); }
public ChoLoggableObject() { _logFileName = ChoPath.AddExtension(GetType().FullName, ChoReservedFileExt.Log); }
private void InitializeConfigElement(ChoBaseConfigurationElement configElement, Type type) { if (configElement == null) { return; } configElement.DefaultConfigSectionHandlerType = ConfigSectionHandlerType; configElement.ConfigFilePath = ConfigFilePath; ChoStandardConfigurationMetaDataInfo standardConfigurationMetaDataInfo = new ChoStandardConfigurationMetaDataInfo(); standardConfigurationMetaDataInfo.BindingMode = BindingMode; if (ConfigStorageType != null) { standardConfigurationMetaDataInfo.ConfigStorageType = ConfigStorageType.AssemblyQualifiedName; } standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo = new ChoConfigurationMetaDataLogInfo(); standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogCondition = LogCondition; standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogTimeStampFormat = LogTimeStampFormat; standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogDirectory = LogDirectory; standardConfigurationMetaDataInfo.ConfigurationMetaDataLogInfo.LogFileName = LogFileName.IsNullOrEmpty() ? ChoPath.AddExtension(type.FullName, ChoReservedFileExt.Log) : LogFileName; standardConfigurationMetaDataInfo.Defaultable = Defaultable; standardConfigurationMetaDataInfo.IgnoreCase = IgnoreCase; standardConfigurationMetaDataInfo.Silent = Silent; configElement.MetaDataInfo = standardConfigurationMetaDataInfo; LoadParameters(configElement); ChoConfigurationMetaDataManager.SetDefaultMetaDataInfo(configElement); }
internal void Refresh(bool refresh) { if (_inLoadingProcess) { return; } lock (SyncRoot) { if (ConfigObject is IChoConfigurationParametersOverridable) { ((IChoConfigurationParametersOverridable)ConfigObject).OverrideParameters(this); } _modifiedStateObject.ResetModified(); bool isDirty = false; bool errorHandled = false; bool canTraceOutput = true; bool hasErrors = false; this[ChoConfigurationConstants.FORCE_PERSIST] = false; _inLoadingProcess = true; ChoConfigSection prevConfigSection = ConfigSection; if (ConfigSection != null) { ConfigSection.StopWatching(); } try { if (ConfigObject != null) { //ChoConfigurationObjectErrorManagerService.ResetObjectErrors(ConfigObject); if (ConfigObject is ChoInterceptableObject) { ChoInterceptableObject interceptableObject = ConfigObject as ChoInterceptableObject; interceptableObject.SetDirty(false); interceptableObject.SetSilent(false); interceptableObject.SetInitialized(false); interceptableObject.IsConfigObjectSilent = Silent; } } GetConfig(ConfigObjectType, refresh); } catch (ConfigurationErrorsException configErrorsEx) { bool isModified = false; errorHandled = SetNThrowException(configErrorsEx, ref isModified); _modifiedStateObject.SetModified(isModified); } catch (TypeInitializationException typeEx) { bool isModified = false; errorHandled = SetNThrowException(typeEx, ref isModified); _modifiedStateObject.SetModified(isModified); } catch (ChoFatalApplicationException) { canTraceOutput = false; throw; } catch (Exception ex) { bool isModified = false; errorHandled = SetNThrowException(ex, ref isModified); _modifiedStateObject.SetModified(isModified); } finally { if (ConfigSection != null && ConfigObject is ChoConfigurableObject) { //Call Notify Property Changed for all default values CallNotifyPropertyChangedForAllDefaultableMembers(); ConfigSection.Initialize(); } if (ConfigSection != null && ConfigSection.ConfigLoadException != null) { bool isModified = false; errorHandled = SetNThrowException(ConfigSection.ConfigLoadException, ref isModified); _modifiedStateObject.SetModified(isModified); } ////Update configuration meta data information //if (ConfigSection != null && ConfigSection.MetaDataInfo != null) // ApplyConfigMetaData(ConfigSection.MetaDataInfo); //Print the output to file if (canTraceOutput) { //Set default trace output file name if (LogFileName.IsNullOrEmpty()) { LogFileName = ChoPath.AddExtension(ConfigObject.GetType().FullName, ChoReservedFileExt.Log); } //if (ConfigSection is IChoCustomConfigSection) //{ // if (ConfigSection.ConfigData != null) // ConfigSection.ConfigObject = ConfigSection.ConfigData as ChoConfigurableObject; // ChoObjectManagementFactory.SetInstance(ConfigObject); //} if ((ConfigSection == null || ConfigSection.ConfigData == null) && !_defaultable /*&& !_persistable*/) { throw new ChoConfigurationConstructionException(String.Format("Failed to load '[{0}]' configuration section.", this._configElementPath)); } else { if (prevConfigSection != null) { prevConfigSection.Dispose(); } if (ConfigObject is ChoConfigurableObject) { ((ChoConfigurableObject)ConfigObject).SetReadOnly(true); } bool hasConfigSectionDefined = ConfigSection != null ? ConfigSection.HasConfigSectionDefined : false; try { if (!errorHandled) { if (!(ConfigSection is IChoCustomConfigSection)) { if (hasConfigSectionDefined) { _modifiedStateObject.SetModified(ExtractNPopulateValues(ref hasErrors, ref isDirty)); } else { _modifiedStateObject.SetModified(AssignToFallbackOrDefaultValues(ref isDirty)); } } else { if (hasConfigSectionDefined) { //isModfied = true; if (ConfigSection == null) { _modifiedStateObject.SetModified(AssignToFallbackOrDefaultValues(ref isDirty)); } else if (!ChoObject.Equals(ConfigSection, prevConfigSection)) { _modifiedStateObject.SetModified(true); } else { _modifiedStateObject.SetModified(AssignToFallbackOrDefaultValues(ref isDirty)); } } else { _modifiedStateObject.SetModified(AssignToFallbackOrDefaultValues(ref isDirty)); } } } if (!hasErrors) { hasErrors = ChoConfigurationObjectErrorManagerService.ContainsObjectError(ConfigObject); } ChoObjectInitializer.Initialize(ConfigObject, false, ConfigSection != null ? ConfigObject : null); SetWatcher(false); if (ConfigObject is ChoInterceptableObject) { ChoInterceptableObject interceptableObject = ConfigObject as ChoInterceptableObject; if (interceptableObject.Dirty) { isDirty = interceptableObject.Dirty; } //if (interceptableObject.IsModified) //{ // isModfied = interceptableObject.IsModified; //} interceptableObject.SetDirty(false); //interceptableObject.SetSilent(false); interceptableObject.SetInitialized(true); } if (ConfigObject is ChoConfigurableObject) { bool invokeObjectLoaded = /* isDirty || */ _firstTime || _modifiedStateObject.IsModified; if (invokeObjectLoaded || hasErrors) { TraceOutput(false); if (invokeObjectLoaded) { ((ChoConfigurableObject)ConfigObject).RaiseAfterConfigurationObjectLoaded(); } } //if (isDirty) //{ // TraceOutput(false); // ((ChoConfigurableObject)ConfigObject).OnAfterConfigurationObjectLoaded(); //} //else if (hasErrors) // TraceOutput(false); } else { TraceOutput(false); } if (!isDirty && ConfigSection != null) { isDirty = ConfigSection.IsMetaDataDefinitionChanged; } } finally { if (prevConfigSection != null) { prevConfigSection.Dispose(); prevConfigSection = null; } if (ConfigObject is ChoConfigurableObject) { ((ChoConfigurableObject)ConfigObject).SetReadOnly(false); } if (!hasConfigSectionDefined || isDirty || hasErrors) { if (_defaultable) { Persist(false, null); } } else if ((bool)this[ChoConfigurationConstants.FORCE_PERSIST]) { Persist(false, null); } _inLoadingProcess = false; if (_watchChange && ConfigSection != null) { ConfigSection.StartWatching(); } ChoConfigurationObjectErrorManagerService.ResetObjectErrors(ConfigObject); _firstTime = false; } } } } } }
public override ChoBaseConfigurationElement GetMe(Type type) { ChoGuard.ArgumentNotNull(type, "Type"); if (_xmlConfigurationElement == null) { lock (_padLock) { if (_xmlConfigurationElement == null) { _xmlConfigurationElement = new ChoXmlConfigurationElement(ConfigElementPath, BindingMode, TraceOutputDirectory, TraceOutputFileName.IsNullOrEmpty() ? ChoPath.AddExtension(type.FullName, ChoReservedFileExt.Log) : TraceOutputFileName); _xmlConfigurationElement.DefaultConfigSectionHandlerType = ConfigSectionHandlerType; _xmlConfigurationElement.LogCondition = LogCondition; _xmlConfigurationElement.LogTimeStampFormat = LogTimeStampFormat; } } } return(_xmlConfigurationElement); }
private static void iniDocument_IgnoredEntry(object sender, ChoIniDocumentEventArgs e) { if (e == null || e.IniDocumentStates == null) { return; } foreach (ChoIniDocumentState iniDocumentState in e.IniDocumentStates) { ChoProfile.RegisterIfNotExists(iniDocumentState.IniFilePath, new ChoBufferProfileEx(ChoFileProfileSettings.GetFullPath(ChoReservedDirectoryName.Others, ChoPath.AddExtension(Path.GetFileName(iniDocumentState.IniFilePath), ChoReservedFileExt.Ignore)), "Entries Ignored are...")); ChoProfile.GetContext(iniDocumentState.IniFilePath).AppendLine(iniDocumentState.ToString()); } }
public void Initialize() { if (ApplicationBehaviourSettings == null) { ApplicationBehaviourSettings = new ChoApplicationBehaviourSettings(); } if (TrayApplicationBehaviourSettings == null) { TrayApplicationBehaviourSettings = new ChoTrayApplicationBehaviourSettings(); } if (LogSettings == null) { LogSettings = new ChoLogSettings(); } if (ApplicationName.IsNullOrWhiteSpace()) { try { ApplicationName = System.IO.Path.GetFileName(ChoAssembly.GetEntryAssemblyLocation()); } catch (System.Security.SecurityException ex) { ChoApplication.Trace(ChoTrace.ChoSwitch.TraceError, ex.ToString()); } } if (ApplicationName.IsNullOrEmpty()) { ChoApplication.OnFatalApplicationException(101, "Missing ApplicationName."); } ApplicationNameWithoutExtension = Path.GetFileNameWithoutExtension(ApplicationName); if (EventLogSourceName.IsNullOrWhiteSpace()) { EventLogSourceName = System.IO.Path.GetFileName(ChoAssembly.GetEntryAssemblyLocation()); } if (LogSettings.LogTimeStampFormat.IsNullOrWhiteSpace()) { LogSettings.LogTimeStampFormat = "yyyy-MM-dd hh:mm:ss.fffffff"; } if (LogSettings.LogFileName.IsNullOrWhiteSpace()) { LogSettings.LogFileName = ChoPath.ChangeExtension(ApplicationName, ChoReservedFileExt.Log); } LogSettings.LogFileName = ChoPath.CleanFileName(LogSettings.LogFileName); if (Path.IsPathRooted(LogSettings.LogFileName)) { LogSettings.LogFileName = Path.GetFileName(LogSettings.LogFileName); } try { DateTime.Now.ToString(LogSettings.LogTimeStampFormat); } catch (Exception ex) { ChoApplication.Trace(ChoTrace.ChoSwitch.TraceError, "Invalid LogTimeStampFormat '{0}' configured.".FormatString(LogSettings.LogTimeStampFormat)); ChoApplication.Trace(ChoTrace.ChoSwitch.TraceError, ex.ToString()); LogSettings.LogTimeStampFormat = "yyyy-MM-dd hh:mm:ss.fffffff"; } try { string sharedEnvConfigDir = null; if (!AppFrxConfigFilePath.IsNullOrEmpty()) { sharedEnvConfigDir = Path.GetDirectoryName(AppFrxConfigFilePath); } if (AppConfigFilePath.IsNullOrWhiteSpace()) { if (sharedEnvConfigDir.IsNullOrWhiteSpace()) { ApplicationConfigFilePath = ChoPath.GetFullPath(Path.Combine(ChoReservedDirectoryName.Config, ChoPath.AddExtension(ChoPath.CleanFileName(ApplicationName), ChoReservedFileExt.Xml))); } else { ApplicationConfigFilePath = Path.Combine(sharedEnvConfigDir, ChoPath.AddExtension(ChoPath.CleanFileName(ApplicationName), ChoReservedFileExt.Xml)); } } else { if (!Path.IsPathRooted(AppConfigFilePath)) { if (sharedEnvConfigDir.IsNullOrWhiteSpace()) { ApplicationConfigFilePath = ChoPath.GetFullPath(Path.Combine(ChoReservedDirectoryName.Config, AppConfigFilePath)); } else { ApplicationConfigFilePath = Path.Combine(sharedEnvConfigDir, AppConfigFilePath); } } else { ApplicationConfigFilePath = AppFrxConfigFilePath; } } ApplicationConfigDirectory = Path.GetDirectoryName(ApplicationConfigFilePath); } catch (System.Security.SecurityException ex) { // This security exception will occur if the caller does not have // some undefined set of SecurityPermission flags. ChoApplication.Trace(ChoTrace.ChoSwitch.TraceError, ex.ToString()); } #region Get HostName // Get the DNS host name of the current machine try { // Lookup the host name if (HostName.IsNullOrWhiteSpace()) { HostName = System.Net.Dns.GetHostName(); } } catch (System.Net.Sockets.SocketException) { } catch (System.Security.SecurityException) { // We may get a security exception looking up the hostname // You must have Unrestricted DnsPermission to access resource } // Get the NETBIOS machine name of the current machine if (HostName.IsNullOrWhiteSpace()) { try { HostName = Environment.MachineName; } catch (InvalidOperationException) { } catch (System.Security.SecurityException) { // We may get a security exception looking up the machine name // You must have Unrestricted EnvironmentPermission to access resource } } #endregion Get HostName #region Get IpAddresses try { IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); for (int i = 0; i < localIPs.Length; i++) { IPAddresses.Add(localIPs[i].ToString()); } } catch (System.Net.Sockets.SocketException) { } catch (System.Security.SecurityException) { // We may get a security exception looking up the hostname // You must have Unrestricted DnsPermission to access resource } #endregion Get IpAddresses if (LogSettings.TraceLevel < 0) { LogSettings.TraceLevel = 4; } if (!LogSettings.LogFolder.IsNullOrWhiteSpace()) { ApplicationLogDirectory = ChoString.ExpandProperties(LogSettings.LogFolder, ChoEnvironmentVariablePropertyReplacer.Instance); } //else // ApplicationLogDirectory = Path.Combine(Path.GetDirectoryName(ChoGlobalApplicationSettings.SharedEnvConfigPath), ChoReservedDirectoryName.Logs); if (ApplicationLogDirectory.IsNullOrWhiteSpace()) { if (ChoApplication.AppEnvironment.IsNullOrWhiteSpace()) { ApplicationLogDirectory = Path.Combine(ChoPath.AssemblyBaseDirectory, ChoReservedDirectoryName.Logs); } else { ApplicationLogDirectory = Path.Combine(ChoPath.AssemblyBaseDirectory, ChoReservedDirectoryName.Logs, ChoApplication.AppEnvironment); } } if (!Path.IsPathRooted(ApplicationLogDirectory)) { ApplicationLogDirectory = Path.Combine(ChoPath.AssemblyBaseDirectory, ApplicationLogDirectory); } if (ChoApplication.ApplicationMode == ChoApplicationMode.Service) { TrayApplicationBehaviourSettings.TurnOn = false; } }
public override ChoBaseConfigurationElement GetMe(Type type) { ChoGuard.ArgumentNotNull(type, "Type"); if (_configurationElement == null) { lock (SyncRoot) { if (_configurationElement == null) { _configurationElement = new ChoConfigurationElement(ConfigElementPath, BindingMode, TraceOutputDirectory, TraceOutputFileName.IsNullOrEmpty() ? ChoPath.AddExtension(type.FullName, ChoReservedFileExt.Log) : TraceOutputFileName); _configurationElement.DefaultConfigSectionHandlerType = ConfigSectionHandlerType; _configurationElement.Defaultable = Defaultable; _configurationElement.ConfigStorageType = ConfigStorageType; _configurationElement.LogCondition = LogCondition; _configurationElement.LogTimeStampFormat = LogTimeStampFormat; _configurationElement.ConfigFilePath = ConfigFilePath; _configurationElement[CONNECTION_STRING] = _connectionString; _configurationElement[TABLE_NAME] = _tableName; //_configurationElement[LAST_WRITE_TIME_COLUMN_NAME] = _lastWriteTimeColumnName; //if (!CreateTableSQL.IsNullOrWhiteSpace()) // _configurationElement[CREATE_TABLE_SQL] = CreateTableSQL; LoadParameters(_configurationElement); } } } return(_configurationElement); }
public bool Initialize(bool beforeFieldInit, object state) { if (beforeFieldInit) { return(false); } //REVISIT //ChoProfile.InitializeProfile(GetType()); ChoDictionary <string, string> typeShortNameMap = ChoDictionary <string, string> .Synchronized(new ChoDictionary <string, string>()); using (ChoBufferProfileEx errProfile = ChoBufferProfileEx.DelayedAutoStart(new ChoBufferProfileEx(true, ChoPath.AddExtension(typeof(ChoTypeFactory).FullName, ChoReservedFileExt.Err), "Below are the duplicate type short names founds..."))) { foreach (Type type in ChoType.GetTypes(typeof(ChoTypeShortNameAttribute))) { ChoTypeShortNameAttribute typeShortNameAttribute = ChoType.GetAttribute <ChoTypeShortNameAttribute>(type); AddToMap(typeShortNameMap, errProfile, type, typeShortNameAttribute.Name, false); } if (ChoShortTypeNameSettings.Me.ValidTypsShortNames != null) { foreach (ChoTypsShortName typsShortName in ChoShortTypeNameSettings.Me.ValidTypsShortNames) { if (typsShortName.Type == null) { continue; } AddToMap(typeShortNameMap, errProfile, typsShortName.Type, typsShortName.TypeShortName, typsShortName.Override); } } } lock (_padLock) { _typeShortNameMap = typeShortNameMap; } return(false); }
internal void PostInitialize() { if (ApplicationName.IsNullOrEmpty()) { ChoEnvironment.Exit(101, "Missing ApplicationName."); } if (EventLogSourceName.IsNullOrWhiteSpace()) { EventLogSourceName = System.IO.Path.GetFileName(ChoAssembly.GetEntryAssemblyLocation()); } if (LogSettings.LogTimeStampFormat.IsNullOrWhiteSpace()) { LogSettings.LogTimeStampFormat = "yyyy-MM-dd hh:mm:ss.fffffff"; } if (LogSettings.LogFileName.IsNullOrWhiteSpace()) { LogSettings.LogFileName = ChoPath.ChangeExtension(ApplicationName, ChoReservedFileExt.Log); } LogSettings.LogFileName = ChoPath.CleanFileName(LogSettings.LogFileName); if (Path.IsPathRooted(LogSettings.LogFileName)) { LogSettings.LogFileName = Path.GetFileName(LogSettings.LogFileName); } try { DateTime.Now.ToString(LogSettings.LogTimeStampFormat); } catch (Exception ex) { ChoApplication.Trace(ChoTraceSwitch.Switch.TraceError, "Invalid LogTimeStampFormat '{0}' configured.".FormatString(LogSettings.LogTimeStampFormat)); ChoApplication.Trace(ChoTraceSwitch.Switch.TraceError, ex.ToString()); LogSettings.LogTimeStampFormat = "yyyy-MM-dd hh:mm:ss.fffffff"; } try { string sharedEnvConfigDir = null; if (!AppFrxConfigFilePath.IsNullOrEmpty()) { sharedEnvConfigDir = Path.GetDirectoryName(ChoPath.GetFullPath(AppFrxConfigFilePath)); } if (AppConfigFilePath.IsNullOrWhiteSpace()) { if (sharedEnvConfigDir.IsNullOrWhiteSpace()) { ApplicationConfigFilePath = ChoPath.GetFullPath(Path.Combine(ChoReservedDirectoryName.Config, ChoPath.AddExtension(ChoPath.CleanFileName(ApplicationName), ChoReservedFileExt.Xml))); } else { ApplicationConfigFilePath = Path.Combine(sharedEnvConfigDir, ChoPath.AddExtension(ChoPath.CleanFileName(ApplicationName), ChoReservedFileExt.Xml)); } } else { if (!Path.IsPathRooted(AppConfigFilePath)) { if (sharedEnvConfigDir.IsNullOrWhiteSpace()) { ApplicationConfigFilePath = ChoPath.GetFullPath(Path.Combine(ChoReservedDirectoryName.Config, AppConfigFilePath)); } else { ApplicationConfigFilePath = Path.Combine(sharedEnvConfigDir, AppConfigFilePath); } } else { ApplicationConfigFilePath = AppConfigFilePath; } } ApplicationConfigDirectory = Path.GetDirectoryName(ChoPath.GetFullPath(ApplicationConfigFilePath)); AppFrxConfigFilePath = Path.Combine(ApplicationConfigDirectory, ChoReservedFileName.CoreFrxConfigFileName); } catch (System.Security.SecurityException ex) { // This security exception will occur if the caller does not have // some undefined set of SecurityPermission flags. ChoApplication.Trace(ChoTraceSwitch.Switch.TraceError, ex.ToString()); } if (!LogSettings.LogFolder.IsNullOrWhiteSpace()) { ApplicationLogDirectory = ChoString.ExpandProperties(LogSettings.LogFolder, ChoEnvironmentVariablePropertyReplacer.Instance); } if (ApplicationLogDirectory.IsNullOrWhiteSpace()) { if (ChoApplication.AppEnvironment.IsNullOrWhiteSpace()) { ApplicationLogDirectory = Path.Combine(ChoPath.AssemblyBaseDirectory, ChoReservedDirectoryName.Logs); } else { ApplicationLogDirectory = Path.Combine(ChoPath.AssemblyBaseDirectory, ChoReservedDirectoryName.Logs, ChoApplication.AppEnvironment); } } if (!Path.IsPathRooted(ApplicationLogDirectory)) { ApplicationLogDirectory = Path.Combine(ChoPath.AssemblyBaseDirectory, ApplicationLogDirectory); } if (ChoApplication.ApplicationMode == ChoApplicationMode.Service) { TrayApplicationBehaviourSettings.TurnOn = false; } }
public ChoLoggableObject GetMe(Type type) { ChoGuard.ArgumentNotNull(type, "Type"); if (_singletonElement == null) { lock (SyncRoot) { if (_singletonElement == null) { _singletonElement = new ChoSingletonLoggableObject(); _singletonElement.LogDirectory = LogDirectory; _singletonElement.LogFileName = LogFileName.IsNullOrEmpty() ? ChoPath.AddExtension(type.FullName, ChoReservedFileExt.Log) : LogFileName; _singletonElement.LogCondition = LogCondition; _singletonElement.LogTimeStampFormat = LogTimeStampFormat; } } } return(_singletonElement); }