public IFactDependencyProcessor Create(IFactDependencyFeature metadata)
        {
            Type processorType;

            if (!KnownFeatureProcessors.TryGetValue(metadata.GetType().GetGenericTypeDefinition(), out processorType))
            {
                throw new ArgumentException($"Feature of type {metadata.GetType().Name} has no known processor", nameof(metadata));
            }

            processorType = processorType.MakeGenericType(metadata.GetType().GetGenericArguments());
            var metadataOverride = new DependencyOverride(metadata.GetType(), metadata);
            var processor        = _unityContainer.Resolve(processorType, metadataOverride);

            return((IFactDependencyProcessor)processor);
        }
Exemplo n.º 2
0
                public IFactDependencyProcessor Create(IFactDependencyFeature metadata)
                {
                    if (metadata.GetType().GetGenericTypeDefinition() == typeof(DirectlyDependentEntityFeature <>))
                    {
                        var processorType = typeof(DirectlyDependentEntityFeatureProcessor <>).MakeGenericType(metadata.GetType().GetGenericArguments());
                        return((IFactDependencyProcessor)Activator.CreateInstance(processorType, metadata));
                    }

                    if (metadata.GetType().GetGenericTypeDefinition() == typeof(IndirectlyDependentEntityFeature <,>))
                    {
                        var processorType = typeof(IndirectlyDependentEntityFeatureProcessor <,>).MakeGenericType(metadata.GetType().GetGenericArguments());
                        var factory       = metadata.GetType().GetGenericArguments()[1] == typeof(long)
                                          ? (object)new RecalculateAggregateCommandFactory()
                                          : (object)new RecalculateStatisticsCommandFactory();

                        return((IFactDependencyProcessor)Activator.CreateInstance(processorType, metadata, _query, new DefaultIdentityProvider(), factory));
                    }

                    throw new ArgumentException($"No processor for feature type {metadata.GetType().Name}");
                }