private static void Add <T>(string logFileName, ChoDictionary <string, T> objDictionary, ChoTypeNameSpecifier defaultObjectKey, string typeName) where T : class { try { T obj = ChoObjectManagementFactory.CreateInstance(typeName) as T; if (obj != null) { string key; if (obj is IChoObjectNameable) { key = ((IChoObjectNameable)obj).Name; } else { key = ChoObjectNameableAttribute.GetName(obj.GetType(), defaultObjectKey); } ChoGuard.NotNullOrEmpty(key, String.Format("{0}: Name can't be empty.", typeName)); if (!objDictionary.ContainsKey(key)) { objDictionary.Add(key, obj); } } //else // ChoStreamProfile.WriteLine(ChoReservedDirectoryName.Settings, Path.ChangeExtension(logFileName, ChoReservedFileExt.Err), // String.Format("Failed to create {0} object.", typeName)); } catch (Exception) { //ChoStreamProfile.WriteLine(ChoReservedDirectoryName.Settings, Path.ChangeExtension(logFileName, ChoReservedFileExt.Err), // String.Format("Failed to create {0} object. {1}", typeName, ex.Message)); } }
/// <summary> /// Initialize a new instance of the <see cref="ChoConfigurationSectionAttribute"/> class with the configuration element name. /// </summary> /// <param name="configElementPath">The <see cref="string"/> configuration element name.</param> public ChoRegistryConfigurationSectionAttribute(string configElementPath, string registryKey) : base(configElementPath) { ChoGuard.NotNullOrEmpty(registryKey, REG_KEY); _registryKey = registryKey; }
/// <summary> /// CustomDictionarytialize a new instance of the <see cref="ChoConfigurationSectionAttribute"/> class with the configuration element name. /// </summary> /// <param name="configElementPath">The <see cref="string"/> configuration element name.</param> public ChoDictionaryAdapterConfigurationSectionAttribute(string configElementPath, string configObjectAdapterType, string configObjectAdapterParams = null) : base(configElementPath) { ChoGuard.NotNullOrEmpty(configObjectAdapterType, CONFIG_OBJECT_ADAPTER_TYPE); _configObjectAdapterType = configObjectAdapterType; _configObjectAdapterParams = configObjectAdapterParams; }
/// <summary> /// Initialize a new instance of the <see cref="ChoConfigurationSectionAttribute"/> class with the configuration element name. /// </summary> /// <param name="configElementPath">The <see cref="string"/> configuration element name.</param> public ChoIniConfigurationSectionAttribute(string configElementPath, string iniSectionName, string iniFilePath) : base(configElementPath) { ChoGuard.NotNullOrEmpty(iniSectionName, INI_SECTION_NAME); ChoGuard.NotNullOrEmpty(iniFilePath, INI_FILE_PATH); _iniSectionName = iniSectionName; _iniFilePath = iniFilePath; }
/// <summary> /// Initialize a new instance of the <see cref="ChoConfigurationSectionAttribute"/> class with the configuration element name. /// </summary> /// <param name="configElementPath">The <see cref="string"/> configuration element name.</param> public ChoODBCConfigurationSectionAttribute(string configElementPath, string connectionString, string tableName, string lastWriteTimeColumnName) : base(configElementPath) { ChoGuard.NotNullOrEmpty(connectionString, CONNECTION_STRING); ChoGuard.NotNullOrEmpty(tableName, TABLE_NAME); //ChoGuard.NotNullOrEmpty(lastWriteTimeColumnName, LAST_WRITE_TIME_COLUMN_NAME); _connectionString = connectionString; _tableName = tableName; _lastWriteTimeColumnName = lastWriteTimeColumnName; }