/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> /// <exception cref="Forge.Configuration.Shared.InvalidConfigurationValueException">CertificateSource value is invalid. /// or /// CertificateSource value is invalid. /// or /// CertificateFile value is invalid. /// or /// Password value is invalid. /// or /// Subject value is invalid. /// or /// CertificateSource value is invalid.</exception> /// <exception cref="Forge.Configuration.Shared.InvalidConfigurationException">Invalid certificate. /// or /// Failed to find certificate. /// or /// Failed to find certificate.</exception> public override void Initialize(CategoryPropertyItem configItem) { if (configItem == null) { ThrowHelper.ThrowArgumentNullException("configItem"); } if (!IsInitialized) { CertificateConfigurationSource certSource = new CertificateConfigurationSource(); certSource.Initialize(configItem); mCertificate = certSource.Certificate; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(configItem.PropertyItems, "Protocol"); if (pi != null) { try { Protocol = (SslProtocols)Enum.Parse(typeof(SslProtocols), pi.EntryValue, true); } catch (Exception) { } } base.Initialize(configItem); IsInitialized = true; } }
/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> public virtual void Initialize(CategoryPropertyItem configItem) { if (configItem == null) { ThrowHelper.ThrowArgumentNullException("configItem"); } int value = 8192; if (ParseIntValue(configItem, "ReceiveBufferSize", 1024, 65536, ref value)) { this.mReceiveBufferSize = value; } value = 8192; if (ParseIntValue(configItem, "SendBufferSize", 1024, 65536, ref value)) { this.mSendBufferSize = value; } value = Timeout.Infinite; if (ParseIntValue(configItem, "ReceiveTimeout", Timeout.Infinite, int.MaxValue, ref value)) { this.mReceiveTimeout = value; } value = Timeout.Infinite; if (ParseIntValue(configItem, "SendTimeout", Timeout.Infinite, int.MaxValue, ref value)) { this.mSendTimeout = value; } NoDelay = ParseBooleanValue(configItem, "NoDelay"); }
/// <summary> /// Initializes a new instance of the <see cref="StorageProviderBase<T>"/> class. /// </summary> /// <param name="storageId">The storage id.</param> /// <param name="configItem">The config item.</param> protected StorageProviderBase(String storageId, CategoryPropertyItem configItem) : this(storageId) { String formatter = String.Empty; CategoryPropertyItem item = configItem.PropertyItems == null ? null : configItem.PropertyItems["DataFormatter"]; if (item != null) { formatter = item.EntryValue; } if (!String.IsNullOrEmpty(formatter)) { Type type = null; try { type = TypeHelper.GetTypeFromString(formatter); } catch (Exception ex) { throw new Exception(String.Format("Unable to resolve data formatter type: {0}", formatter), ex); } try { mDataFormatter = (IDataFormatter <T>)type.Assembly.CreateInstance(type.AssemblyQualifiedName); } catch (Exception ex) { throw new Exception(String.Format("Unable to instantiate formatter: {0}", formatter), ex); } } else { mDataFormatter = new BinarySerializerFormatter <T>(BinarySerializerBehaviorEnum.DoNotThrowExceptionOnMissingField, TypeLookupModeEnum.AllowAll, true); } }
/// <summary> /// Parses the int value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="minValue">The min value.</param> /// <param name="maxValue">The max value.</param> /// <param name="value">The value.</param> /// <returns>True, if the parse method was succeeded, otherwise False.</returns> protected static bool ParseIntValue(CategoryPropertyItem root, String entryId, int minValue, int maxValue, ref int value) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { try { value = int.Parse(pi.EntryValue); result = true; } catch (FormatException ex) { throw new InvalidConfigurationException(String.Format("Invalid value for item: {0}", entryId), ex); } if (value < minValue) { throw new InvalidConfigurationException(String.Format("Minimum value ({0}) is out of range ({1}) for item: {2}", minValue, result, entryId)); } if (value > maxValue) { throw new InvalidConfigurationException(String.Format("Maximum value ({0}) is out of range ({1}) for item: {2}", maxValue, result, entryId)); } } return(result); }
private void Initialize() { string appId = ApplicationHelper.ApplicationId; bool mutexResult = false; string typeName = String.Format("HibernateStorageProvider_{0}_{1}_{2}", appId, StorageId, typeof(T).AssemblyQualifiedName.GetHashCode().ToString()); if (typeName.Length > 255) { // limit the length of the mutex name to avoid exception typeName = typeName.Substring(0, 255); } mAppIdMutex = new Mutex(true, typeName, out mutexResult); if (!mutexResult) { throw new InitializationException("An other application with the specified application identifier is running."); } this.mDeviceId = HashGeneratorHelper.GetSHA256BasedValue(StorageId); CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, String.Format("NHibernateProvider/KnownStorageIdsToReset/{0}", StorageId)); if (pi != null) { Reset(); } LoadAllocationTable(); }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public override void Initialize(CategoryPropertyItem item) { base.Initialize(item); this.MemberName = null; this.Value = null; if (item.PropertyItems != null) { string memberName = string.Empty; if (ConfigurationAccessHelper.ParseStringValue(item.PropertyItems, CONFIG_MEMBERNAME, ref memberName)) { this.MemberName = memberName; } string value = string.Empty; if (ConfigurationAccessHelper.ParseStringValue(item.PropertyItems, CONFIG_VALUE, ref value)) { this.Value = value; } } if (string.IsNullOrEmpty(this.MemberName)) { throw new InitializationException("Member name has not been definied."); } }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public virtual void Initialize(CategoryPropertyItem item) { this.Filter = null; if (item != null) { this.SinkId = item.Id; CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(item.PropertyItems, CONFIG_FILTER); if (rootItem != null) { try { Type filterType = TypeHelper.GetTypeFromString(rootItem.EntryValue, TypeLookupModeEnum.AllowAll, true, true, true); this.Filter = (IErrorReportFilter)filterType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); this.Filter.Initialize(rootItem); } catch (Exception ex) { this.Filter = null; string message = string.Format("Failed to create error report filter. Type: '{0}'. Sink type: '{1}'", rootItem.EntryValue, this.GetType().AssemblyQualifiedName); if (LOGGER.IsErrorEnabled) { LOGGER.Error(message, ex); } throw new InitializationException(message, ex); } } } }
/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> /// <exception cref="Forge.Configuration.Shared.InvalidConfigurationValueException">ServerNameOnCertificate value is invalid.</exception> public override void Initialize(CategoryPropertyItem configItem) { if (configItem == null) { ThrowHelper.ThrowArgumentNullException("configItem"); } if (!IsInitialized) { mServerNameOnCertificate = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "ServerNameOnCertificate"); if (string.IsNullOrEmpty(mServerNameOnCertificate)) { throw new InvalidConfigurationValueException("ServerNameOnCertificate value is invalid."); } string skipSslPolicy = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "SkipSslPolicyErrors"); if (!string.IsNullOrEmpty(skipSslPolicy)) { bool value = false; if (bool.TryParse(skipSslPolicy, out value)) { mSkipSslPolicyErrors = value; } } base.Initialize(configItem); IsInitialized = true; } }
/// <summary> /// Creates the message sink. /// </summary> /// <param name="pi">The pi.</param> /// <returns></returns> protected IMessageSink CreateMessageSink(CategoryPropertyItem pi) { if (string.IsNullOrEmpty(pi.EntryValue)) { throw new InvalidConfigurationException("No message sink class definied in a message sink configuration entry."); } IMessageSink result = null; try { if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("Channel, create message sink from type '{0}'. ChannelId: '{1}'.", pi.EntryValue, this.ChannelId)); } Type type = TypeHelper.GetTypeFromString(pi.EntryValue); result = (IMessageSink)type.GetConstructor(new Type[] { }).Invoke(null); result.Initialize(pi); } catch (Exception ex) { throw new InvalidConfigurationException(String.Format("Unable to instantiate message sink '{0}' specified in configuration.", pi.EntryValue), ex); } return(result); }
/// <summary> /// Initialize message sink from configuration /// </summary> /// <param name="pi">The pi.</param> public virtual void Initialize(CategoryPropertyItem pi) { if (pi == null) { ThrowHelper.ThrowArgumentNullException("pi"); } if (!this.mInitialized) { CategoryPropertyItem piCompressData = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "CompressData"); if (piCompressData != null) { bool.TryParse(piCompressData.EntryValue, out mCompressData); CategoryPropertyItem piCompressDataOverSize = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "CompressDataOverSize"); if (piCompressDataOverSize != null) { int result = 0; if (int.TryParse(piCompressDataOverSize.EntryValue, out result)) { mCompressDataOverSize = result; } } } } }
/// <summary> /// Initialize message sink from configuration /// </summary> /// <param name="pi">The pi.</param> public override void Initialize(CategoryPropertyItem pi) { if (!this.mInitialized) { base.Initialize(pi); this.mInitialized = true; } }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { string value = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext"); if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(value.Trim())) { throw new InitializationException("Network context name not configured."); } this.mName = value.Trim(); value = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext/Separation"); bool boolValue = false; if (!string.IsNullOrEmpty(value)) { bool.TryParse(value, out boolValue); } Separation = boolValue; CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext/Separation/WhiteList"); List <ContextRule> list = new List <ContextRule>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { if (string.IsNullOrEmpty(pi.EntryName) || string.IsNullOrEmpty(pi.EntryName.Trim())) { throw new InitializationException("Invalid context rule."); } if (string.IsNullOrEmpty(pi.EntryValue) || string.IsNullOrEmpty(pi.EntryValue.Trim())) { throw new InitializationException("Invalid context rule."); } list.Add(new ContextRule(pi.EntryName, pi.EntryValue)); } } WhiteList = list; piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext/Separation/BlackList"); list = new List <ContextRule>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { if (string.IsNullOrEmpty(pi.EntryName) || string.IsNullOrEmpty(pi.EntryName.Trim())) { throw new InitializationException("Invalid context rule."); } if (string.IsNullOrEmpty(pi.EntryValue) || string.IsNullOrEmpty(pi.EntryValue.Trim())) { throw new InitializationException("Invalid context rule."); } list.Add(new ContextRule(pi.EntryName, pi.EntryValue)); } } BlackList = list; }
/// <summary> /// Fails the safe start storage provider. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="storageId">The storage id.</param> /// <param name="dataFormatter">The data formatter.</param> /// <param name="compressContent">if set to <c>true</c> [compress content].</param> /// <param name="enableReset">if set to <c>true</c> [enable reset].</param> /// <param name="hasError">if set to <c>true</c> [has error].</param> /// <returns></returns> public static HibernateStorageProvider <T> FailSafeStartStorageProvider <T>(string storageId, IDataFormatter <T> dataFormatter, bool compressContent, bool enableReset, out bool hasError) { HibernateStorageProvider <T> result = null; hasError = false; try { result = new HibernateStorageProvider <T>(storageId, dataFormatter, compressContent); IEnumeratorSpecialized <T> iterator = result.GetEnumerator(); while (iterator.MoveNext()) { // check data consistency } } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("NHIBERNATE_STORAGE_PROVIDER, failed to initialize storage provider: '{0}'. Reset allowed: {1}", storageId, enableReset.ToString()), ex); } hasError = true; if (enableReset) { // reset the content of the storage provider CategoryPropertyItem root = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider"); CategoryPropertyItem removeItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, "KnownStorageIdsToReset"); if (removeItem == null) { removeItem = new CategoryPropertyItem(); removeItem.Id = "KnownStorageIdsToReset"; root.PropertyItems.Add(removeItem); } CategoryPropertyItem storeItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(removeItem.PropertyItems, storageId); if (storeItem == null) { storeItem = new CategoryPropertyItem(); storeItem.Id = storageId; removeItem.PropertyItems.Add(storeItem); try { result = new HibernateStorageProvider <T>(storageId, dataFormatter, compressContent); } finally { removeItem.PropertyItems.Remove(storeItem); } } } else { throw; } } return(result); }
/// <summary> /// Parses the string value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="defaultValue">The default value.</param> /// <returns>True, if the parse method was succeeded, otherwise False.</returns> protected static String ParseStringValue(CategoryPropertyItem root, String entryId, String defaultValue) { String result = defaultValue; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { result = pi.EntryValue; } return(result); }
/// <summary> /// Creates the category property item. /// </summary> /// <returns></returns> public CategoryPropertyItem CreateCategoryPropertyItem() { CategoryPropertyItem result = new CategoryPropertyItem(); result.Id = this.Id; result.EntryValue = this.Value; result.PropertyItems = new CategoryPropertyItems(); foreach (PropertyItem pi in this.PropertyItems.Values) { result.PropertyItems.Add(pi.CreateCategoryPropertyItem()); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="FileStorageProvider<T>"/> class. /// </summary> /// <param name="storageId">The storage id.</param> /// <param name="configItem">The config item.</param> public FileStorageProvider(String storageId, CategoryPropertyItem configItem) : base(storageId, configItem) { String url = String.Empty; CategoryPropertyItem item = configItem.PropertyItems == null ? null : configItem.PropertyItems["BaseUrl"]; if (item != null) { url = item.EntryValue; } this.mBaseUrl = url; Initialize(); }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/NAT_Gateways"); List <AddressEndPoint> list = new List <AddressEndPoint>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { list.Add(AddressEndPoint.Parse(pi.EntryValue)); } } EndPoints = list; }
/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> /// <exception cref="InitializationException">Administration connection string was not set.</exception> /// <exception cref="Forge.InitializationException">Administration connection string was not set.</exception> public void Initialize(CategoryPropertyItem configItem) { if (configItem == null) { ThrowHelper.ThrowArgumentNullException("configItem"); } mConnectionStringForAdmin = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, CONNECTION_STRING_CONFIG_ID); if (string.IsNullOrEmpty(mConnectionStringForAdmin)) { throw new InitializationException("Administration connection string was not set."); } this.IsInitialized = true; }
private static void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem != null) { int mouseMoveSendingInterval = Consts.DEFAULT_MOUSE_MOVE_SEND_INTERVAL; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL, 0, int.MaxValue, ref mouseMoveSendingInterval)) { MouseMoveSendInterval = mouseMoveSendingInterval; } } Raiser.CallDelegatorBySync(EventConfigurationChanged, new object[] { null, EventArgs.Empty }); }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public virtual void Initialize(CategoryPropertyItem item) { if (item == null) { ThrowHelper.ThrowArgumentNullException("item"); } if (item.PropertyItems != null) { bool negation = false; if (ConfigurationAccessHelper.ParseBooleanValue(item.PropertyItems, CONFIG_NEGATION, ref negation)) { this.Negation = negation; } } }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public override void Initialize(CategoryPropertyItem item) { base.Initialize(item); this.MatchMode = LikeMatchModeFilterEnum.Exact; if (item.PropertyItems != null) { LikeMatchModeFilterEnum matchMode = LikeMatchModeFilterEnum.Exact; if (ConfigurationAccessHelper.ParseEnumValue <LikeMatchModeFilterEnum>(item.PropertyItems, CONFIG_MATCHMODE, ref matchMode)) { this.MatchMode = matchMode; } } this.IsInitialized = true; }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public override void Initialize(CategoryPropertyItem item) { base.Initialize(item); this.Operand = ArithmeticFilterOperandEnum.Equal; if (item.PropertyItems != null) { ArithmeticFilterOperandEnum operand = ArithmeticFilterOperandEnum.Equal; if (ConfigurationAccessHelper.ParseEnumValue <ArithmeticFilterOperandEnum>(item.PropertyItems, CONFIG_OPERAND, ref operand)) { this.Operand = operand; } } this.IsInitialized = true; }
/// <summary> /// Parses the enum value. /// </summary> /// <typeparam name="TEnum">The type of the enum.</typeparam> /// <param name="root">The root.</param> /// <param name="entryId">The entry unique identifier.</param> /// <returns></returns> protected static TEnum ParseEnumValue <TEnum>(CategoryPropertyItem root, String entryId) where TEnum : struct { TEnum result = default(TEnum); CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { try { result = (TEnum)Enum.Parse(typeof(TEnum), pi.EntryValue, true); } catch (Exception) { } } return(result); }
/// <summary> /// Parses the boolean value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <returns>True, if the parse method was succeeded, otherwise False.</returns> protected static bool ParseBooleanValue(CategoryPropertyItem root, String entryId) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { try { result = bool.Parse(pi.EntryValue); } catch (Exception) { } } return(result); }
/// <summary> /// Initializes the <see cref="HibernateStorageProvider<T>"/> class. /// </summary> static HibernateStorageProvider() { SYSTEM_ID = HashGeneratorHelper.GetSHA256BasedValue(ApplicationHelper.ApplicationId); CategoryPropertyItem configItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider/NHibernateStorages/Default"); if (configItem != null) { DEFAULT_SESSION_FACTORY = CreateEntityManagerFactory(configItem); } configItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider/NHibernateStorages/StorageSpecified"); if (configItem != null) { foreach (CategoryPropertyItem pi in configItem) { mSessionFactoriesForStorages.Add(configItem.Id, CreateEntityManagerFactory(configItem)); } } }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/TCP_Connections"); List <ConnectionEntry> list = new List <ConnectionEntry>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { AddressEndPoint address = AddressEndPoint.Parse(pi.EntryValue); bool reConnect = true; int delayValue = 1000; int conTimeout = Timeout.Infinite; string item = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, string.Format("NetworkPeering/TCP_Connections/{0}/ReconnectOnFailure", pi.Id)); if (!string.IsNullOrEmpty(item)) { bool.TryParse(item, out reConnect); } item = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, string.Format("NetworkPeering/TCP_Connections/{0}/DelayBetweenAttempsInMS", pi.Id)); if (!string.IsNullOrEmpty(item)) { int.TryParse(item, out delayValue); if (delayValue < 0) { delayValue = 1000; } } item = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, string.Format("NetworkPeering/TCP_Connections/{0}/ConnectionTimeout", pi.Id)); if (!string.IsNullOrEmpty(item)) { int.TryParse(item, out conTimeout); if (conTimeout < Timeout.Infinite) { conTimeout = Timeout.Infinite; } } list.Add(new ConnectionEntry(address, reConnect, delayValue, conTimeout)); } } EndPoints = list; }
/// <summary> /// Initializes the channel. /// </summary> /// <param name="pi">The pi.</param> public virtual void Initialize(CategoryPropertyItem pi) { DoDisposeCheck(); if (pi == null) { ThrowHelper.ThrowArgumentNullException("pi"); } if (!mInitialized) { { this.mConnectionData = null; CategoryPropertyItem item = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "RemoteAddress"); if (item != null) { this.mConnectionData = AddressEndPoint.Parse(item.EntryValue); } if (item != null) { ConfigurationAccessHelper.ParseLongValue(pi.PropertyItems, "DefaultErrorResponseTimeout", Timeout.Infinite, long.MaxValue, ref mDefaultErrorResponseTimeout); } } { mServerEndpoints.Clear(); CategoryPropertyItem baseAddressesItems = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "BaseAddresses"); if (baseAddressesItems != null) { IEnumerator <CategoryPropertyItem> iterator = baseAddressesItems.GetEnumerator(); while (iterator.MoveNext()) { mServerEndpoints.Add(AddressEndPoint.Parse(iterator.Current.EntryValue)); } } } { mSessionReusable = true; ConfigurationAccessHelper.ParseBooleanValue(pi.PropertyItems, "SessionReusable", ref mSessionReusable); } } }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public override void Initialize(CategoryPropertyItem item) { base.Initialize(item); this.FilterLogic = GroupFilterLoginEnum.And; mFilters.Clear(); if (item.PropertyItems != null) { GroupFilterLoginEnum logic = GroupFilterLoginEnum.And; if (ConfigurationAccessHelper.ParseEnumValue <GroupFilterLoginEnum>(item.PropertyItems, CONFIG_FILTER_LOGIC, ref logic)) { this.FilterLogic = logic; } CategoryPropertyItem filterItems = ConfigurationAccessHelper.GetCategoryPropertyByPath(item.PropertyItems, CONFIG_FILTERS); if (filterItems != null && filterItems.PropertyItems != null) { foreach (CategoryPropertyItem filterItem in filterItems.PropertyItems) { try { Type filterType = TypeHelper.GetTypeFromString(filterItem.EntryValue, TypeLookupModeEnum.AllowAll, true, true, true); IErrorReportFilter filter = (IErrorReportFilter)filterType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); filter.Initialize(filterItem); mFilters.Add(filter); } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("GROUP_FILTER, failed to create error report filter. Type: '{0}'", filterItem.EntryValue), ex); } } } } } this.IsInitialized = true; }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/TCPServers/Auto"); List <AddressEndPoint> list = new List <AddressEndPoint>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { list.Add(AddressEndPoint.Parse(pi.EntryValue)); } } EndPoints = list; string value = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/TCPServers/Auto"); bool boolValue = false; if (!string.IsNullOrEmpty(value)) { bool.TryParse(value, out boolValue); } mAuto = boolValue; }
public static void Save(ConfigurationSaveMode saveMode) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem == null) { rootItem = new CategoryPropertyItem(); rootItem.Id = CONFIG_ROOT; RemoteDesktopConfiguration.Settings.CategoryPropertyItems.Add(rootItem); } CategoryPropertyItem piMouseMoveSendingInterval = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL); if (piMouseMoveSendingInterval == null) { piMouseMoveSendingInterval = new CategoryPropertyItem(); piMouseMoveSendingInterval.Id = CONFIG_MOUSE_MOVE_SEND_INTERVAL; rootItem.PropertyItems.Add(piMouseMoveSendingInterval); } piMouseMoveSendingInterval.EntryValue = MouseMoveSendInterval.ToString(); RemoteDesktopConfiguration.Save(saveMode); }
private void Decrypt(CategoryPropertyItem item) { item.Encrypted = false; foreach (CategoryPropertyItem i in item.PropertyItems) { Decrypt(i); } }
/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> public virtual void Initialize(CategoryPropertyItem configItem) { this.IsInitialized = true; }
/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> /// <exception cref="InvalidConfigurationValueException"> /// CertificateSource value is invalid. /// or /// CertificateSource value is invalid. /// or /// CertificateFile value is invalid. /// or /// Password value is invalid. /// or /// Subject value is invalid. /// or /// CertificateSource value is invalid. /// </exception> /// <exception cref="InvalidConfigurationException"> /// Invalid certificate. /// or /// Failed to find certificate. /// or /// Failed to find certificate. /// </exception> public virtual void Initialize(CategoryPropertyItem configItem) { if (configItem == null) { ThrowHelper.ThrowArgumentNullException("configItem"); } if (!mInitialized) { string certSource = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "CertificateSource"); if (string.IsNullOrEmpty(certSource)) { throw new InvalidConfigurationValueException("CertificateSource value is invalid."); } certSource = certSource.Trim().ToLower(); if (string.IsNullOrEmpty(certSource)) { throw new InvalidConfigurationValueException("CertificateSource value is invalid."); } if ("file".Equals(certSource)) { string certFile = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "CertificateFile"); if (string.IsNullOrEmpty(certFile)) { throw new InvalidConfigurationValueException("CertificateFile value is invalid."); } FileInfo fi = new FileInfo(certFile); if (!fi.Exists) { throw new InvalidConfigurationException(string.Format("Certificate file not found: {0}", fi.FullName)); } string passwordString = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "Password"); if (string.IsNullOrEmpty(passwordString)) { throw new InvalidConfigurationValueException("Password value is invalid."); } try { mCertificate = new X509Certificate2(fi.FullName, passwordString); } catch (Exception ex) { throw new InvalidConfigurationException("Invalid certificate.", ex); } } else if ("store".Equals(certSource)) { StoreName storeName = StoreName.My; StoreLocation storeLocation = StoreLocation.CurrentUser; string subject = string.Empty; string storeNameStr = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "StoreName"); if (!string.IsNullOrEmpty(storeNameStr)) { storeName = (StoreName)Enum.Parse(typeof(StoreName), storeNameStr); } string storeLocationStr = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "StoreLocation"); if (!string.IsNullOrEmpty(storeLocationStr)) { storeLocation = (StoreLocation)Enum.Parse(typeof(StoreLocation), storeLocationStr); } subject = ConfigurationAccessHelper.GetValueByPath(configItem.PropertyItems, "Subject"); if (string.IsNullOrEmpty(subject)) { throw new InvalidConfigurationValueException("Subject value is invalid."); } X509Store store = new X509Store(storeName, storeLocation); store.Open(OpenFlags.ReadOnly); try { foreach (X509Certificate2 c in store.Certificates) { if (c.Subject.Equals(subject)) { mCertificate = c; break; } } if (mCertificate == null) { throw new InvalidConfigurationException("Failed to find certificate."); } } catch (InvalidConfigurationException) { throw; } catch (Exception ex) { throw new InvalidConfigurationException("Failed to find certificate.", ex); } finally { store.Close(); } } else { throw new InvalidConfigurationValueException("CertificateSource value is invalid."); } this.mInitialized = true; } }
private void Encrypt(CategoryPropertyItem item) { item.Encrypted = true; foreach (CategoryPropertyItem i in item.PropertyItems) { Encrypt(i); } }