private void RegisterHandlerForINeedsInitializationImplementations() { Type screenType = _parent.GetType(); var genericImplementations = screenType .GetInterfaces() .Where(i => TypeService.ClosesGenericType(i, typeof(INeedsInitialization <>))) .Select(i => new { SubjectType = i.GetGenericArguments().Single(), HandlerMethod = screenType .GetInterfaceMap(i) .TargetMethods .Single() } ); foreach (var impl in genericImplementations) { InvokeRegisterGenericInitializeHandler( impl.SubjectType, impl.HandlerMethod ); } IEnumerable <MethodInfo> nonGenericImplementations = screenType .Traverse(x => x.BaseType) .SelectMany(t => t .GetInterfaces() .Where(i => i == typeof(INeedsInitialization)) .Select(i => t .GetInterfaceMap(i) .TargetMethods .Single() ) ) .Distinct(); foreach (MethodInfo impl in nonGenericImplementations) { MethodInfo implReference = impl; RegisterHandler( ScreenEvents.Initialize(), args => implReference.Invoke(_parent, null) ); } }
private static bool IsIViewInterface(Type itf) { return(TypeService.ClosesGenericType(itf, typeof(IView <>))); }
public bool Matches(EventPublication publication) { Type eventType = publication.Event.GetType(); return(TypeService.ClosesGenericType(eventType, typeof(ScreenLifecycleEvent <>))); }
private static bool IsVMCollectionInterface(Type type) { return(TypeService.ClosesGenericType(type, typeof(IVMCollection <>))); }