Example #1
0
                public EventChannel(EventRouter router)
                {
                    var current   = this;
                    var argsType  = typeof(TEventData);
                    var basetypes = new List <Type>()
                    {
                        //argsType
                    };


                    for (; ;)
                    {
                        argsType = argsType.GetTypeInfo().BaseType;
                        if (argsType != null && argsType?.Name != "RuntimeClass")
                        {
                            basetypes.Add(argsType);
                        }
                        else
                        {
                            break;
                        }


                        if (router != null)
                        {
                            BaseClassTypeChannels = basetypes

                                                    .Select(x => router.GetEventChannel(x))
                                                    .Where(x => x != null)
                                                    .ToList();


                            ImplementedInterfaceTypeInstances = typeof(TEventData)
                                                                .GetTypeInfo()
                                                                .ImplementedInterfaces
                                                                .Where(x => x.Name[0] == 'I')
                                                                .Select(x =>
                                                                        router.GetEventChannel(x))
                                                                .Where(x => x != null)
                                                                .ToList();
                        }
                    }
                }
Example #2
0
                public EventChannel(EventRouter router)
                {
                    var current   = this;
                    var argsType  = typeof(TEventData);
                    var basetypes = new List <Type>()
                    {
                        //argsType
                    };

#if NETFX_CORE
                    for (; ;)
                    {
                        argsType = argsType.GetTypeInfo().BaseType;
                        if (argsType != typeof(object) && argsType != null)
                        {
                            if (argsType.Name != "RuntimeClass")
                            {
                                basetypes.Add(argsType);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
#else
                    for (; ;)
                    {
                        argsType = argsType.BaseType;
                        if (argsType != typeof(object) && argsType != null)
                        {
                            basetypes.Add(argsType);
                        }
                        else
                        {
                            break;
                        }
                    }
#endif
                    if (typeof(TEventData) != typeof(Object))
                    {
                        basetypes.Add(typeof(object));
                    }
                    if (router != null)
                    {
                        BaseClassTypeChannels = basetypes

                                                .Select(x => router.GetEventChannel(x))
                                                .Where(x => x != null)
                                                .ToList();


#if NETFX_CORE
                        ImplementedInterfaceTypeInstances = typeof(TEventData)
                                                            .GetTypeOrTypeInfo()
                                                            .ImplementedInterfaces
                                                            .Where(x => x.Name[0] == 'I')
                                                            .Select(x =>
                                                                    router.GetEventChannel(x))
                                                            .Where(x => x != null)
                                                            .ToList();
#else
                        ImplementedInterfaceTypeInstances = typeof(TEventData)
                                                            .GetInterfaces()
                                                            .Select(x =>
                                                                    router.GetEventChannel(x))
                                                            .Where(x => x != null)
                                                            .ToList();
#endif
                    }
                }