Ejemplo n.º 1
0
 public static BaseMessageHandler CreateHandler(int messageType)
 {
     if (_msgHelperContainer == null)
     {
         lock (_lockObj)
         {
             ContainerBuilder cb = new ContainerBuilder();
             cb.Register(c => ModuleInjector.Inject <NormalMessageHandler>()).Named <BaseMessageHandler>(MessageType.Normal.ToString());
             cb.Register(c => ModuleInjector.Inject <AcceptMessageHandler>()).Named <BaseMessageHandler>(MessageType.Accept.ToString());
             cb.Register(c => ModuleInjector.Inject <RejectMessageHandler>()).Named <BaseMessageHandler>(MessageType.Reject.ToString());
             cb.Register(c => ModuleInjector.Inject <EndMessageHandler>()).Named <BaseMessageHandler>(MessageType.ConversationEnded.ToString());
             cb.Register(c => ModuleInjector.Inject <ContinueMessageHandler>()).Named <BaseMessageHandler>(MessageType.ConversationContinue.ToString());
             //cb.Register(c => ModuleInjector.Inject<HeartBeatMessageHandler>()).Named<BaseMessageHandler>(MessageType.HeartBeat.ToString());
             //cb.Register(c => ModuleInjector.Inject<MySqlHelper>()).Named<MessageHandler>("MySql");
             //cb.Register(c => ModuleInjector.Inject<MySqlHelper>()).Named<MessageHandler>("MySql");
             //cb.Register(c => ModuleInjector.Inject<MySqlHelper>()).Named<MessageHandler>("MySql");
             IContainer tmpContainer = cb.Build();
             if (_msgHelperContainer == null)
             {
                 _msgHelperContainer = tmpContainer;
             }
             else
             {
                 tmpContainer.Dispose();
             }
         }
     }
     return(_msgHelperContainer.ResolveNamed <BaseMessageHandler>(messageType.ToString()));
 }
Ejemplo n.º 2
0
        private static void LoggingTest()
        {
            LogUtils.LogLevel = LogLevelEnum.Debug;

            Console.WriteLine(new AOPTest().add(100, 200));
            Console.WriteLine(ModuleInjector.Inject <AOPTest>().add(100, 200));

            AOPTest data1 = new AOPTest()
            {
                DataInt = 300, DataString = "111"
            };
            AOPTest data2 = new AOPTest()
            {
                DataInt = 500, DataString = "222"
            };

            Console.WriteLine(XmlUtils.SerializeData(new AOPTest().add(data1, data2)));
            Console.WriteLine(XmlUtils.SerializeData(ModuleInjector.Inject <AOPTest>().add(data1, data2)));
            Console.WriteLine(XmlUtils.SerializeData(ModuleInjector.Inject <AOPTest>().add(data1, null)));
        }
Ejemplo n.º 3
0
 public static DataHelper CreateHelper()
 {
     if (_dataHelperContainer == null)
     {
         lock (_lockObj)
         {
             ContainerBuilder cb = new ContainerBuilder();
             cb.Register(c => ModuleInjector.Inject <MySqlHelper>()).Named <DataHelper>("MySql");
             IContainer tmpContainer = cb.Build();
             if (_dataHelperContainer == null)
             {
                 _dataHelperContainer = tmpContainer;
             }
             else
             {
                 tmpContainer.Dispose();
             }
         }
     }
     return(_dataHelperContainer.ResolveNamed <DataHelper>(DatabaseConfig.Instance.Type.ToString()));
 }