/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public CachedLog(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "Log") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"Log\". Configuration Key={configuration.Key}", nameof(configuration)); } // Log if (!configuration.ContainsKey("Log")) { throw new ArgumentException($"Configuration missing subgroup. Configuration must have subgroup: \"Log\".", nameof(configuration)); } InnerLog = (ILog)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(null, configuration["Log"]); InnerLog.Open(); // AutoFlushLogs AutoFlushEnabled = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "AutoFlushLogs", typeof(bool)).Value; // FlushMaximumLogs FlushMaximumLogs = (int)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "FlushMaximumLogs", typeof(int)).Value; // FlushTimeLimit FlushTimeLimit = (TimeSpan)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "FlushTimeLimit", typeof(TimeSpan)).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public InstallationSettings(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "InstallationSettings") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"InstallationSettings\". Configuration Key={configuration.Key}", nameof(configuration)); } // InstallType // TODO: add support for using a typeof(string) instead of a typeof(Installation.InstallType) // this would allow for a simpler configuration file item: it would not have the full type name of the ENUM, just SYSTEM.STRING InstallType = (Installation.InstallType)Enum.Parse(typeof(Installation.InstallType), (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "InstallType", typeof(Installation.InstallType)).Value, true); // CleanInstall CleanInstall = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "CleanInstall", typeof(bool)).Value; // EnablePackageUpdates EnablePackageUpdates = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "EnablePackageUpdates", typeof(bool)).Value; // RemoveOrphanedPackages RemoveOrphanedPackages = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "RemoveOrphanedPackages", typeof(bool)).Value; // UpdatePackagesBeforeInstalling UpdatePackagesBeforeInstalling = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "UpdatePackagesBeforeInstalling", typeof(bool)).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public TransportController(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "TransportController") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"TransportController\". Configuration Key={configuration.Key}", nameof(configuration)); } // _TransportConfiguration if (configuration.ContainsKey("TransportConfiguration")) { TransportConfiguration = (ITransportConfiguration)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(TransportConfiguration), configuration["TransportConfiguration"]); } // _RegistrationController if (!configuration.ContainsKey("RegistrationController")) { throw new ArgumentException($"Configuration missing subgroup. Configuration must have subgroup: \"RegistrationController\".", nameof(configuration)); } if ((!configuration["RegistrationController"].ContainsKey("TransportConfiguration")) && (configuration.ContainsKey("TransportConfiguration"))) { configuration["RegistrationController"].Add(configuration["TransportConfiguration"]); } RegistrationController = (IRegistrationController)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(null, configuration["RegistrationController"]); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public Log(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "Log") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"Log\". Configuration Key={configuration.Key}", nameof(configuration)); } // _LogFilename //LogFilename = Core.Configuration.ConfigurationHelper.FindConfigurationItemValue<string>(configuration, "LogFilename"); if (!Core.Configuration.ConfigurationHelper.TryFindConfigurationItemValue(configuration, "LogFilename", out string _logfilename, out Exception logFilenameException)) { throw logFilenameException; } LogFilename = _logfilename; if (string.IsNullOrWhiteSpace(LogFilename)) { throw new Exception($"Configuration item missing information. Configuration item \"LogFilename\" must contain a value."); } // _WriteLogEntriesUsingLocalTime _WriteLogEntriesUsingLocalTime = Core.Configuration.ConfigurationHelper.FindConfigurationItemValue <bool>(configuration, "WriteLogEntriesUsingLocalTime"); // _AutoTruncateLogFile AutoTruncateEnabled = Core.Configuration.ConfigurationHelper.FindConfigurationItemValue <bool>(configuration, "AutoTruncateLogFile"); // _MaxLogSizeBytes LogFileSizeMaximumBytes = Core.Configuration.ConfigurationHelper.FindConfigurationItemValue <long>(configuration, "MaxLogSizeBytes"); // _LogsToRetain LogsToRetain = Core.Configuration.ConfigurationHelper.FindConfigurationItemValue <int>(configuration, "LogsToRetain"); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public ServerConfiguration(Configuration.IConfigurationGroup configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "ServerConfiguration") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"ServerConfiguration\". Configuration Key={configuration.Key}", nameof(configuration)); } // Id Id = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Id", typeof(string)).Value; // list: OverrideTypesFilter var overrideFilterList = new List <IPayloadTypeInfo>(); var overrideTypeFilterGroup = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "OverrideTypesFilter", true); foreach (var item in overrideTypeFilterGroup) { ((Configuration.IConfigurationGroupAdvanced)item).SetKey("PayloadTypeInfo"); overrideFilterList.Add((IPayloadTypeInfo)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(PayloadTypeInfo), item)); } if (overrideFilterList.Count > 0) { ReplaceOverrideTypesFilter(overrideFilterList); } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public DependencyPackage(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (!configuration.Key.StartsWith("DependencyPackage")) { throw new ArgumentException($"Wrong configuration. Configuration Key must begin with \"DependencyPackage\". Configuration Key={configuration.Key}", nameof(configuration)); } // Name var temp1 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Name", typeof(string)).Value; if (string.IsNullOrWhiteSpace(temp1)) { throw new Exception($"Configuration invalid information. Configuration item: \"Name\" cannot be empty."); } Name = temp1; // MinimumVersion MinimumVersion = (Version)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "MinimumVersion", typeof(Version)).Value; // SpecificVersion try { SpecificVersion = (Version)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SpecificVersion", typeof(Version)).Value; } catch { } }
/// <summary> /// Instantiates a new <see cref="ReadPackageCustomConfigurationResponse"/> with the given package and custom configuration. /// </summary> /// <param name="request">The package to get the custom configuration from.</param> /// <param name="configuration">The custom configuration for the package.</param> public ReadPackageCustomConfigurationResponse(ReadPackageCustomConfiguration request, Configuration.IConfigurationGroup configuration) : this() { SourcePackage = request ?? throw new ArgumentNullException(nameof(request)); Configuration = configuration; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public FolderAccessItems(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "FolderAccessItems") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"FolderAccessItems\". Configuration Key={configuration.Key}", nameof(configuration)); } // special folders var specialFolders = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "SpecialFolders", false); if (specialFolders != null) { foreach (var item in specialFolders.Items) { _Folders.Add(new FolderAccessItem(item.Value as string, item.Key)); } } // non-special folders var nonSpecialFolders = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "Folders", false); if (nonSpecialFolders != null) { foreach (var item in nonSpecialFolders.Items) { _Folders.Add(new FolderAccessItem(item.Value as string)); } } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public StackableEncryptor(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "Encryptor") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"Encryptor\". Configuration Key={configuration.Key}", nameof(configuration)); } // EncryptorConfigurations if (!configuration.ContainsKey("EncryptorConfigurations")) { throw new ArgumentException($"Configuration missing subgroup. Configuration must have subgroup: \"EncryptorConfigurations\".", nameof(configuration)); } _EncryptorConfigurations = new List <IEncryptorConfiguration>(); foreach (var item in configuration["EncryptorConfigurations"]) { // TODO: change this configuration item name to HashAlgorithmType to be consistent // HashAlgorithm var hashAlgorithmType = Type.GetType((string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "HashAlgorithm", typeof(Type)).Value); // Salt var saltValue = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Salt", typeof(string)).Value; byte[] salt = Convert.FromBase64String(saltValue); // PasswordSaltHash var passwordSaltHashValue = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "PasswordSaltHash", typeof(string)).Value; byte[] passwordSaltHash = Convert.FromBase64String(passwordSaltHashValue); // SymmetricAlgorithmType Type symmetricAlgorithmType = Type.GetType((string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SymmetricAlgorithmType", typeof(Type)).Value); ISaltedPassword saltedPassword = new SaltedPassword(hashAlgorithmType, passwordSaltHash, salt); var dude = new EncryptorConfiguration(saltedPassword, symmetricAlgorithmType); _EncryptorConfigurations.Add(dude); } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public PackageProvider(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "PackageProvider") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"PackageProvider\". Configuration Key={configuration.Key}", nameof(configuration)); } // _AllPackagesFileStore var fileStoreConfig = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "FileStore", true); // add support for the ExtractionRootDirectory to be an empty string. Empty string equates to using the current user's temporary folder. if ((!fileStoreConfig.Items.ContainsKey("ExtractionRootDirectory")) || (fileStoreConfig.Items["ExtractionRootDirectory"].Value.ToString() == "")) { fileStoreConfig.Items.Add("ExtractionRootDirectory", System.IO.Path.GetTempPath(), typeof(string)); } _AllPackagesFileStore = (FileStorage.IFileStore)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(fileStoreConfig); // configurationFilename _ConfigurationFilename = Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationItem <string>(configuration, "ConfigurationFilename", true); // serializer _ConfigurationSerializer = Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationItem <Core.Configuration.IConfigurationSerializer <StringBuilder> >(configuration, "ConfigurationFileSerializer", true); // packageFileStoreProvider PackageFileStoreProvider = Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationItem <IPackageFileStoreProvider>(configuration, "PackageFileStoreProvider", true); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public NullRegistrationController(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "RegistrationController") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"RegistrationController\". Configuration Key={configuration.Key}", nameof(configuration)); } // _TransportConfiguration if (configuration.ContainsKey("TransportConfiguration")) { TransportConfiguration = (ITransportConfiguration)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(TransportConfiguration), configuration["TransportConfiguration"]); } // _ChallengeController if (configuration.ContainsKey("ChallengeController")) { ChallengeController = (IChallengeController)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(null, configuration["ChallengeController"]); } else if (configuration.Items.ContainsKey("Evidence")) { if (!configuration.Items["Evidence"].ValueType.StartsWith(typeof(byte[]).FullName)) { throw new Exception($"Configuration item invalid format. Configuration item \"Evidence\" must be a <{typeof(byte[])}>."); } _ChallengeEvidence = (byte[])configuration.Items["Evidence"].Value; } else { throw new ArgumentException($"Configuration missing information. Configuration must have either an \"Evidence\" item or a \"ChallengeController\" subgroup.", nameof(configuration)); } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public LogControllerSettings(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "LogControllerSettings") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"LogControllerSettings\". Configuration Key={configuration.Key}", nameof(configuration)); } // SystemSourceId var temp1 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "LogSourceId", typeof(string)).Value; if (string.IsNullOrWhiteSpace(temp1)) { throw new Exception($"Configuration invalid information. Configuration item: \"LogSourceId\" cannot be empty."); } LogSourceId = temp1; // AutoFlushMaximumLogs var temp2 = (int)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "AutoFlushMaximumLogs", typeof(int)).Value; if (temp2 < MinimumAutoFlushLogsCount_) { throw new Exception($"AutoFlushMaximumLogs must be greater than {MinimumAutoFlushLogsCount_}."); } AutoFlushMaximumLogs = temp2; // AutoFlushTimeLimit var temp3 = (TimeSpan)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "AutoFlushTimeLimit", typeof(TimeSpan)).Value; if (temp3 < MinimumAutoFlushTimeLimit_) { throw new Exception($"AutoFlushTimeLimit must be greater than {MinimumAutoFlushTimeLimit_}."); } AutoFlushTimeLimit = temp3; // AutoArchiveEnabled AutoArchiveEnabled = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "AutoArchiveEnabled", typeof(bool)).Value; // AutoArchiveMaximumLogs var temp4 = (int)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "AutoArchiveMaximumLogs", typeof(int)).Value; if (temp4 < MinimumAutoArchiveLogsCount_) { throw new Exception($"AutoFlushMaximumLogs must be greater than {MinimumAutoArchiveLogsCount_}."); } AutoArchiveMaximumLogs = temp4; // WriteArchivedLogEntriesUsingLocalTime WriteArchivedLogEntriesUsingLocalTime = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "WriteArchivedLogEntriesUsingLocalTime", typeof(bool)).Value; // WritePrimaryLogEntriesUsingLocalTime WritePrimaryLogEntriesUsingLocalTime = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "WritePrimaryLogEntriesUsingLocalTime", typeof(bool)).Value; // TruncateLogArchive TruncateLogArchive = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "TruncateLogArchive", typeof(bool)).Value; // TruncateLogArchiveMaximumFiles TruncateLogArchiveMaximumFiles = (int)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "TruncateLogArchiveMaximumFiles", typeof(int)).Value; // TruncateLogArchivePercentageToRemove TruncateLogArchivePercentageToRemove = (double)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "TruncateLogArchivePercentageToRemove", typeof(double)).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public NullChallengeController(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "ChallengeController") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"ChallengeController\". Configuration Key={configuration.Key}", nameof(configuration)); } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public NullEncryptor(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "Encryptor") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"Encryptor\". Configuration Key={configuration.Key}", nameof(configuration)); } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public TransportConfiguration(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "TransportConfiguration") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"TransportConfiguration\". Configuration Key={configuration.Key}", nameof(configuration)); } // Compressor CompressorType = Type.GetType((string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Compressor", typeof(Type)).Value); // UseChunking UseChunking = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "UseChunking", typeof(bool)).Value; // ChunkSize var chunkSize = (int)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "ChunkSize", typeof(int)).Value; if (chunkSize < NetworkingHelper.MinimumTransportEnvelopeChunkSize) { throw new ArgumentOutOfRangeException(string.Format("ChunkSize too small. Minimum Chunk Size= {0}", NetworkingHelper.MinimumTransportEnvelopeChunkSize)); } ChunkSize = chunkSize; // EnvelopeCacheTimeLimit var envelopeCacheTimeLimit = (TimeSpan)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "EnvelopeCacheTimeLimit", typeof(TimeSpan)).Value; if (envelopeCacheTimeLimit < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("EnvelopeCacheTimeLimit cannot be less than TimeSpan.Zero."); } EnvelopeCacheTimeLimit = envelopeCacheTimeLimit; // SeenMessageCacheTimeLimit var seenMessageCacheTimeLimit = (TimeSpan)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SeenMessageCacheTimeLimit", typeof(TimeSpan)).Value; if (seenMessageCacheTimeLimit < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("SeenMessageCacheTimeLimit cannot be less than TimeSpan.Zero."); } SeenMessageCacheTimeLimit = seenMessageCacheTimeLimit; // EncryptorConfigurations if (configuration.ContainsKey("EncryptorConfigurations")) { var configs = new List <Cryptography.IEncryptorConfiguration>(); foreach (var group in configuration["EncryptorConfigurations"]) { ((dodSON.Core.Configuration.IConfigurationGroupAdvanced)group).SetKey("EncryptorConfiguration"); var dude = (Cryptography.IEncryptorConfiguration)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(Cryptography.EncryptorConfiguration), group); configs.Add(dude); } EncryptorConfigurations = configs; } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public IniConfigurationSerializer(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "Serializer") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"Serializer\". Configuration Key={configuration.Key}", nameof(configuration)); } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public PasswordChallengeController(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "ChallengeController") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"ChallengeController\". Configuration Key={configuration.Key}", nameof(configuration)); } // Evidence Evidence = (byte[])Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Evidence", typeof(byte[])).Value; }
/// <summary> /// Instantiates a new <see cref="WriteInstalledCustomConfiguration"/> with the given name, version and custom configuration. /// </summary> /// <param name="name">The name of the installed package to write the custom configuration to.</param> /// <param name="version">The version of the installed package to write the custom configuration to.</param> /// <param name="configuration">The <see cref="Configuration.IConfigurationGroup"/> to write to the custom configuration file. Can be null; null will delete the custom configuration file.</param> public WriteInstalledCustomConfiguration(string name, Version version, Configuration.IConfigurationGroup configuration) : this() { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } Name = name; // Version = version ?? throw new ArgumentNullException(nameof(version)); // Configuration = configuration; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public PayloadTypeInfo(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "PayloadTypeInfo") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"PayloadTypeInfo\". Configuration Key={configuration.Key}", nameof(configuration)); } // TypeName TypeName = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "TypeName", typeof(string)).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public ClientConfiguration(Configuration.IConfigurationGroup configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "ClientConfiguration") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"ClientConfiguration\". Configuration Key={configuration.Key}", nameof(configuration)); } // Id Id = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Id", typeof(string)).Value; // ReceiveSelfSentMessages ReceiveSelfSentMessages = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "ReceiveSelfSentMessages", typeof(bool)).Value; // list: ReceivableTypesFilter var receivableTypesFilterList = new List <IPayloadTypeInfo>(); var receivableTypesFilterGroup = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "ReceivableTypesFilter", false); if (receivableTypesFilterGroup != null) { foreach (var item in receivableTypesFilterGroup) { ((Configuration.IConfigurationGroupAdvanced)item).SetKey("PayloadTypeInfo"); receivableTypesFilterList.Add((IPayloadTypeInfo)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(PayloadTypeInfo), item)); } if (receivableTypesFilterList.Count > 0) { ReplaceReceivableTypesFilter(receivableTypesFilterList); } } // list: TransmittableTypesFilter var transmittableTypesFilterList = new List <IPayloadTypeInfo>(); var transmittableTypesFilterGroup = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "TransmittableTypesFilter", false); if (transmittableTypesFilterGroup != null) { foreach (var item in transmittableTypesFilterGroup) { ((Configuration.IConfigurationGroupAdvanced)item).SetKey("PayloadTypeInfo"); transmittableTypesFilterList.Add((IPayloadTypeInfo)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(PayloadTypeInfo), item)); } if (transmittableTypesFilterList.Count > 0) { ReplaceTransmittableTypesFilter(transmittableTypesFilterList); } } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public ChannelAddress(Configuration.IConfigurationGroup configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "ChannelAddress") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"ChannelAddress\". Configuration Key={configuration.Key}", nameof(configuration)); } // IPAddress IPAddress = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "IPAddress", typeof(string)).Value; // Name Name = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Name", typeof(string)).Value; // Port Port = (int)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Port", typeof(int)).Value; }
/// <summary> /// Instantiates a new instance of a <see cref="ComponentFactory"/> with the given id and <see cref="Addon.IAddonFactory"/>. /// </summary> /// <param name="id">The unique id representing this <see cref="ComponentFactory"/>.</param> /// <param name="addonFactory">The <see cref="Addon.IAddonFactory"/> needed to create and control this extension, or plugin.</param> /// <param name="packageConfiguration">The <see cref="Packaging.IPackageConfiguration"/> for the package this component was located in.</param> /// <param name="customConfiguration">The custom configuration, if found; otherwise, null.</param> /// <param name="installationRootPath">The root path where the <see cref="Installation.IInstaller"/> installs packages.</param> /// <param name="installPath">The install directory path where this component's package has been installed.</param> /// <param name="temporaryPath">A temporary folder for the <see cref="IComponent"/> to use.</param> /// <param name="longTermStoragePath">A permanent folder for the <see cref="IComponent"/> to use.</param> /// <param name="folderAccessItems">A collection of folders.</param> public ComponentFactory(string id, Addon.IAddonFactory addonFactory, Packaging.IPackageConfiguration packageConfiguration, Configuration.IConfigurationGroup customConfiguration, string installationRootPath, string installPath, string temporaryPath, string longTermStoragePath, IFolderAccessItems folderAccessItems) : this() { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException(nameof(id)); } Id = id; _AddonFactory = addonFactory ?? throw new ArgumentNullException(nameof(addonFactory)); PackageConfiguration = packageConfiguration ?? throw new ArgumentNullException(nameof(packageConfiguration)); CustomConfiguration = customConfiguration; // if (string.IsNullOrWhiteSpace(installationRootPath)) { throw new ArgumentNullException(nameof(installationRootPath)); } _InstallationRootPath = installationRootPath; // if (string.IsNullOrWhiteSpace(installPath)) { throw new ArgumentNullException(nameof(installPath)); } _InstallPath = installPath; // if (string.IsNullOrWhiteSpace(temporaryPath)) { throw new ArgumentNullException(nameof(temporaryPath)); } _TemporaryPath = temporaryPath; // if (string.IsNullOrWhiteSpace(longTermStoragePath)) { throw new ArgumentNullException(nameof(longTermStoragePath)); } _LongTermStoragePath = longTermStoragePath; // _FolderAccessItems = folderAccessItems ?? throw new ArgumentNullException(nameof(folderAccessItems)); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public SaltedPassword(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "SaltedPassword") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"SaltedPassword\". Configuration Key={configuration.Key}", nameof(configuration)); } // HashAlgorithmType HashAlgorithmType = Type.GetType((string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "HashAlgorithmType", typeof(Type)).Value); // PasswordSaltHash PasswordSaltHash = (byte[])Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "PasswordSaltHash", typeof(byte[])).Value; // Salt Salt = (byte[])Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Salt", typeof(byte[])).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public FileStore(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "FileStore") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"FileStore\". Configuration Key={configuration.Key}", nameof(configuration)); } // BackendStorageZipFilename var temp1 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "BackendStorageZipFilename", typeof(string)).Value; // if (string.IsNullOrWhiteSpace(temp1)) { throw new Exception($"Configuration invalid information. Configuration item: \"BackendStorageZipFilename\" cannot be empty."); } BackendStorageZipFilename = temp1; // ExtractionRootDirectory var temp2 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "ExtractionRootDirectory", typeof(string)).Value; // if (string.IsNullOrWhiteSpace(temp2)) { throw new Exception($"Configuration invalid information. Configuration item: \"ExtractionRootDirectory\" cannot be empty."); } if (!System.IO.Directory.Exists(temp2)) { throw new System.IO.DirectoryNotFoundException(temp2); } ExtractionRootDirectory = temp2; // SaveOriginalFilenames SaveOriginalFilenames = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SaveOriginalFilenames", typeof(bool)).Value; // Engine Name/Version CompressionEngineName = _EngineName_; CompressionEngineVersion = _EngineVersion_; // // TODO: add CompressedFileStoreBase stuff to this list. // IList<string> ExtensionsToStore InitializeStore(); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public FileStore(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "FileStore") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"FileStore\". Configuration Key={configuration.Key}", nameof(configuration)); } // SourceDirectory var temp1 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SourceDirectory", typeof(string)).Value; if (string.IsNullOrWhiteSpace(temp1)) { throw new Exception($"Configuration invalid information. Configuration item: \"SourceDirectory\" cannot be empty."); } if (!System.IO.Directory.Exists(temp1)) { throw new System.IO.DirectoryNotFoundException(temp1); } RootPath = temp1; // ExtractionRootDirectory var temp2 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "ExtractionRootDirectory", typeof(string)).Value; if (string.IsNullOrWhiteSpace(temp2)) { throw new Exception($"Configuration invalid information. Configuration item: \"ExtractionRootDirectory\" cannot be empty."); } if (!System.IO.Directory.Exists(temp2)) { throw new System.IO.DirectoryNotFoundException(temp2); } ExtractionRootDirectory = temp2; // SaveOriginalFilenames SaveOriginalFilenames = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SaveOriginalFilenames", typeof(bool)).Value; // InitializeStore(); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public Log(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "Log") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"Log\". Configuration Key={configuration.Key}", nameof(configuration)); } // LogName LogName = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "LogName", typeof(string)).Value; // DebugReplacementEntryType DebugReplacementEntryType = (System.Diagnostics.EventLogEntryType)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "DebugReplacementEntryType", typeof(System.Diagnostics.EventLogEntryType)).Value; // MachineName MachineName = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "MachineName", typeof(string)).Value; // SourceName SourceName = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SourceName", typeof(string)).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public LogController(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "LogController") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"LogController\". Configuration Key={configuration.Key}", nameof(configuration)); } // LogControllerSettings var logControllerSettingsConfig = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "LogControllerSettings", true); Settings = (LogControllerSettings)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(logControllerSettingsConfig); // Log var logConfig = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "Log", true); // **** add/update "WriteLogEntriesUsingLocalTime" to reflect the value in Settings logConfig.Items.Add("WriteLogEntriesUsingLocalTime", Settings.WritePrimaryLogEntriesUsingLocalTime, Settings.WritePrimaryLogEntriesUsingLocalTime.GetType()); _Log = (Logging.ILog)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(logConfig); // **** turn OFF auto-truncation if it is the known interface:{Logging.ITruncatable} if (_Log is Logging.ITruncatable) { (_Log as Logging.ITruncatable).AutoTruncateEnabled = false; } // LogArchiveFileStore var fileStoreConfig = Core.Configuration.ConfigurationHelper.FindConfigurationGroup(configuration, "FileStore", true); if ((!fileStoreConfig.Items.ContainsKey("ExtractionRootDirectory")) || (fileStoreConfig.Items["ExtractionRootDirectory"].Value.ToString() == "")) { fileStoreConfig.Items.Add("ExtractionRootDirectory", System.IO.Path.GetTempPath(), typeof(string)); } _LogArchiveFileStore = (FileStorage.IFileStore)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(fileStoreConfig); // ArchiveFilenameFactory var archiveFilenameFactoryType = (Type)Type.GetType((string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "ArchiveFilenameFactory", typeof(Type)).Value); _ArchiveFilenameFactory = (IArchiveFilenameFactory)Common.InstantiationHelper.InvokeDefaultCtor(archiveFilenameFactoryType); }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public DsvSettings(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "DsvSettings") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"DsvSettings\". Configuration Key={configuration.Key}", nameof(configuration)); } // settings RowSeperator = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "RowSeperator", typeof(string)).Value; ColumnSeperator = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "ColumnSeperator", typeof(string)).Value; Enclosure = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Enclosure", typeof(string)).Value; Reader_FirstRowIsHeader = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Reader_FirstRowIsHeader", typeof(bool)).Value; Reader_ParseHeaderRowAsColumns = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Reader_ParseHeaderRowAsColumns", typeof(bool)).Value; Reader_TrimWhitespace = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Reader_TrimWhitespace", typeof(bool)).Value; Writer_IncludeHeaderRow = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Writer_IncludeHeaderRow", typeof(bool)).Value; Writer_ColumnEnclosingRule = (ColumnEnclosingRuleEnum)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Writer_ColumnEnclosingRule", typeof(ColumnEnclosingRuleEnum)).Value; }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public PackageConfiguration(Configuration.IConfigurationGroup configuration) : this() { // check if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "PackageConfiguration") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"PackageConfiguration\". Configuration Key={configuration.Key}", nameof(configuration)); } // Name var temp1 = (string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Name", typeof(string)).Value; // if (string.IsNullOrWhiteSpace(temp1)) { throw new Exception($"Configuration invalid information. Configuration item: \"Name\" cannot be empty."); } Name = temp1; // Version Version = (Version)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Version", typeof(Version)).Value; // IsEnabled IsEnabled = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "IsEnabled", typeof(bool)).Value; // Priority Priority = (double)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "Priority", typeof(double)).Value; // IsDependencyPackage IsDependencyPackage = (bool)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "IsDependencyPackage", typeof(bool)).Value; // group: DependencyPackages if (configuration.ContainsKey("DependencyPackages")) { foreach (var item in configuration["DependencyPackages"]) { ((Configuration.IConfigurationGroupAdvanced)item).SetKey("DependencyPackage"); DependencyPackages.Add(new DependencyPackage(item)); } } }
/// <summary> /// Instantiates an new instance with the data from the <paramref name="configuration"/>. /// </summary> /// <param name="configuration">The configuration to use to populate the new instance.</param> public EncryptorConfiguration(Configuration.IConfigurationGroup configuration) : this() { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Key != "EncryptorConfiguration") { throw new ArgumentException($"Wrong configuration. Configuration Key must equal \"EncryptorConfiguration\". Configuration Key={configuration.Key}", nameof(configuration)); } // SymmetricAlgorithm try { SymmetricAlgorithmType = Type.GetType((string)Core.Configuration.ConfigurationHelper.FindConfigurationItem(configuration, "SymmetricAlgorithmType", typeof(Type)).Value); } catch { } // SaltedPassword if (!configuration.ContainsKey("SaltedPassword")) { throw new Exception($"Configuration missing information. Configuration must have item: \"SaltedPassword\"."); } SaltedPassword = (Cryptography.ISaltedPassword)Core.Configuration.ConfigurationHelper.InstantiateTypeFromConfigurationGroup(typeof(Cryptography.SaltedPassword), configuration["SaltedPassword"]); }