public ScriptContext Init()
        {
            if (HasInit)
            {
                return(this);
            }
            HasInit = true;

            if (ScriptMethods.Count > 0)
            {
                ScriptMethods.InsertRange(0, InsertScriptMethods);
            }
            if (ScriptBlocks.Count > 0)
            {
                ScriptBlocks.InsertRange(0, InsertScriptBlocks);
            }
            if (Plugins.Count > 0)
            {
                Plugins.InsertRange(0, InsertPlugins);
            }

            Args[ScriptConstants.Debug] = DebugMode;

            Container.AddSingleton(() => this);
            Container.AddSingleton(() => Pages);

            var beforePlugins = Plugins.OfType <IScriptPluginBefore>();

            foreach (var plugin in beforePlugins)
            {
                plugin.BeforePluginsLoaded(this);
            }
            foreach (var plugin in Plugins)
            {
                plugin.Register(this);
            }

            OnAfterPlugins?.Invoke(this);

            foreach (var type in ScanTypes)
            {
                ScanType(type);
            }

            foreach (var assembly in ScanAssemblies.Safe())
            {
                foreach (var type in assembly.GetTypes())
                {
                    ScanType(type);
                }
            }

            foreach (var method in ScriptMethods)
            {
                InitMethod(method);
            }

            foreach (var block in ScriptBlocks)
            {
                InitBlock(block);
                blocksMap[block.Name] = block;
            }

            var afterPlugins = Plugins.OfType <IScriptPluginAfter>();

            foreach (var plugin in afterPlugins)
            {
                plugin.AfterPluginsLoaded(this);
            }

            return(this);
        }
 public ScriptContext RemoveFilters(Predicate <ScriptMethods> match)
 {
     ScriptMethods.RemoveAll(match);
     return(this);
 }