示例#1
0
        private void AddServiceImpl(
            ITisServicesHost servicesHost,
            string applicationName,
            object oServiceInstance,
            ITisServiceInfo oServiceInfo,
            string sEventSourceBindingKey)
        {
            if (!StringUtil.CompareIgnoreCase(sEventSourceBindingKey, TisServicesConst.UNNAMED_INSTANCE))
            {
                List <TisEventParams> SupportedEvents = GetSupportedEvents(oServiceInfo);

                if (SupportedEvents.Count != 0)
                {
                    ITisEventsManager oEventsMngr = (ITisEventsManager)servicesHost.GetService(applicationName, "EventsManager");

                    CreateServiceEventInterceptorTypeIfNeeded(
                        applicationName,
                        oServiceInfo,
                        SupportedEvents);

                    CreateServiceEventHandlers(
                        oServiceInstance,
                        oServiceInfo,
                        sEventSourceBindingKey,
                        SupportedEvents,
                        oEventsMngr);
                }
            }
        }
示例#2
0
        private void CreateServiceEventHandlers(
            object oServiceInstance,
            ITisServiceInfo oServiceInfo,
            string oEventBindingKey,
            List <TisEventParams> SupportedEvents,
            ITisEventsManager oEventsMngr)
        {
            Type oEventInterceptorDynamicType =                             //Todo : IgnoreCase does not work properly
                                                m_oAssemblyBuilder.GetType(oServiceInfo.ServiceName, false, false);

            object   oEventInterceptorDynamicInstance;
            Delegate oEventInterceptorDynamicDelegate;

            foreach (ITisEventParams oEventParams in SupportedEvents)
            {
                oEventInterceptorDynamicInstance = Activator.CreateInstance(
                    oEventInterceptorDynamicType,
                    new object[] { m_oEventInterceptor.EventInterceptorDelegate,
                                   oEventsMngr,
                                   oServiceInfo,
                                   oEventBindingKey,
                                   oEventParams.Name, });

                oEventInterceptorDynamicDelegate = Delegate.CreateDelegate(
                    oEventParams.EventHandlerType,
                    oEventInterceptorDynamicInstance,
                    oEventParams.Name);

                oEventParams.AddEventHandler(oServiceInstance, oEventInterceptorDynamicDelegate);
            }
        }
示例#3
0
        // Service events interceptor

        public object OnEventInterceptionHandler(
            ITisEventsManager oEventsManager,
            object oEventSource,
            object oEventBindingKey,
            string sEventName,
            ref object[] InOutParams)
        {
            return(((TisEventsManager)oEventsManager).FireEvent(
                       oEventSource,
                       oEventBindingKey,
                       sEventName,
                       ref InOutParams));
        }