Exemple #1
0
        static ServiceType GetServiceType(SimpleAuth.Api api)
        {
            if (api is GoogleMusicApi)
            {
                return(ServiceType.Google);
            }
            if (api is CloudDriveApi)
            {
                return(ServiceType.Amazon);
            }
            if (api is YoutubeOauthApi)
            {
                return(ServiceType.YouTube);
            }
            if (api is SoundCloudApi)
            {
                return(ServiceType.SoundCloud);
            }
            if (api is OneDriveApi)
            {
                return(ServiceType.OneDrive);
            }

            App.ShowNotImplmented(new Dictionary <string, string> {
                { "Api type", api.GetType().ToString() }
            });
            return(ServiceType.FileSystem);
        }
Exemple #2
0
        public void SaveApi(SimpleAuth.Api api)
        {
            var id     = int.Parse(api.Identifier);
            var record = new ApiModel
            {
                Id        = id,
                Service   = GetServiceType(api),
                DeviceId  = api.DeviceId,
                ExtraData = api.ExtraDataString,
            };

            Settings.AddApiModel(record);
        }
Exemple #3
0
        public MusicProvider AddApi(SimpleAuth.Api api)
        {
            var provider = CreateProvider(api);

            if (provider == null)
            {
                return(null);
            }
            SaveApi(api);

            Collection.Add(api.Identifier, provider);

            return(provider);
        }
Exemple #4
0
        public MusicProvider CreateProvider(SimpleAuth.Api api)
        {
            try
            {
                var providerType = ApiProviderTypes[api.GetType()];
                var provider     = Activator.CreateInstance(providerType, api) as MusicProvider;
                return(provider);
            }
            catch (Exception ex)
            {
                LogManager.Shared.Report(ex);
            }

            App.ShowNotImplmented(new Dictionary <string, string> {
                { "Service Type", api.GetType().ToString() }
            });
            return(null);
        }