public static HttpStatusCode EditEntry(
            HatenaBlogAtomPubClient hatenaBlog,
            PostedEntry entry,
            PostMode postMode,
            IHatenaBlogEntryEditor editor,
            IDiffGenerator diff,
            Func <bool> confirmBeforePosting,
            out bool isModified
            )
        {
            Console.Write("{0} \"{1}\" ", entry.EntryUri, entry.Title);

            isModified = false;

            if (editor.Edit(entry, out var originalText, out var modifiedText))
            {
                isModified = true;

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("(変更あり)");
                Console.ResetColor();

                diff.DisplayDifference(originalText, modifiedText);

                Console.WriteLine();
            }
        public static void EditAllEntry(
            HatenaBlogAtomPubClient hatenaBlog,
            PostMode postMode,
            IHatenaBlogEntryEditor editor,
            IDiffGenerator diff,
            Uri entryUrlSkipTo,
            Func <bool> confirmBeforePosting,
            out IReadOnlyList <PostedEntry> updatedEntries,
            out IReadOnlyList <PostedEntry> modifiedEntries
            )
        {
            var entriesUpdated  = new List <PostedEntry>();
            var entriesModified = new List <PostedEntry>();

            foreach (var entry in hatenaBlog.EnumerateEntries())
            {
                if (entryUrlSkipTo != null)
                {
                    if (entry.EntryUri.Equals(entryUrlSkipTo))
                    {
                        entryUrlSkipTo = null;
                    }
                    else
                    {
                        Console.Write("{0} \"{1}\" ", entry.EntryUri, entry.Title);

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("(スキップしました)");
                        Console.ResetColor();

                        continue;
                    }
                }

                var statusCode = EditEntry(
                    hatenaBlog,
                    entry,
                    postMode,
                    editor,
                    diff,
                    confirmBeforePosting,
                    out var isModified
                    );

                if (statusCode == HttpStatusCode.OK)
                {
                    entriesUpdated.Add(entry);

                    if (isModified)
                    {
                        entriesModified.Add(entry);
                    }
                }

                hatenaBlog.WaitForCinnamon();
            }

            updatedEntries  = entriesUpdated;
            modifiedEntries = entriesModified;
        }
Exemple #3
0
        /// <summary>
        /// Determines the post method.
        /// </summary>
        private void DeterminePostMethod()
        {
            string postMethod = HttpContext.Current.Request.QueryString[ForumConstants.Query_PostMethod];

            if (null != postMethod)
            {
                MessageMode = (PostMode)PostMode.Parse(typeof(PostMode), postMethod);
            }
            else
            {
                MessageMode = PostMode.New;
            }
        }