Пример #1
0
 public MemBusAdapter(IocAdapter iocAdapter)
 {
     this.memBus =
         BusSetup.StartWith <AsyncConfiguration>()
         .Apply <IoCSupport>(s => s.SetAdapter(iocAdapter).SetHandlerInterface(typeof(IHandle <>)))
         .Construct();
 }
Пример #2
0
        /// <summary>
        /// </summary>
        public ZoneServer()
        {
            // TODO: Get the Server id from chatengine or config file
            this.Id = 0x356;
            this.ClientDisconnected += this.ZoneServerClientDisconnected;

            // New Bus initialization
            this.zoneBus = BusSetup.StartWith <AsyncConfiguration>().Construct();

            this.subscribedMessageHandlers.Clear();

            IEnumerable <Type> types =
                Assembly.GetExecutingAssembly()
                .GetTypes()
                .Where(
                    x =>
                    x.GetCustomAttributes(typeof(MessageHandlerAttribute), false)
                    .Any(
                        y => ((MessageHandlerAttribute)y).Direction != MessageHandlerDirection.OutboundOnly));

            MethodInfo subscriptMethodInfo = typeof(ZoneServer).GetMethod(
                "SubscribeMessage",
                BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (Type type in
                     types)
            {
                Type[]     temp    = type.BaseType.GetGenericArguments();
                MethodInfo generic = subscriptMethodInfo.MakeGenericMethod(new Type[] { temp[1], temp[0] });
                generic.Invoke(this, null);
            }
            this.CheckSubscribedMessageHandlers();
        }