示例#1
0
        public GameHostModule(Entity source, Context ctxParent, GameHostModuleDescription description)
        {
            if (!description.IsNameIdValid())
            {
                throw new InvalidOperationException($"The mod '{description.NameId}' has invalid characters!");
            }

            Source                = source;
            Ctx                   = new Context(ctxParent);
            Storage               = this.storage = new();
            DllStorage            = new DllStorage(GetType().Assembly);
            ReferencedDisposables = new List <IDisposable>();

            var strategy = new ContextBindingStrategy(Ctx, true);
            var storage  = strategy.Resolve <IStorage>();

            if (storage == null)
            {
                throw new NullReferenceException(nameof(storage));
            }

            storage.GetOrCreateDirectoryAsync($"ModuleData/{description.NameId}").ContinueWith(OnRequiredDirectoryFound);
        }