Esempio n. 1
0
        private ConstructorInfo GetConstructor()
        {
            Contract.Ensures(Contract.Result <ConstructorInfo>() != null);

            var aggregateRootType = typeof(TAggregateRoot);

            var key = $"{aggregateRootType.FullName}";

            Contract.Assume(string.IsNullOrWhiteSpace(key) == false);

            var ctor = _cache.AddOrGetExisting(key, new Lazy <ConstructorInfo>(() => aggregateRootType.GetConstructor(DefaultBindingFlags, Type.DefaultBinder, new[] { typeof(AggregateRootIdentity), typeof(TAggregateRootState) }, null)));

            Contract.Assume(ctor != null);

            return(ctor);
        }
        private ConstructorInfo GetConstructor(Type[] parameters, string ctorType)
        {
            Contract.Requires(parameters != null);
            Contract.Ensures(Contract.Result <ConstructorInfo>() != null);

            var aggregateRootStateType = typeof(TAggregateRootState);

            var key = $"{aggregateRootStateType.FullName}::{ctorType}";

            Contract.Assume(string.IsNullOrWhiteSpace(key) == false);

            var ctor = _cache.AddOrGetExisting(key, new Lazy <ConstructorInfo>(() => aggregateRootStateType.GetConstructor(DefaultBindingFlags, Type.DefaultBinder, parameters, null)));

            Contract.Assume(ctor != null);

            return(ctor);
        }