Esempio n. 1
0
 private Hub()
 {
     foreach (var instanceConfig in Config.GitDeployHub.Settings.Instances.OfType<InstanceElement>())
     {
         var instance = new Instance(this, instanceConfig.Name, instanceConfig.Treeish, instanceConfig.Folder);
         if (!string.IsNullOrWhiteSpace(instanceConfig.EnvironmentVariables))
         {
             foreach (var pair in instanceConfig.EnvironmentVariables
                 .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
             {
                 var equalsIndex = pair.IndexOf('=');
                 if (equalsIndex >= 0)
                 {
                     var name = pair.Substring(0, equalsIndex).Trim();
                     var value = pair.Substring(equalsIndex + 1).Trim();
                     instance.EnvironmentVariables[name] = value;
                 }
             }
         }
         if (instanceConfig.Notifiers != null)
         {
             instance.Notifiers = instanceConfig.Notifiers.OfType<NotifierElement>().Select(notifierConfig =>
                 {
                     var typeName = notifierConfig.Type.Substring(0, 1).ToUpperInvariant() + notifierConfig.Type.Substring(1).ToLowerInvariant();
                     typeName = string.Format("GitDeployHub.Web.Engine.Notifiers.{0}Notifier", typeName);
                     var notifier = (Notifier)Activator.CreateInstance(Type.GetType(typeName, true));
                     notifier.Key = notifierConfig.Key;
                     notifier.Settings = notifierConfig.Settings == null ? new Dictionary<string, string>() : notifierConfig.Settings.ToDictionary();
                     return notifier;
                 }).ToArray();
         }
         Register(instance);
     }
 }
Esempio n. 2
0
 internal static void Log(string message, Instance instance, BaseProcess process)
 {
     TraceSource.TraceInformation(message);
 }
Esempio n. 3
0
 public void Register(Instance instance)
 {
     if (_instances.ContainsKey(instance.Name))
     {
         throw new Exception("An instance with the same name already exists: " + instance.Name);
     }
     _instances[instance.Name] = instance;
 }