Exemplo n.º 1
0
        public ObjectDef ToObjectDef(DiagnosticLevel level)
        {
            var objectDef = new ObjectDef(typeof (MediaWriter<>).MakeGenericType(_inputType));

            if (Links.Dependency != null) objectDef.Dependency(Links.Dependency);
            if (Projection.Dependency != null) objectDef.Dependency(Projection.Dependency);
            if (Document.Dependency != null) objectDef.Dependency(Document.Dependency);

            return objectDef;
        }
Exemplo n.º 2
0
        protected override ObjectDef toWriterDef()
        {
            var objectDef = new ObjectDef(typeof (MediaWriter<>).MakeGenericType(_resourceType));

            if (Links.Dependency != null) objectDef.Dependency(Links.Dependency);
            if (Projection.Dependency != null) objectDef.Dependency(Projection.Dependency);
            if (Document.Dependency != null) objectDef.Dependency(Document.Dependency);

            return objectDef;
        }
Exemplo n.º 3
0
        protected override ObjectDef buildObjectDef()
        {
            Validate();

            var objectDef = new ObjectDef(determineHandlerType());

            objectDef.Dependency(createLambda());

            if (_handlerDependencies.IsValueCreated)
            {
                objectDef.Dependency(HandlerType, _handlerDependencies.Value);
            }

            return(objectDef);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the specified <see cref="IAuthorizationRule{T}"/>
        /// </summary>
        /// <param name="ruleType">Closed generic rule type</param>
        /// <returns></returns>
        public ObjectDef AddRule(Type ruleType)
        {
            var openRuleType = ruleType
                               .FindInterfaceThatCloses(typeof(IAuthorizationRule <>));


            if (openRuleType == null)
            {
                throw new ArgumentOutOfRangeException("ruleType", "ruleType must close IAuthorizationRule<T>");
            }

            var modelType = openRuleType
                            .GetGenericArguments()
                            .First();

            var topDef = new ObjectDef(typeof(AuthorizationPolicy <>).MakeGenericType(modelType));

            _policies.Add(topDef);

            var ruleObjectDef = new ObjectDef(ruleType);

            topDef.Dependency(typeof(IAuthorizationRule <>).MakeGenericType(modelType), ruleObjectDef);

            return(ruleObjectDef);
        }
Exemplo n.º 5
0
        protected override ObjectDef buildObjectDef()
        {
            Validate();

            var objectDef = new ObjectDef(determineHandlerType());

            objectDef.Dependency(createLambda());

            return(objectDef);
        }
Exemplo n.º 6
0
        public ObjectDef ToObjectDef(DiagnosticLevel level)
        {
            var objectDef = new ObjectDef(typeof(MediaWriter <>).MakeGenericType(_inputType));

            if (Links.Dependency != null)
            {
                objectDef.Dependency(Links.Dependency);
            }
            if (Projection.Dependency != null)
            {
                objectDef.Dependency(Projection.Dependency);
            }
            if (Document.Dependency != null)
            {
                objectDef.Dependency(Document.Dependency);
            }

            return(objectDef);
        }
        protected override ObjectDef toWriterDef()
        {
            var objectDef = new ObjectDef(typeof(MediaWriter <>).MakeGenericType(_resourceType));

            if (Links.Dependency != null)
            {
                objectDef.Dependency(Links.Dependency);
            }
            if (Projection.Dependency != null)
            {
                objectDef.Dependency(Projection.Dependency);
            }
            if (Document.Dependency != null)
            {
                objectDef.Dependency(Document.Dependency);
            }

            return(objectDef);
        }
Exemplo n.º 8
0
        protected override ObjectDef buildObjectDef()
        {
            var def = new ObjectDef(typeof(OutputBehavior <>), _resourceType);

            Type mediaType      = typeof(IMedia <>).MakeGenericType(_resourceType);
            Type enumerableType = typeof(IEnumerable <>).MakeGenericType(mediaType);
            var  dependency     = new ListDependency(enumerableType);

            dependency.AddRange(Writers.OfType <IContainerModel>().Select(x => x.ToObjectDef()));

            def.Dependency(dependency);

            if (ResourceNotFound != null)
            {
                def.Dependency(typeof(IResourceNotFoundHandler), ResourceNotFound);
            }

            return(def);
        }
Exemplo n.º 9
0
        protected override ObjectDef buildObjectDef()
        {
            ObjectDef def = ObjectDef.ForType <TopicBehavior>();

            def.DependencyByValue(typeof(Topic), Topic);
            ObjectDef viewDef = Topic.File.ToViewToken().ToViewFactoryObjectDef();

            def.Dependency(typeof(IViewFactory), viewDef);

            return(def);
        }
Exemplo n.º 10
0
        ObjectDef IContainerModel.ToObjectDef()
        {
            var def = new ObjectDef(typeof(Media <>), ResourceType);

            def.DependencyByType <IConditional>(_conditionalDef);

            var writerType = typeof(IMediaWriter <>).MakeGenericType(ResourceType);

            // TODO -- validate that it's really an IMediaWriter<T>
            def.Dependency(writerType, toWriterDef());

            return(def);
        }
Exemplo n.º 11
0
        protected override ObjectDef toWriterDef()
        {
            var def = new ObjectDef(typeof(ViewWriter<>), ResourceType);

            def.DependencyByType<IViewFactory>(_token.ToViewFactoryObjectDef());

            var activator = new ObjectDef(typeof (FubuPageActivator<>), _token.ViewModel);
            activator.DependencyByValue(typeof (IViewToken), _token);

            def.Dependency(typeof (IFubuPageActivator), activator);

            return def;
        }
Exemplo n.º 12
0
        protected override ObjectDef toWriterDef()
        {
            var def = new ObjectDef(typeof(ViewWriter <>), ResourceType);

            def.DependencyByType <IViewFactory>(_token.ToViewFactoryObjectDef());

            var activator = new ObjectDef(typeof(FubuPageActivator <>), _token.ViewModel);

            activator.DependencyByValue(typeof(IViewToken), _token);

            def.Dependency(typeof(IFubuPageActivator), activator);

            return(def);
        }
        protected override ObjectDef buildObjectDef()
        {
            if (Repository == null)
            {
                throw new InvalidOperationException(
                    "something descriptive here saying you don't know how to do the repo for the saga");
            }

            var def = new ObjectDef(typeof (SagaBehavior<,,>), _types.StateType, _types.MessageType, _types.HandlerType);
            var repositoryType = typeof (ISagaRepository<,>).MakeGenericType(_types.StateType, _types.MessageType);
            def.Dependency(repositoryType, Repository);

            return def;
        }
Exemplo n.º 14
0
        protected override ObjectDef buildObjectDef()
        {
            var def = new ObjectDef(typeof(InputBehavior <>), _inputType);

            var readerType     = typeof(IReader <>).MakeGenericType(_inputType);
            var enumerableType = typeof(IEnumerable <>).MakeGenericType(readerType);
            var dependency     = new ListDependency(enumerableType);

            dependency.AddRange(Readers.OfType <IContainerModel>().Select(x => x.ToObjectDef()));

            def.Dependency(dependency);

            return(def);
        }
Exemplo n.º 15
0
        protected override sealed ObjectDef buildObjectDef()
        {
            var objectDef = new ObjectDef(behaviorType().MakeGenericType(InputType));

            var mediaReaderType = getReaderWriterType().MakeGenericType(InputType);


            var readerDependencies = new ListDependency(typeof(IEnumerable <>).MakeGenericType(mediaReaderType));

            readerDependencies.AddRange(createBuilderDependencies());

            objectDef.Dependency(readerDependencies);

            return(objectDef);
        }
Exemplo n.º 16
0
        protected override ObjectDef buildObjectDef()
        {
            if (Repository == null)
            {
                throw new InvalidOperationException(
                          "something descriptive here saying you don't know how to do the repo for the saga");
            }

            var def            = new ObjectDef(typeof(SagaBehavior <, ,>), _types.StateType, _types.MessageType, _types.HandlerType);
            var repositoryType = typeof(ISagaRepository <,>).MakeGenericType(_types.StateType, _types.MessageType);

            def.Dependency(repositoryType, Repository);

            return(def);
        }
Exemplo n.º 17
0
        public void Should_satisfy_dependency()
        {
            var def = new ObjectDef(typeof(NeedListOfDoers));

            var doer1 = new ASomethingDoer();

            var doers = new ListDependency(typeof(IEnumerable <ISomethingDoer>));

            doers.AddValue(doer1);
            doers.AddType(typeof(BSomethingDoer));

            def.Dependency(doers);


            def.Dependencies.ShouldHaveCount(1);
        }
Exemplo n.º 18
0
        protected override ObjectDef buildObjectDef()
        {
            var def = new ObjectDef(typeof(OutputBehavior <>), _resourceType);



            var collectionType = typeof(IMediaCollection <>).MakeGenericType(_resourceType);
            var collection     = typeof(MediaCollection <>).CloseAndBuildAs <object>(this, _resourceType);

            def.DependencyByValue(collectionType, collection);

            if (ResourceNotFound != null)
            {
                def.Dependency(typeof(IResourceNotFoundHandler), ResourceNotFound);
            }

            return(def);
        }
Exemplo n.º 19
0
        public void Should_satisfy_dependency()
        {
            var def = new ObjectDef(typeof(NeedListOfDoers));

            var doer1 = new ASomethingDoer();

            var doers = new ListDependency(typeof (IEnumerable<ISomethingDoer>));
            doers.AddValue(doer1);
            doers.AddType(typeof (BSomethingDoer));

            def.Dependency(doers);

            def.Dependencies.ShouldHaveCount(1);
        }