public static Model.Client From(IClientTemplate c) { var client = new Model.Client() { Name = c.Name, Properties = new ClientProperties() { Description = c.Properties.Description, IsEnabled = c.IsEnabled, }, Schedule = new ClientSchedule() { IsRunContinuously = c.Schedule.IsRunContinuously, RunEverySeconds = c.Schedule.RunEverySeconds }, Plugin = new Plugin() { DLLName = c.PluginTemplate.DLLName, FullClassName = c.PluginTemplate.FullClassName, }, Runtime = new ClientRuntime() { LastRun = c.Status.LastRun, LastLifeSign = c.Status.LastLifeSign, NextRun = c.Status.NextRun } }; return(client); }
public IClient MakeClient(IClientTemplate template) { // Construct and initialize settings for a second AppDomain. AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; ads.DisallowBindingRedirects = false; ads.DisallowCodeDownload = true; ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; // Create the second AppDomain. AppDomain ad = AppDomain.CreateDomain("AD #2", null, ads); //ad.FirstChanceException += Ad_FirstChanceException; //ad.UnhandledException += Ad_UnhandledException; Type t = template.PluginTemplate.PluginType; IPlugin plugin = (IPlugin)ad.CreateInstanceAndUnwrap(t.Assembly.FullName, t.FullName); //TODO Use reflection to setup plugin properties //TODO Pass client properties to plugin DefaultClient client = new DefaultClient() { AppDomain = ad, Plugin = plugin, Properties = new ClientProperties() { Properties = template.Properties //TODO Make your own copy. } }; client.Properties.Name = template.Properties["Name"]; //TODO Use reflection. return(client); }
public SandboxBuilder(IClientTemplate template) { _template = Guard.NotNull(template); }
private bool IsPluginChanged(IClientTemplate template) { return (clients[template.Name].PluginTemplate.FullClassName != template.PluginTemplate.FullClassName || clients[template.Name].PluginTemplate.DLLName != template.PluginTemplate.DLLName); }
private bool IsClientExists(IClientTemplate template) { return(clients.ContainsClientWithName(template.Name)); }
private bool IsNewClientRequired(IClientTemplate template) { return(!IsClientExists(template) || IsPluginChanged(template)); }
private void Merge(IClient client, IClientTemplate ct) { client.Plugin.Properties = ct.Properties.Properties.Clone(); client.Properties = ct.Properties.Clone(); client.Schedule = ct.Schedule.Clone(); }
private void MakeAndAddNew(IClientTemplate template) { var client = clientFactory.MakeClient(template); clients.Add(template.Name, client); }
public void Add(string key, IClientTemplate template) { templates.Add(key, template); }