Skip to content

Instantly share code, notes, and snippets.

@dkudelko
Created November 24, 2015 13:15
Show Gist options
  • Save dkudelko/9a4fe9d0424e3eb7f411 to your computer and use it in GitHub Desktop.
Save dkudelko/9a4fe9d0424e3eb7f411 to your computer and use it in GitHub Desktop.
XamarinForms.BaseUrl
using System;
using Xamarin.Forms;
using App.Android;
[assembly: Dependency (typeof (BaseUrl_Android))]
namespace App.Android
{
public class BaseUrl_Android : IBaseUrl
{
public string Get ()
{
return "file:///android_asset/";
}
}
}
using Xamarin.Forms;
using App.iOS;
using Foundation;
[assembly: Dependency (typeof (BaseUrl_iOS))]
namespace App.iOS
{
public class BaseUrl_iOS : IBaseUrl
{
public string Get ()
{
return NSBundle.MainBundle.BundlePath;
}
}
}
using Xamarin.Forms;
using App.WinPhone;
using Windows.Storage;
using System.IO.IsolatedStorage;
[assembly: Dependency(typeof(BaseUrl_WinPhone))]
namespace App.WinPhone
{
public class BaseUrl_WinPhone : IBaseUrl
{
public string Get()
{
//IsolatedStorageFile.GetUserStoreForApplication().
return "";
}
}
}
using Xamarin.Forms;
namespace App.WinPhone
{
public interface IBaseUrl { string Get(); }
}
// how to use
// var url = DependencyService.Get<IBaseUrl>().Get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment