|
Revision 10785, 1.4 kB
(checked in by mattn, 5 years ago)
|
|
Wassr追加
|
| Line | |
|---|
| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Text;
|
|---|
| 4 | using MMMMB.MiniBlogs;
|
|---|
| 5 | using System.Drawing;
|
|---|
| 6 |
|
|---|
| 7 | namespace MMMMB
|
|---|
| 8 | {
|
|---|
| 9 | public interface IMiniBlog
|
|---|
| 10 | {
|
|---|
| 11 | string Username { get; set; }
|
|---|
| 12 | string Password { get; set; }
|
|---|
| 13 | string ServiceName { get; }
|
|---|
| 14 | string Prompt { get; }
|
|---|
| 15 | Uri Image { get; }
|
|---|
| 16 |
|
|---|
| 17 | List<Entry> GetLatestEntryList();
|
|---|
| 18 | void Post(string message);
|
|---|
| 19 | string GetReply(Entry entry);
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | public class MiniBlogFactory
|
|---|
| 23 | {
|
|---|
| 24 | public static IMiniBlog CreateInstance(string text)
|
|---|
| 25 | {
|
|---|
| 26 | string[] fields = text.Split(':');
|
|---|
| 27 | if (fields.Length != 3) throw new InvalidOperationException();
|
|---|
| 28 |
|
|---|
| 29 | IMiniBlog miniblog;
|
|---|
| 30 | switch (fields[0].ToLower())
|
|---|
| 31 | {
|
|---|
| 32 | case "twitter":
|
|---|
| 33 | miniblog = new Twitter();
|
|---|
| 34 | break;
|
|---|
| 35 | case "jaiku":
|
|---|
| 36 | miniblog = new Jaiku();
|
|---|
| 37 | break;
|
|---|
| 38 | case "friendfeed":
|
|---|
| 39 | miniblog = new FriendFeed();
|
|---|
| 40 | break;
|
|---|
| 41 | case "wassr":
|
|---|
| 42 | miniblog = new Wassr();
|
|---|
| 43 | break;
|
|---|
| 44 | default:
|
|---|
| 45 | throw new InvalidOperationException();
|
|---|
| 46 | }
|
|---|
| 47 | miniblog.Username = fields[1];
|
|---|
| 48 | miniblog.Password = fields[2];
|
|---|
| 49 | return miniblog;
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|