예제 #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
     });
 }
        public IDependencyScope BeginScope()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("this", "This scope has already been disposed.");
            }

            return(new TinyIocWebApiDependencyResolver(_container.GetChildContainer()));
        }
예제 #4
0
 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));
        }
 public IDependencyResolver GetChildService()
 {
     return(new TinyIoCDependencyService(_container.GetChildContainer()));
 }
 public IInjector GetChildContainer()
 {
     return(new InjectorProvider(_tinyIoCContainer.GetChildContainer()));
 }
 public IDependencyScope BeginScope()
 {
     return(new TinyIoCResolver(_container.GetChildContainer()));
 }