public void Initialize <TSubject>(TSubject subject)
 {
     PublishEvent(
         ScreenEvents.Initialize <TSubject>(),
         new InitializeEventArgs <TSubject>(_target, subject)
         );
 }
Exemple #2
0
 private void RegisterGenericInitializeHandler <TSubject>(MethodInfo initializeMethod)
 {
     RegisterHandler(
         ScreenEvents.Initialize <TSubject>(),
         args => initializeMethod.Invoke(_parent, new Object[] { args.Subject })
         );
 }
Exemple #3
0
        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)
                    );
            }
        }
 public void Initialize()
 {
     PublishEvent(ScreenEvents.Initialize(), new InitializeEventArgs(_target));
 }