/// <summary> /// Creates an AggregateContext that is bound by the Type configured for it /// </summary> /// <typeparam name="T1">The Type to configure the context for</typeparam> /// <returns><seealso cref="IDataContext"/>The IDataContext for usage</returns> public static IDataContext Create <T1>() where T1 : class { IAggregateConfiguration configuration = AggregateConfigurationFactory.GetConfigurationFor <T1>(); return(CreatContextFromConfiguration(configuration)); }
private static IDataContext CreatContextFromConfiguration(IAggregateConfiguration configuration) { Type newContextType = DynamicAggregateContextTypeBuilder.Build(configuration); SetInitialIzer(newContextType); var context = (IDataContext)Activator.CreateInstance(newContextType, new object[] { configuration }); return(context); }
/// <summary> /// Builds the type for the Context /// </summary> /// <param name="configuration">the aggregate configuration used to build the context</param> /// <returns>the IDataContext</returns> public static Type Build(IAggregateConfiguration configuration) { string key = BuildKey(configuration); if (PreviousContextTypes.ContainsKey(key)) { return PreviousContextTypes[key]; } Type contextType = ConstructNewContextType(); PreviousContextTypes.AddOrUpdate(key, contextType, (k, existingValue) => contextType); return contextType; }
/// <summary> /// Builds the type for the Context /// </summary> /// <param name="configuration">the aggregate configuration used to build the context</param> /// <returns>the IDataContext</returns> public static Type Build(IAggregateConfiguration configuration) { string key = BuildKey(configuration); if (PreviousContextTypes.ContainsKey(key)) { return(PreviousContextTypes[key]); } Type contextType = ConstructNewContextType(); PreviousContextTypes.AddOrUpdate(key, contextType, (k, existingValue) => contextType); return(contextType); }
private void AddByCategory(StoredEvent storedEvent, IAggregateConfiguration configuration) { var category = configuration.Name; if (_byCategory.TryGetValue(category, out var byCategory)) { byCategory.Add(storedEvent); } else { byCategory = new List <StoredEvent>(); byCategory.Add(storedEvent); _byCategory[category] = byCategory; } }
private static string BuildKey(IAggregateConfiguration configuration) { return(AggregateConfigurationKeyFactory.GenerateKey(configuration.TypesConfigured.ToArray())); }
private static string BuildKey(IAggregateConfiguration configuration) { return AggregateConfigurationKeyFactory.GenerateKey(configuration.TypesConfigured.ToArray()); }