public void build_an_object_with_dependencies() { var request = new InMemoryFubuRequest(); var def = new ObjectDef(typeof(FakeJsonBehavior)); def.DependencyByValue(typeof(IFubuRequest), request); var jsonWriter = def.DependencyByType(typeof(IJsonWriter), typeof(AjaxAwareJsonWriter)); jsonWriter.DependencyByType(typeof(IOutputWriter), typeof(OutputWriter)); jsonWriter.DependencyByType(typeof(IRequestData), typeof(InMemoryRequestData)); def.DependencyByType(typeof(IRequestData), typeof(InMemoryRequestData)); var container = new Container(x => { x.For <IFileSystem>().Use <FileSystem>(); x.For <IHttpWriter>().Use <NulloHttpWriter>(); x.For <IActionBehavior>().Use(new ObjectDefInstance(def)); x.For <ILogger>().Use <Logger>(); x.For <ISystemTime>().Use(SystemTime.Default); }); var jsonBehavior = container.GetInstance <IActionBehavior>().ShouldBeOfType <FakeJsonBehavior>(); jsonBehavior.Writer.ShouldBeOfType <AjaxAwareJsonWriter>(); jsonBehavior.Request.ShouldBeTheSameAs(request); }
public void build_an_object_with_dependencies() { var request = new InMemoryFubuRequest(); var def = new ObjectDef(typeof (FakeJsonBehavior)); def.DependencyByValue(typeof (IFubuRequest), request); var jsonWriter = def.DependencyByType(typeof (IJsonWriter), typeof (AjaxAwareJsonWriter)); jsonWriter.DependencyByType(typeof (IOutputWriter), typeof (OutputWriter)); jsonWriter.DependencyByType(typeof(IRequestData), typeof(InMemoryRequestData)); def.DependencyByType(typeof (IRequestData), typeof (InMemoryRequestData)); var container = new Container(x => { x.For<IFileSystem>().Use<FileSystem>(); x.For<IHttpWriter>().Use<NulloHttpWriter>(); x.For<IActionBehavior>().UseInstance(new ObjectDefInstance(def)); x.For<ILogger>().Use<Logger>(); x.For<ISystemTime>().Use(() => SystemTime.Default()); }); var jsonBehavior = container.GetInstance<IActionBehavior>().ShouldBeOfType<FakeJsonBehavior>(); jsonBehavior.Writer.ShouldBeOfType<AjaxAwareJsonWriter>(); jsonBehavior.Request.ShouldBeTheSameAs(request); }
private ObjectDef buildObjectDef(DiagnosticLevel diagnosticLevel) { var topDef = Top.As <IContainerModel>().ToObjectDef(diagnosticLevel); if (diagnosticLevel == DiagnosticLevel.FullRequestTracing && !IsPartialOnly) { var objectDef = new ObjectDef(typeof(DiagnosticBehavior)) { Name = UniqueId.ToString() }; objectDef.DependencyByType <IActionBehavior>(topDef); topDef.Name = Guid.NewGuid().ToString(); var list = new List <ObjectDef>(); var def = topDef; while (def != null) { list.Add(def); def = def.FindDependencyDefinitionFor <IActionBehavior>(); } return(objectDef); } return(topDef); }
protected override void configure(ObjectDef def) { if (_membershipType != null) { def.DependencyByType <IMembershipRepository>(new ObjectDef(_membershipType)); } }
protected override ObjectDef toWriterDef() { var def = new ObjectDef(typeof(ViewWriter<>), ResourceType); def.DependencyByType<IViewFactory>(_token.ToViewFactoryObjectDef()); return def; }
protected override ObjectDef toWriterDef() { var def = new ObjectDef(typeof(ViewWriter <>), ResourceType); def.DependencyByType <IViewFactory>(_token.ToViewFactoryObjectDef()); return(def); }
public ObjectDef ToObjectDef(DiagnosticLevel level) { var objectDef = new ObjectDef(typeof(FeedWriter <T>)); objectDef.DependencyByType(typeof(IFeedSource <T>), FeedSourceType); objectDef.DependencyByValue(typeof(IFeedDefinition <T>), _feed); return(objectDef); }
protected override void configureObject(ObjectDef def) { var renderer = def.DependencyByType(typeof(IViewRenderer), typeof(ViewRenderer)); var viewEntrySource = renderer.DependencyByType(typeof(IRenderAction), typeof(RenderAction)) .DependencyByType(typeof(IViewFactory), typeof(ViewFactory)) .DependencyByType(typeof(IViewEntrySource), typeof(ViewEntrySource)); viewEntrySource.DependencyByValue(_descriptor); }
protected ObjectDef toObjectDef() { ObjectDef objectDef = buildObjectDef(); if (Next != null) { var nextObjectDef = Next.As <IContainerModel>().ToObjectDef(); objectDef.DependencyByType <IActionBehavior>(nextObjectDef); } return(objectDef); }
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); }
protected override ObjectDef BuildObjectDef() { var messageType = Chain.MessageType; var handlerDef = new ObjectDef(typeof (ConditionalHandler<>), messageType); var dependencyType = typeof (ICondition<>).MakeGenericType(messageType); var conditionType = ConditionType; if(conditionType.IsOpenGeneric()) { conditionType = ConditionType.MakeGenericType(messageType); } handlerDef.DependencyByType(dependencyType, conditionType); return handlerDef; }
protected override void configureObject(ObjectDef def) { var renderer = def.DependencyByType(typeof(IViewRenderer), typeof(ViewRenderer)); var viewDefinition = new ViewDefinition(createSparkDescriptor(true), createSparkDescriptor(false)); var viewEntrySource = renderer.DependencyByType(typeof(IRenderAction), typeof(RenderAction)) .DependencyByType(typeof(IViewFactory), typeof(ViewFactory)) .DependencyByType(typeof(IViewEntrySource), typeof(ViewEntrySource)); viewEntrySource.DependencyByValue(_cache); viewEntrySource.DependencyByValue(viewDefinition); }
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 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); }
private ObjectDef createTracerDef(ObjectDef objectDef) { var tracerDef = new ObjectDef(typeof(BehaviorTracer)); tracerDef.DependencyByType <IActionBehavior>(objectDef); var chain = ParentChain(); tracerDef.DependencyByValue(new BehaviorCorrelation { ChainId = chain == null ? Guid.Empty : chain.UniqueId, BehaviorId = UniqueId }); return(tracerDef); }
private void attachNextBehavior(ObjectDef objectDef, DiagnosticLevel diagnosticLevel) { var nextObjectDef = Next.As<IContainerModel>().ToObjectDef(diagnosticLevel); objectDef.DependencyByType<IActionBehavior>(nextObjectDef); }
private void attachNextBehavior(ObjectDef objectDef) { var nextObjectDef = Next.As <IContainerModel>().ToObjectDef(); objectDef.DependencyByType <IActionBehavior>(nextObjectDef); }
public SpecialView(IViewToken view) { _def = new ObjectDef(typeof(SpecialViewWriter <>), typeof(T)); _def.DependencyByType <IViewFactory>(view.ToViewFactoryObjectDef()); }
private ObjectDef createTracerDef(ObjectDef objectDef) { var tracerDef = new ObjectDef(typeof(BehaviorTracer)); tracerDef.DependencyByType<IActionBehavior>(objectDef); var chain = ParentChain(); tracerDef.DependencyByValue(new BehaviorCorrelation { ChainId = chain == null ? Guid.Empty : chain.UniqueId, BehaviorId = UniqueId }); return tracerDef; }