コード例 #1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            PluginStorage.ExecutePlugins((s, exception) => exception.SendExceptionToDeveloper("Error executando plugin: " + s));
        }
コード例 #2
0
        public void CreateJob(JobConfigModel model)
        {
            //Instanciate plugins depending on class name
            Job job = PluginStorage.CreateObject <Job>(model.ClassName);

            //Load job from config
            job.LoadConfig(model.GetConfig());

            //Create repository configuration in jobs folder
            job.CreateRepository("jobs");
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: noisecrime/ForBlog
        /// <summary>
        /// DataGrid's Delete button click
        /// </summary>
        private void datagridDelete_Click(object sender, RoutedEventArgs e)
        {
            PluginModel pm = ((FrameworkElement)sender).DataContext as PluginModel;

            if (pm == null)
            {
                throw new ApplicationException();
            }

            this.m_data.Remove(pm);

            this.dataGrid.Items.Refresh();
            this.dataGrid.UpdateLayout();

            PluginStorage.SaveModels(this.m_data);
        }
コード例 #4
0
ファイル: JobConfigModel.cs プロジェクト: Emile95/Ludovik
        public Config GetConfig()
        {
            Config config = new Config();

            config.AddProperty(
                new DescriptionPropertyDefinition(),
                new Parameter[] {
                new Parameter()
                {
                    Definition = new StringParameterDefinition(),
                    Name       = "name",
                    Value      = Name
                },
                new Parameter()
                {
                    Definition = new StringParameterDefinition(),
                    Name       = "description",
                    Value      = Description
                }
            }
                );

            Properties.ForEach(o =>
            {
                List <Parameter> parameters = new List <Parameter>();
                foreach (Property.Parameter p in o.Parameters)
                {
                    parameters.Add(new Parameter()
                    {
                        Definition = PluginStorage.CreateObject <ParameterDefinition>(p.ClassName),
                        Name       = p.Name,
                        Value      = p.Value
                    });
                }

                config.AddProperty(
                    PluginStorage.CreateObject <PropertyDefinition>(o.ClassName),
                    parameters.ToArray()
                    );
            });

            return(config);
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: noisecrime/ForBlog
        /// <summary>
        /// Add new model of type m_addplugin
        /// </summary>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            SettingsWindow sw = new SettingsWindow();

            if (sw.ShowDialog(this.m_addplugin) == true)
            {
                this.m_data.Add(new PluginModel
                {
                    Plugin = sw.GetName(),
                    Data   = sw.GetData(),
                    Type   = this.m_addplugin.GetType()
                });

                this.dataGrid.Items.Refresh();
                this.dataGrid.UpdateLayout();

                PluginStorage.SaveModels(this.m_data);
            }
        }
コード例 #6
0
    public void InstallMenu(IBasicMenu parentMenu)
    {
        AHWorkFolder = $"{CurrentProfile.PluginsDirectory}\\AdicHelper";
        AHPath       = $"{AHWorkFolder}\\AdicHelper.exe";

        if (!File.Exists(AHPath))
        {
            Log.Error($"Can't run {AH}: file \"{AHPath}\" not found.");
            return;
        }

        Storage = ImportStorage.GetPluginStorage(typeof(AdicHelper));

        parentMenu.AppendMenuItem(AH, isEnabled: false);

        EnableParser        = parentMenu.AppendMenuItem("Enable cJASS", true, Storage.GetValue(nameof(EnableParser), true), true);
        EnableParser.Click += (s, e) => Storage.SetValue(nameof(EnableParser), EnableParser.IsChecked);

        EnableOptimizer        = parentMenu.AppendMenuItem("Enable optimizer", true, Storage.GetValue(nameof(EnableOptimizer), true), true);
        EnableOptimizer.Click += (s, e) => Storage.SetValue(nameof(EnableOptimizer), EnableOptimizer.IsChecked);

        DebugMode        = parentMenu.AppendMenuItem("Enable debug", true, Storage.GetValue(nameof(DebugMode), false), true);
        DebugMode.Click += (s, e) => Storage.SetValue(nameof(DebugMode), DebugMode.IsChecked);

        LocalsFlush        = parentMenu.AppendMenuItem("Locals auto flush", true, Storage.GetValue(nameof(LocalsFlush), true), true);
        LocalsFlush.Click += (s, e) => Storage.SetValue(nameof(LocalsFlush), LocalsFlush.IsChecked);

        DefaultCjBj        = parentMenu.AppendMenuItem("Compile for default cj and bj", true, Storage.GetValue(nameof(DefaultCjBj), true), true);
        DefaultCjBj.Click += (s, e) => Storage.SetValue(nameof(DefaultCjBj), DefaultCjBj.IsChecked);

        CompatMode        = parentMenu.AppendMenuItem("Modules compatibility mode", true, Storage.GetValue(nameof(CompatMode), true), true);
        CompatMode.Click += (s, e) => Storage.SetValue(nameof(CompatMode), CompatMode.IsChecked);

        NullBoolexpr        = parentMenu.AppendMenuItem("Use 'null' as default boolexpr", true, Storage.GetValue(nameof(NullBoolexpr), true), true);
        NullBoolexpr.Click += (s, e) => Storage.SetValue(nameof(NullBoolexpr), NullBoolexpr.IsChecked);

        parentMenu.AppendMenuItem("About AdicHelper...", false, false, true).Click += (s, e) => Process.Start(AHPath);

        Hooks.MapSaved += Hooks_MapSaved;

        Inited = true;
    }
コード例 #7
0
        public void RunJob(JobRunModel model)
        {
            //Instanciate plugins depending on class name
            Job job = PluginStorage.CreateObject <Job>(
                //Go Fetch class name from config file
                JObject.Parse(File.ReadAllText("jobs\\" + model.Name + "\\config.json")).Value <string>("_class")
                );

            //Load job from folder configuration
            job.LoadFromFolder("jobs", model.Name);

            //Create Logger list for the run
            LoggerList loggers = new LoggerList();

            //Add Standard logger in the logger list
            loggers.AddLogger(new StandardLogger());

            //Add job build in the process with his name as key and provide log
            _threadApplication.AddRun(model.Name, job, loggers);
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: noisecrime/ForBlog
        /// <summary>
        /// Application Initialization
        /// </summary>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //load models from file, if exists
            this.m_data = PluginStorage.GetModels();

            //binding for datagrid
            this.dataGrid.ItemsSource = this.m_data;
            ((DataGridTextColumn)this.dataGrid.Columns[0]).Binding = new Binding("Plugin");
            ((DataGridTextColumn)this.dataGrid.Columns[1]).Binding = new Binding("Data");

            //get all plugins
            var plugins = Plugins.ApplicationPlugins;

            //populate "add" menu items with plugins
            btnAddDropDownContainer.Children.Clear();

            foreach (var plugin in plugins)
            {
                var newmi = new MenuItem
                {
                    Header      = plugin.GetName(),
                    DataContext = plugin
                };
                newmi.Click += this.MenuItem_Click;

                btnAddDropDownContainer.Children.Add(newmi);
            }

            if (btnAddDropDownContainer.Children.Count == 0)
            {
                btnAdd.Content   = "No Plugins";
                btnAdd.IsEnabled = false;
            }
            else
            {
                var mi = ((MenuItem)btnAddDropDownContainer.Children[0]);
                SetPluginFromMenuItem(mi);
            }
        }
コード例 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSingleton <ThreadApplication>();

            services.AddScoped <IJobApplication, JobApplication>();

            PluginStorage.AddPlugin <Job>(typeof(StandardJob));

            PluginStorage.AddPlugin <ParameterDefinition>(typeof(StringParameterDefinition));
            PluginStorage.AddPlugin <ParameterDefinition>(typeof(BoolParameterDefinition));
            PluginStorage.AddPlugin <ParameterDefinition>(typeof(LabelParameterDefinition));

            PluginStorage.AddPlugin <PropertyDefinition>(typeof(DescriptionPropertyDefinition));
            PluginStorage.AddPlugin <PropertyDefinition>(typeof(ParameterizedRunPropertyDefinition));
            PluginStorage.AddPlugin <PropertyDefinition>(typeof(NodePropertyDefinition));
            PluginStorage.AddPlugin <PropertyDefinition>(typeof(WindowsBatchBuildStepDefinition));

            PluginStorage.AddPlugin <BuildStepDefinition>(typeof(WindowsBatchBuildStepDefinition));

            PluginStorage.AddPlugin <Logger>(typeof(StandardLogger));
            PluginStorage.AddPlugin <Logger>(typeof(JobBuildLogger));
        }
コード例 #10
0
        public static void Execute()
        {
            if (_initialized)
            {
                throw new InvalidOperationException("Compilador só pode ser executado no Pre-Start!");
            }

            _initialized = true;

            //plugin loader
            PluginLoaderEntryPoint.Initialize();

            if (BootstrapperSection.Instance.Kompiler.ForceRecompilation)
            {
                //se forçar a recompilação, remove o assembly existente.
                KompilerDbService.RemoveExistingCompiledAssemblyFromDb();
            }

            AddReferences(PluginStorage.GetAssemblies().ToArray());

            byte[] buffer = new byte[0];
            string msg;

            try
            {
                //todo: usar depdendency injection
                IKompiler kompiler;

                if (BootstrapperSection.Instance.Kompiler.Roslyn)
                {
                    kompiler = new RoslynKompiler();
                }
                else
                {
                    kompiler = new CodeDomWrapper();
                }

                if (BootstrapperSection.Instance.Kompiler.LoadFromDb)
                {
                    Trace.TraceInformation("Compiling from DB...");
                    var source = KompilerDbService.LoadSourceCodeFromDb();
                    msg = kompiler.CompileFromSource(source, out buffer);
                }
                else
                {
                    var localRootFolder = BootstrapperSection.Instance.DumpToLocal.Folder;
                    Trace.TraceInformation("Compiling from Local File System: {0}", localRootFolder);
                    msg = kompiler.CompileFromFolder(localRootFolder, out buffer);
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                Trace.TraceInformation("Erro durante a compilação do projeto no banco de dados. \r\n" + ex.Message);
            }

            if (string.IsNullOrWhiteSpace(msg) && buffer.Length > 0)
            {
                Trace.TraceInformation("[Kompiler]: DB Compilation Result: SUCCESS");

                if (!BootstrapperSection.Instance.Kompiler.ForceRecompilation)
                {
                    //só salva no banco se compilação forçada for False
                    KompilerDbService.SaveCompiledCustomAssembly(buffer);
                }

                PluginLoaderEntryPoint.SaveAndLoadAssembly(CompiledAssemblyName + ".dll", buffer);
            }
            else
            {
                Trace.TraceInformation("[Kompiler]: DB Compilation Result: Bytes:{0}, Msg:{1}",
                                       buffer.Length, msg);
            }
        }
コード例 #11
0
ファイル: StandardJob.cs プロジェクト: Emile95/Ludovik
        public sealed override void LoadFromFolder(string path, string folderName)
        {
            //Config.json object
            string  configFile       = File.ReadAllText(path + "\\" + folderName + "\\config.json");
            JObject configFileObject = JObject.Parse(configFile);

            Name        = folderName;
            Description = configFileObject.Value <string>("description");

            JArray propConfigObjects = configFileObject
                                       .Value <JArray>("properties");

            foreach (JToken propConfigObject in propConfigObjects)
            {
                Property prop = new Property()
                {
                    Definition = PluginStorage.CreateObject <PropertyDefinition>(propConfigObject.Value <string>("_class"))
                };
                foreach (JToken parameterConfigObject in propConfigObject.Value <JArray>("parameters"))
                {
                    prop.Parameters.Add(new Parameter()
                    {
                        Definition = PluginStorage.CreateObject <ParameterDefinition>(parameterConfigObject.Value <string>("_class")),
                        Name       = parameterConfigObject.Value <string>("name"),
                        Value      = parameterConfigObject.Value <string>("value")
                    });
                }

                Properties.Add(prop);
            }

            JArray buildStepConfigObjects = configFileObject
                                            .Value <JArray>("buildSteps");

            foreach (JToken buildStepConfigObject in buildStepConfigObjects)
            {
                BuildStep buildStep = new BuildStep()
                {
                    Definition = PluginStorage.CreateObject <BuildStepDefinition>(buildStepConfigObject.Value <string>("_class"))
                };
                foreach (JToken parameterConfigObject in buildStepConfigObject.Value <JArray>("parameters"))
                {
                    buildStep.Parameters.Add(new Parameter()
                    {
                        Definition = PluginStorage.CreateObject <ParameterDefinition>(parameterConfigObject.Value <string>("_class")),
                        Name       = parameterConfigObject.Value <string>("name"),
                        Value      = parameterConfigObject.Value <string>("value")
                    });
                }

                BuildSteps.Add(buildStep);
            }

            Properties.Add(new Property()
            {
                Definition = new DescriptionPropertyDefinition.DescriptionPropertyDefinition(),
                Parameters = new List <Parameter>()
                {
                    new Parameter()
                    {
                        Definition = new StringParameterDefinition.StringParameterDefinition(),
                        Name       = "name",
                        Value      = this.Name
                    },
                    new Parameter()
                    {
                        Definition = new StringParameterDefinition.StringParameterDefinition(),
                        Name       = "description",
                        Value      = this.Description
                    }
                }
            });
        }