mirror of
https://github.com/farcasclaudiu/myfriendsaround.git
synced 2026-06-29 03:01:46 +03:00
IoC and NavigationService implementation
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using MicroIoc;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace MicroIoc
|
||||
{
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
public static IConfiguration Property<T, TProp>(this IConfiguration configuration, Expression<Func<T, TProp>> propertyExpression, TProp value)
|
||||
{
|
||||
var memberExpression = propertyExpression.Body as MemberExpression;
|
||||
if (memberExpression == null)
|
||||
throw new ArgumentException("propertyExpression is not a valid member expression");
|
||||
|
||||
var propertyInfo = memberExpression.Member as PropertyInfo;
|
||||
if (propertyInfo == null)
|
||||
throw new ArgumentException("propertyExpression is not a valid property on the class");
|
||||
|
||||
return configuration.Configure<T>(new InjectedProperty<TProp>(propertyInfo.Name, value));
|
||||
}
|
||||
|
||||
public static IConfiguration ConstructorParam<T, TParam>(this IConfiguration configuration, string name, TParam value)
|
||||
{
|
||||
return configuration.Configure<T>(new InjectedConstructorParam<TParam>(name, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace MicroIoc
|
||||
{
|
||||
public static class PatternExtensions
|
||||
{
|
||||
public static string PropertyPattern(this Type type, string memberName)
|
||||
{
|
||||
return type.FullName + "." + memberName;
|
||||
}
|
||||
|
||||
public static string ConstructorParamPattern(this Type type, string memberName)
|
||||
{
|
||||
return type.FullName + "#" + memberName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user