public virtual void OnBindToElement(AppSettingsSection appSettings, CommanderSection commanderSettings, NamedConfigurationElement element)
        {
            var handler = BindToElement;
            if (handler != null)
            {
				handler(this, new BindToElementEventArgs(appSettings, commanderSettings, element));
            }
        }
		private string GetValue(string appSettingKey, NamedConfigurationElement namedConfigurationElement)
		{
			var projectName = GetCurrentProjectElement(_commanderSettings, namedConfigurationElement).Name;
			var elementName = namedConfigurationElement.Name;
			return _appSettings.Settings[appSettingKey].Value
				.Replace("%ProjectName%", projectName)
				.Replace("%ElementName%", elementName);
		}
Example #3
0
 public CacheConfig(INamedElement element)
 {
     if (element == null)
     {
         element = new NamedConfigurationElement()
         {
             Name = SectionName
         }
     }
     ;
     Children   = element.Children;
     Attributes = element.Attributes;
     Name       = element.Name;
 }
Example #4
0
 public AuditConfig(INamedElement element)
 {
     if (element == null)
     {
         element = new NamedConfigurationElement()
         {
             Name = SectionName
         }
     }
     ;
     Children   = element.Children;
     Attributes = element.Attributes;
     //Name = element.Name;
     _useLocalTime = Attributes.ContainsKey(USE_LOCAL_TIME) && bool.Parse(Attributes[USE_LOCAL_TIME]);
     _useOUID      = Attributes.ContainsKey(USE_OUID) && bool.Parse(Attributes[USE_OUID]);
 }
		/// <summary>
		/// Get the project element for a plugin.
		/// </summary>
		/// <param name="commanderSettings"></param>
		/// <param name="namedConfigurationElement"></param>
		/// <returns>The project element for the plugin.</returns>
		private ProjectElement GetCurrentProjectElement(CommanderSection commanderSettings, NamedConfigurationElement namedConfigurationElement)
		{
			if (namedConfigurationElement is FolderElement)
			{
				var projectElementForFolderElement = commanderSettings.Projects
					.Where(x => x.Folders
						.Where(y => y.Name == namedConfigurationElement.Name)
						.Any()
					)
					.First();

				return projectElementForFolderElement;
			}

			var projectElementForPlugin = commanderSettings.Projects
				.Where(x => x.CommandPlugins
					.SelectMany(y => y.Cast<NamedConfigurationElement>())					
					.Where(z => z.Name == namedConfigurationElement.Name)
					.Any()
				)
				.First();

			return projectElementForPlugin;
		}
Example #6
0
        protected static T FromLegacyConfiguration <T>(NamedConfigurationElement legacyConfiguration, ServiceConfiguration baseConfiguration = null, Profile profile = null, Dictionary <string, string> options = null) where T : ServiceConfiguration, new()
        {
            if (legacyConfiguration is AccountServiceElement || legacyConfiguration is WorkflowStepElement || legacyConfiguration is ActiveServiceElement)
            {
                if (baseConfiguration == null)
                {
                    throw new ArgumentNullException("baseConfiguration", "When creating a configuration from a Legacy.AccountServiceElement or Legacy.ActiveServiceElement, baseConfiguration must be supplied.");
                }
                if (profile == null)
                {
                    throw new ArgumentNullException("profile", "When creating a configuration from a Legacy.AccountServiceElement or Legacy.ActiveServiceElement, profile must be supplied.");
                }
            }
            if (legacyConfiguration is ServiceElement && !(legacyConfiguration is ActiveServiceElement))
            {
                if (baseConfiguration != null)
                {
                    throw new ArgumentException("baseConfiguration", "When creating a configuration from a Legacy.ServiceInstance, baseConfiguration must be null.");
                }
                if (profile != null)
                {
                    throw new ArgumentException("profile", "When creating a configuration from a Legacy.ServiceInstance, profile must be null.");
                }
            }

            ServiceElement legacy;

            if (legacyConfiguration is AccountServiceElement)
            {
                legacy = new ActiveServiceElement(legacyConfiguration as AccountServiceElement);
            }
            else if (legacyConfiguration is WorkflowStepElement)
            {
                legacy = new ActiveServiceElement(legacyConfiguration as WorkflowStepElement);
            }
            else
            {
                if (options != null)
                {
                    legacy = new ActiveServiceElement((ServiceElement)legacyConfiguration);
                }
                else
                {
                    legacy = (ServiceElement)legacyConfiguration;
                }
            }
            if (options != null)
            {
                legacy.Options.Merge(options);
            }

            T serviceConfiguration = new T()
            {
                _name                   = legacy.Name,
                MaxConcurrent           = (legacy.MaxInstances == 0) ? 9999 : legacy.MaxInstances,
                MaxConcurrentPerProfile = (legacy.MaxInstancesPerAccount == 0) ? 9999 : legacy.MaxInstancesPerAccount,
                _legacyConfiguration    = legacy,
                _baseConfiguration      = baseConfiguration,
                _schedulingProfile      = profile
            };

            if (legacy.Options.ContainsKey("ServicePriority"))
            {
                serviceConfiguration._priority = int.Parse(legacy.Options["ServicePriority"]);
            }

            //scheduling rules
            foreach (SchedulingRuleElement schedulingRuleElement in legacy.SchedulingRules)
            {
                SchedulingRule rule = SchedulingRule.FromLegacyRule(schedulingRuleElement);
                if (serviceConfiguration.SchedulingRules == null)
                {
                    serviceConfiguration.SchedulingRules = new List <SchedulingRule>();
                }
                serviceConfiguration.SchedulingRules.Add(rule);
            }

            return(serviceConfiguration);
        }
Example #7
0
 public static ServiceConfiguration FromLegacyConfiguration(NamedConfigurationElement legacyConfiguration, ServiceConfiguration baseConfiguration = null, Profile profile = null, Dictionary <string, string> options = null)
 {
     return(FromLegacyConfiguration <ServiceConfiguration>(legacyConfiguration, baseConfiguration, profile, options));
 }
		public string CompletedPath(NamedConfigurationElement namedConfigurationElement)
		{
			return GetValue("completedPath", namedConfigurationElement);
		}
		public string OutPutPath(NamedConfigurationElement namedConfigurationElement)
		{
			return GetValue("outPutPath", namedConfigurationElement);
		}
		public string ErrorProcessingPath(NamedConfigurationElement namedConfigurationElement)
		{
			return GetValue("errorProcessingPath", namedConfigurationElement);
		}
		public string WorkingPath(NamedConfigurationElement commandConfiguration)
		{
			return GetValue("workingPath", commandConfiguration);
		}
		public string FolderToWatch(NamedConfigurationElement namedConfigurationElement)
		{
			return GetValue("folderToWatch", namedConfigurationElement);
		}
		public BindToElementEventArgs(AppSettingsSection appSettings, CommanderSection commanderSettings, NamedConfigurationElement element)
        {
			AppSettings = appSettings;
			CommanderSettings = commanderSettings;
            Element = element;
        }
Example #14
0
 public void Add(NamedConfigurationElement element)
 {
     BaseAdd(element);
 }