예제 #1
0
        /// <summary>
        ///     Extracts the add options.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <returns>AddNoteOptions.</returns>
        /// <exception cref="ArgumentException">Found more than 1 tag body</exception>
        internal AddTagOptions ExtractAddOptions(IEnumerable <string> args)
        {
            var options = new AddTagOptions();
            var arr     = args.ToArray();

            for (var i = 0; i < arr.Length; i++)
            {
                var ptr = arr[i];

                switch (ptr)
                {
                case "-a":
                case "--all":
                    options.IsAllThreadsAtPosition = true;
                    break;

                default:
                    if (options.Text == null)
                    {
                        options.Text = ptr;
                    }
                    else
                    {
                        throw new ArgumentException("Found more than 1 tag body");
                    }
                    break;
                }
            }

            return(options);
        }
예제 #2
0
        /// <summary>
        ///     Adds the tag.
        /// </summary>
        /// <param name="addOptions">The add options.</param>
        internal void AddTag(AddTagOptions addOptions)
        {
            var positions = TimeTravelFacade.Positions();
            var current   = positions.CurrentThreadResult;

            if (addOptions.IsAllThreadsAtPosition) // todo: extract methods
            {
                var threadIds = positions.Select(x => x.ThreadId);
                ServerClient.AddTag(current.Position, threadIds, addOptions.Text);
            }
            else
            {
                ServerClient.AddTag(current.Position, new[] { current.ThreadId }, addOptions.Text);
            }
        }
예제 #3
0
        /// <summary>
        ///     Adds a tag.
        /// </summary>
        /// <param name="addOptions">The add options.</param>
        internal void AddTag(AddTagOptions addOptions)
        {
            var positions = TimeTravelFacade.Positions();
            var current   = positions.CurrentThreadResult;
            var tag       = new Tag()
            {
                Title         = addOptions.Title,
                Body          = addOptions.Body,
                CreateDateUtc = DateTime.UtcNow
            };

            if (addOptions.IsAllThreadsAtPosition) // todo: extract methods
            {
                var threadIds = positions.Select(x => x.ThreadId);

                ServerClient.AddTag(current.Position, threadIds, tag);
            }
            else
            {
                ServerClient.AddTag(current.Position, new[] { current.ThreadId }, tag);
            }
        }
예제 #4
0
        /// <summary>
        ///     Extracts the add options.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <returns>AddNoteOptions.</returns>
        /// <exception cref="ArgumentException">Found more than 1 tag body</exception>
        internal AddTagOptions ExtractAddOptions(IEnumerable <string> args)
        {
            var options = new AddTagOptions();
            var arr     = args.ToArray();

            for (var i = 0; i < arr.Length; i++) // todo: support short cut for tagging
            {
                var ptr = arr[i];

                switch (ptr)
                {
                case "-a":
                case "--all":
                    options.IsAllThreadsAtPosition = true;
                    break;

                case "-t":
                case "--title":
                    if (i + 1 >= arr.Length)
                    {
                        throw new ArgumentException(nameof(args), $"Found switch {ptr}, which requires a value, but none was found");
                    }
                    options.Title = arr[i + 1];
                    break;

                case "-b":
                case "--body":
                    if (i + 1 >= arr.Length)
                    {
                        throw new ArgumentException(nameof(args), $"Found switch {ptr}, which requires a value, but none was found");
                    }
                    options.Body = arr[i + 1];
                    break;
                }
            }

            return(options);
        }