private void CreateFronEnvironmentStringIfNotExists(IEventStreamIdentity attribute) { if (!AllSettings.ContainsKey(EventStreamSetting.MakeDomainQualifiedEntityName(attribute))) { string envValue = Environment.GetEnvironmentVariable(EventStreamSetting.MakeEnvironmentStringKey(attribute)); if (string.IsNullOrWhiteSpace(envValue)) { envValue = Environment.GetEnvironmentVariable(EventStreamSetting.MakeEnvironmentStringKey(attribute, AllEntityTypes: true)); } if (string.IsNullOrWhiteSpace(envValue)) { envValue = Environment.GetEnvironmentVariable(EventStreamSetting.MakeEnvironmentStringKey(attribute, AllDomains: true)); } if (string.IsNullOrWhiteSpace(envValue)) { envValue = Environment.GetEnvironmentVariable(EventStreamSetting.MakeEnvironmentStringKey(attribute, AllEntityTypes: true, AllDomains: true)); } if (!string.IsNullOrWhiteSpace(envValue)) { EventStreamSetting newSetting = EventStreamSetting.SettingsFromEnvironmentStringValue(attribute, envValue); if (null != newSetting) { AllSettings.TryAdd(EventStreamSetting.MakeDomainQualifiedEntityName(attribute), newSetting); } } } }
public string GetBackingImplementationType(IEventStreamIdentity attribute) { CreateFronEnvironmentStringIfNotExists(attribute); if (AllSettings.ContainsKey(EventStreamSetting.MakeDomainQualifiedEntityName(attribute))) { return(AllSettings[EventStreamSetting.MakeDomainQualifiedEntityName(attribute)].Storage.ToUpperInvariant()); } else { return(DefaultEventStreamSetting(EventStreamSetting.MakeDomainQualifiedEntityName(attribute)).Storage.ToUpperInvariant()); } }
public string GetConnectionStringName(IEventStreamIdentity attribute) { CreateFronEnvironmentStringIfNotExists(attribute); if (AllSettings.ContainsKey(EventStreamSetting.MakeDomainQualifiedEntityName(attribute))) { return(AllSettings[EventStreamSetting.MakeDomainQualifiedEntityName(attribute)].ConnectionStringName); } else { return(ConnectionStringNameAttribute.DefaultConnectionStringName(attribute)); } }
public static EventStreamSetting SettingsFromEnvironmentStringValue(IEventStreamIdentity eventStreamIdentity, string environmentStringValue) { EventStreamSetting ret = new EventStreamSetting(MakeDomainQualifiedEntityName(eventStreamIdentity)); if (!string.IsNullOrWhiteSpace(environmentStringValue)) { if (environmentStringValue.StartsWith("Table;")) { ret.Storage = EVENTSTREAMIMPLEMENTATIOIN_TABLE; if (environmentStringValue.Length > @"Table;".Length) { ret.ConnectionStringName = environmentStringValue.Substring(6); } } if (environmentStringValue.StartsWith("AppendBlob;")) { ret.Storage = EVENTSTREAMIMPLEMENTATION_APPENDBLOB; if (environmentStringValue.Length > @"AppendBlob;".Length) { ret.ConnectionStringName = environmentStringValue.Substring(11); } } } // If not able to make a setting from the environment string, fall back on the default if (string.IsNullOrWhiteSpace(ret.Storage)) { // Default to event blob storage ret.Storage = EVENTSTREAMIMPLEMENTATION_APPENDBLOB; } if (string.IsNullOrWhiteSpace(ret.ConnectionStringName)) { ret.ConnectionStringName = ConnectionStringNameAttribute.DefaultConnectionStringName(eventStreamIdentity); } return(ret); }