コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: SampleFactory.cs プロジェクト: YongLWei03/EM-1
        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);
        }
コード例 #3
0
 public SandboxBuilder(IClientTemplate template)
 {
     _template = Guard.NotNull(template);
 }
コード例 #4
0
 private bool IsPluginChanged(IClientTemplate template)
 {
     return
         (clients[template.Name].PluginTemplate.FullClassName != template.PluginTemplate.FullClassName ||
          clients[template.Name].PluginTemplate.DLLName != template.PluginTemplate.DLLName);
 }
コード例 #5
0
 private bool IsClientExists(IClientTemplate template)
 {
     return(clients.ContainsClientWithName(template.Name));
 }
コード例 #6
0
 private bool IsNewClientRequired(IClientTemplate template)
 {
     return(!IsClientExists(template) || IsPluginChanged(template));
 }
コード例 #7
0
 private void Merge(IClient client, IClientTemplate ct)
 {
     client.Plugin.Properties = ct.Properties.Properties.Clone();
     client.Properties        = ct.Properties.Clone();
     client.Schedule          = ct.Schedule.Clone();
 }
コード例 #8
0
        private void MakeAndAddNew(IClientTemplate template)
        {
            var client = clientFactory.MakeClient(template);

            clients.Add(template.Name, client);
        }
コード例 #9
0
 public void Add(string key, IClientTemplate template)
 {
     templates.Add(key, template);
 }