Exemple #1
0
        public object GetService(Type serviceType, string name)
        {
            if (disposedValue)
            {
                throw new ObjectDisposedException("Has been disposed.");
            }
            var defintion = Defintions.TryGet(serviceType, name);

            if (defintion != null)
            {
                switch (defintion.Lifetime)
                {
                case Lifetime.Singleton:
                    return(SingletonCache.GetOrAdd(defintion, d => d.ImplementationFactory(Root)));

                case Lifetime.Scoped:
                    return(scopedCache.GetOrAdd(defintion, d => d.ImplementationFactory(this)));

                case Lifetime.Transient:
                    return(defintion.ImplementationFactory(this));

                default:
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
 /// <inheritdoc />
 protected override void LateSetup()
 {
     base.LateSetup();
     WriteToLog("LateSetup", $"Cargo: {MyAPIGateway.Session.SessionSettings.CargoShipsEnabled}", LogType.General);
     WriteToLog("LateSetup", $"Encounters: {MyAPIGateway.Session.SessionSettings.EnableEncounters}", LogType.General);
     WriteToLog("LateSetup", $"Drones: {MyAPIGateway.Session.SessionSettings.EnableDrones}", LogType.General);
     WriteToLog("LateSetup", $"Scripts: {MyAPIGateway.Session.SessionSettings.EnableIngameScripts}", LogType.General);
     WriteToLog("LateSetup", $"Sync: {MyAPIGateway.Session.SessionSettings.SyncDistance}", LogType.General);
     WriteToLog("LateSetup", $"View: {MyAPIGateway.Session.SessionSettings.ViewDistance}", LogType.General);
     WriteToLog("LateSetup", $"PiratePCU: {MyAPIGateway.Session.SessionSettings.PiratePCU}", LogType.General);
     WriteToLog("LateSetup", $"TotalPCU: {MyAPIGateway.Session.SessionSettings.TotalPCU}", LogType.General);
     foreach (MyObjectBuilder_Checkpoint.ModItem mod in MyAPIGateway.Session.Mods)
     {
         WriteToLog("LateSetup", $"Mod: {mod}", LogType.General);
     }
     Defintions.InitDefnitions();
 }