Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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();
            }