Exemplo n.º 1
0
 public static IProvider GetProvider(Type type, ProviderMode mode)
 {
     Logger.Assert (type != null);
     Type provider = null;
     Hashtable subproviders = (Hashtable) providers[mode];
     if (subproviders != null) {
         provider = (Type) subproviders[type];
     }
     return NewInstance (provider);
 }
Exemplo n.º 2
0
 private static string ConvertImageUris(string html, int index, ProviderMode mode)
 {
     if (mode == ProviderMode.LocalMode || mode == ProviderMode.EditMode)
     {
         return(html.Replace("#$", TestingHttpServer.GetUrl("images")).Replace("#%", "."));
     }
     else
     {
         return(html.Replace("#$", "/ImageHandler.aspx?id=").Replace("#%", "."));
     }
 }
        public SqliteSyncProvider(SqliteSyncConfiguration configuration, ProviderMode providerMode = ProviderMode.Bidirectional, ISyncLogger logger = null)
        {
            Configuration = configuration;
            ProviderMode  = providerMode;
            _logger       = logger;

            if (configuration.Tables.Any(_ => _.SyncDirection != SyncDirection.UploadAndDownload) &&
                providerMode == ProviderMode.Bidirectional)
            {
                throw new InvalidOperationException("One or more table with sync direction different from Bidirectional: please must specify the provider mode to Local or Remote");
            }
        }
Exemplo n.º 4
0
        public static WallpaperProvider GetProvider(ProviderMode mode)
        {
            switch (mode)
            {
            case ProviderMode.Bing:
                return(new BingWallpaperProvider());

            case ProviderMode.DailyLockscreen:
                return(new DailyWallpaperProvider());

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }
        }
Exemplo n.º 5
0
        public static string GetQuestionHtml(HtmlStore store, ProviderMode mode)
        {
            if (store == null)
            {
                return(null);
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(ConvertImageUris(store.Html, store.QuestIndex, mode));
            sb.Append("<table width=\"100%\" style=\"border:0px;border-collapse:collapse;margin:8px 0px 8px 0px;\" cellspacing=\"0\"><tr><td style=\"height:1px;background-color:#7d9acb;padding:0px;margin:0px;\"></td></tr></table>");
            BaseQuestionProvider questProvider = GetQuestionProvider(store);

            if (questProvider == null)
            {
                questProvider = new NoAnswerQuestionProvider(store);
            }
            sb.Append(ConvertImageUris(questProvider.ProcessHtml(), store.QuestIndex, mode));
            return(sb.ToString());
        }
Exemplo n.º 6
0
        public string SaveImage(Image image, ProviderMode providerMode)
        {
            string folder = wallpapersFolderAvailable ? wallpapersFolder : Directory.GetCurrentDirectory();

            Path = System.IO.Path.Combine(Directory.GetCurrentDirectory(), folder, $"{DateUtils.Today()}_{providerMode}.jpg");

            var encoderParameters = new EncoderParameters(1)
            {
                Param = { [0] = encoderParameter }
            };

            if (File.Exists(Path))
            {
                File.Delete(Path);
            }

            image.Save(Path, codecInfo, encoderParameters);

            return(Path);
        }
Exemplo n.º 7
0
 public static ICollection GetRegisteredTypes(ProviderMode mode)
 {
     Hashtable subproviders = (Hashtable) providers[mode];
     if (subproviders == null)
         return null;
     // subproviders keys are Type
     return subproviders.Keys;
 }