コード例 #1
0
        internal GitTaskControl(GitTask task)
        {
            this.InitializeComponent();

            this.Task = task;

            this.Task.Error              += this.Task_Error;
            this.Task.Started            += this.Task_Started;
            this.Task.Stopped            += this.Task_Stopped;
            this.Task.LogMessageReceived += this.Task_LogMessageReceived;

            this.TextBox_DisplayName.Text  = this.Task.DisplayName ?? string.Empty;
            this.TextBox_InternalName.Text = this.Task.Name ?? string.Empty;

            this.UpdateButtonStates();
        }
コード例 #2
0
        // Private Methods (1) 

        private static void PushAction(GitTask task, CancellationToken cancelToken)
        {
        }
コード例 #3
0
        /// <summary>
        /// Loads tasks from a config repository.
        /// </summary>
        /// <param name="config">The config repository.</param>
        /// <returns>The loaded data.</returns>
        public static IEnumerable <GitTask> FromConfig(IConfigRepository config,
                                                       bool activeOnly = true)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            foreach (var taskName in config.GetCategoryNames())
            {
                GitTask newTask;
                try
                {
                    bool isActive;
                    config.TryGetValue <bool>(category: taskName,
                                              name: _CONFIG_NAME_IS_ACTIVE,
                                              value: out isActive,
                                              defaultVal: true);

                    if (activeOnly &&
                        isActive == false)
                    {
                        continue;
                    }

                    string group;
                    config.TryGetValue <string>(category: taskName,
                                                name: _CONFIG_NAME_GROUP,
                                                value: out group);

                    string method;
                    config.TryGetValue <string>(category: taskName,
                                                name: _CONFIG_NAME_METHOD,
                                                value: out method);

                    string displayName;
                    config.TryGetValue <string>(category: taskName,
                                                name: _CONFIG_NAME_TASKNAME,
                                                value: out displayName);

                    bool useCredentials;
                    config.TryGetValue <bool>(category: taskName,
                                              name: _CONFIG_NAME_USE_CREDENTIALS,
                                              value: out useCredentials);

                    string remotes;
                    config.TryGetValue <string>(category: taskName,
                                                name: _CONFIG_NAME_REMOTES,
                                                value: out remotes);

                    Credentials cred = null;
                    if (useCredentials)
                    {
                        string user;
                        config.TryGetValue <string>(category: taskName,
                                                    name: _CONFIG_NAME_USERNAME,
                                                    value: out user);

                        if (string.IsNullOrWhiteSpace(user) == false)
                        {
                            cred          = new Credentials();
                            cred.Username = user.Trim();

                            string pwd;
                            config.TryGetValue <string>(category: taskName,
                                                        name: _CONFIG_NAME_PASSWORD,
                                                        value: out pwd);

                            if (string.IsNullOrEmpty(pwd) == false)
                            {
                                cred.Password = pwd;
                            }
                        }
                    }

                    string email;
                    config.TryGetValue <string>(category: taskName,
                                                name: _CONFIG_NAME_EMAIL,
                                                value: out email);

                    newTask             = new GitTask();
                    newTask.Credentials = cred;
                    newTask.DisplayName = string.IsNullOrWhiteSpace(displayName) ? taskName : displayName.Trim();
                    newTask.IsActive    = isActive;
                    newTask.Logger.Add(new _GitTaskLogger(newTask));
                    newTask.Name    = taskName;
                    newTask.Remotes = new ReadOnlyCollection <string>((remotes ?? string.Empty).Split('\n')
                                                                      .Select(x => x.ToUpper().Trim())
                                                                      .Where(x => x != string.Empty)
                                                                      .Distinct()
                                                                      .ToArray());

                    if (string.IsNullOrWhiteSpace(email) == false)
                    {
                        newTask.eMail = new Uri("mailto:" + email.Trim());
                    }

                    if (string.IsNullOrWhiteSpace(group) == false)
                    {
                        newTask.Group = group.ToUpper().Trim();
                    }

                    switch ((method ?? string.Empty).ToUpper().Trim())
                    {
                    case _METHOD_PULL:
                        newTask.Method = GitTaskMethod.Pull;
                        break;

                    case "":
                    case _METHOD_PUSH:
                        newTask.Method = GitTaskMethod.Push;
                        break;

                    default:
                        throw new NotSupportedException();
                    }

                    newTask.Control = new GitTaskControl(newTask);
                }
                catch
                {
                    newTask = null;
                }

                if (newTask != null)
                {
                    yield return(newTask);
                }
            }
        }
コード例 #4
0
 internal _GitTaskLogger(GitTask task)
     : base(isThreadSafe: false)
 {
     this._TASK = task;
 }