In Xamarin Forms, I have a solution like this:
Solution |- Libraries | |- IInterface.cs | |- Etc. | |- Libraries.iOS | |- Interface.cs | |- Etc. | |- Forms.App | |- App.cs | |- Etc. | |- Forms.App.iOS | |- Etc.
- Links to .App.iOS Libraries.iOS Forms
- Forms.App Library Links
- Libraries.iOS library links
- Links Forms.App.iOS Forms.App
IInterface.cs
namespace a { public interface IInterface { void Function (); } }
Interface.cs
[assembly: Xamarin.Forms.Dependency(typeof(a.Interface))] namespace a { public class Interface : IInterface { public void Function () { return; } } }
App.cs
namespace a { public class App { public static Page GetMainPage () { var inter = DependencyService.Get<IInterface> ();
How can I get the dependency service to find an interface implementation? I need to have them in a separate project, because I need the same implementations in different projects.
c # dependency-injection xamarin xamarin.forms
Bisaz
source share