コード例 #1
0
        /// <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));
        }
コード例 #2
0
        private static IDataContext CreatContextFromConfiguration(IAggregateConfiguration configuration)
        {
            Type newContextType = DynamicAggregateContextTypeBuilder.Build(configuration);

            SetInitialIzer(newContextType);
            var context = (IDataContext)Activator.CreateInstance(newContextType, new object[] { configuration });

            return(context);
        }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
 private static string BuildKey(IAggregateConfiguration configuration)
 {
     return(AggregateConfigurationKeyFactory.GenerateKey(configuration.TypesConfigured.ToArray()));
 }
コード例 #7
0
 private static string BuildKey(IAggregateConfiguration configuration)
 {
     return AggregateConfigurationKeyFactory.GenerateKey(configuration.TypesConfigured.ToArray());
 }