Beispiel #1
0
        public ProcessingEngine(
            IObjectFactory objectFactory,
            IScopePool scopePool,
            IPermissionManager permissions,
            IExtensibilityProvider extensibilityProvider)
        {
            Contract.Requires(objectFactory != null);
            Contract.Requires(scopePool != null);
            Contract.Requires(permissions != null);
            Contract.Requires(extensibilityProvider != null);

            this.ObjectFactory = objectFactory.CreateInnerFactory();
            this.ScopePool     = scopePool;
            this.Permissions   = permissions;
            var commandTypes = extensibilityProvider.FindPlugins <IServerCommand>();

            var commands = new Dictionary <Type, Type>();

            foreach (var ct in commandTypes)
            {
                commands[ct] = ct;
            }
            foreach (var ct in commandTypes)
            {
                var attr = ct.GetCustomAttributes(typeof(ExportMetadataAttribute), false) as ExportMetadataAttribute[];
                if (attr != null)
                {
                    var insteadOf = attr.FirstOrDefault(it => it.Name == Metadata.InsteadOf);
                    if (insteadOf != null)
                    {
                        var type = insteadOf.Value as Type;
                        if (commandTypes.All(it => it != type))
                        {
                            throw new FrameworkException("Can't find target {0} for InsteadOf attribute declared on {1}".With(type, ct));
                        }
                        commands[type] = ct;
                    }
                }
            }
            foreach (var ct in commands)
            {
                ActualCommands[ct.Key] = ObjectFactory.Resolve <IServerCommand>(ct.Value);
            }
        }
Beispiel #2
0
 public RestService(IScopePool scopePool, JsonSerialization json)
 {
     this.ScopePool = scopePool;
     this.Json      = json;
 }