コード例 #1
0
        public Dungeon GetDungeon(string id)
        {
            using (TinyIoCContainer requestContainer = _container.GetChildContainer())
            {
                Dungeon       result = null;
                IDungeonDepot depot  = requestContainer.Resolve <IDungeonDepot>();

                if (depot.ContainsKey(id))
                {
                    DungeonConfigEntity dungeonConfig = depot[id];
                    requestContainer.Register <DungeonConfigEntity>(dungeonConfig);

                    //TODO: Pull the generator by name stored in the config
                    IDungeonGenerator generator = requestContainer.Resolve <IDungeonGenerator>();

                    result = generator.Generate();
                }
                else if (id == _defaultId)
                {
                    // return the default dungeon
                    result = new Dungeon(_defaultId, _defaultSize, _defaultSize);
                }
                else
                {
                    throw new WebFaultException <string>(
                              string.Format("No dungeon exists with id {0}", id),
                              HttpStatusCode.NotFound);
                }


                return(result);
            }
        }
コード例 #2
0
 public DualContainer GetChildContainer()
 {
     return(new DualContainer
     {
         TinyIoCContainer = TinyIoCContainer.GetChildContainer(),
         ApplicationContext = this.ApplicationContext
     });
 }
コード例 #3
0
        public IDependencyScope BeginScope()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("this", "This scope has already been disposed.");
            }

            return(new TinyIocWebApiDependencyResolver(_container.GetChildContainer()));
        }
コード例 #4
0
ファイル: JobStore.cs プロジェクト: f-spot/f-spot-xplat
 Job CreateJob(string type, uint id, string options, DateTime runAt, JobPriority priority)
 {
     using (var childContainer = container.GetChildContainer()) {
         childContainer.Register(new JobData
         {
             Id          = id,
             JobOptions  = options,
             JobPriority = priority,
             RunAt       = runAt,
             Persistent  = true
         });
         childContainer.TryResolve <Job> (type, out var job);
         if (job == null)
         {
             Log.Error($"Unknown job type {type} ignored.");
         }
         return(job);
     }
 }
コード例 #5
0
        public IDependencyScope BeginScope()
        {
            var childContainer = Container.GetChildContainer();

            return(new TinyIocDependencyResolver(childContainer));
        }
コード例 #6
0
 public IDependencyResolver GetChildService()
 {
     return(new TinyIoCDependencyService(_container.GetChildContainer()));
 }
コード例 #7
0
 public IInjector GetChildContainer()
 {
     return(new InjectorProvider(_tinyIoCContainer.GetChildContainer()));
 }
コード例 #8
0
 public IDependencyScope BeginScope()
 {
     return(new TinyIoCResolver(_container.GetChildContainer()));
 }