mirror of
https://github.com/farcasclaudiu/myfriendsaround.git
synced 2026-06-29 11:02:07 +03:00
IoC and NavigationService implementation
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace MicroIoc
|
||||
{
|
||||
public class ContainerConfiguration : IConfiguration
|
||||
{
|
||||
private readonly IMicroIocContainer _container;
|
||||
|
||||
public ContainerConfiguration(IMicroIocContainer container)
|
||||
{
|
||||
if (container == null)
|
||||
throw new ArgumentNullException("container");
|
||||
|
||||
_container = container;
|
||||
}
|
||||
|
||||
public IConfiguration Configure<T>(InjectedMemberBase injection)
|
||||
{
|
||||
var fullName = injection.DeriveFullName<T>();
|
||||
_container.RegisterInstance(injection.MemberValue.GetType(), injection.MemberValue, fullName);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace MicroIoc
|
||||
{
|
||||
public interface IConfiguration
|
||||
{
|
||||
IConfiguration Configure<T>(InjectedMemberBase injection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace MicroIoc
|
||||
{
|
||||
public class InjectedConstructorParam<T> : InjectedMemberBase
|
||||
{
|
||||
public InjectedConstructorParam(string name, T value)
|
||||
{
|
||||
MemberName = name;
|
||||
MemberValue = value;
|
||||
}
|
||||
|
||||
public override string DeriveFullName<TClass>()
|
||||
{
|
||||
return typeof (TClass).ConstructorParamPattern(MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace MicroIoc
|
||||
{
|
||||
public abstract class InjectedMemberBase
|
||||
{
|
||||
public string MemberName { get; set; }
|
||||
public object MemberValue { get; set; }
|
||||
|
||||
public abstract string DeriveFullName<T>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace MicroIoc
|
||||
{
|
||||
public class InjectedProperty<T> : InjectedMemberBase
|
||||
{
|
||||
public InjectedProperty(string name, T value)
|
||||
{
|
||||
MemberName = name;
|
||||
MemberValue = value;
|
||||
}
|
||||
|
||||
public override string DeriveFullName<TClass>()
|
||||
{
|
||||
return typeof(TClass).PropertyPattern(MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user