Beispiel #1
0
        public static string[] GetServicesOfImplType(
            ITisServiceRegistry oServiceRegistry,
            Type oImplType)
        {
            string[] retArray;

            lock (m_locker)
            {
                if (m_TypeToImpTypes.TryGetValue(oImplType, out retArray) == true)
                {
                    return(retArray);
                }

                List <string> oRetServices = new List <string>();

                foreach (ITisServiceInfo oServiceInfo in oServiceRegistry.InstalledServices)
                {
                    string sImplType = oServiceInfo.ServiceImplType;

                    if (string.IsNullOrEmpty(sImplType))
                    {
                        continue;
                    }

                    Type oServiceType;
                    if (m_StringToType.TryGetValue(sImplType, out oServiceType) == false)
                    {
                        try
                        {
                            oServiceType = Type.GetType(sImplType, false);
                        }
                        catch (Exception exc)
                        {
                            oServiceType = null;

                            Log.WriteWarning("Failed to load type {0}. Details : {1}", sImplType, exc.Message);
                        }

                        if (oServiceType != null)
                        {
                            m_StringToType.Add(sImplType, oServiceType);
                        }
                    }

                    if (oServiceType != null)
                    {
                        if (oImplType.IsAssignableFrom(oServiceType))
                        {
                            oRetServices.Add(oServiceInfo.ServiceName);
                        }
                    }
                }

                retArray = oRetServices.ToArray();

                m_TypeToImpTypes.Add(oImplType, retArray);
            }

            return(retArray);
        }
Beispiel #2
0
 public TisValidationManager(
     ITisServiceRegistry applicationServiceRegistry,
     TisValidatorManager validatorMngr,
     TisValidationContextManager customValidationContextMngr)
 {
     m_applicationServiceRegistry = applicationServiceRegistry;
     m_validatorMngr         = validatorMngr;
     m_validationContextMngr = customValidationContextMngr;
 }
        public TisValidatorManager(
            string sApplicationName,
            ITisServicesHost oServicesHost)
            : base(oServicesHost, sApplicationName)
        {
            m_serviceRegistry =
                oServicesHost.GetServiceRegistry(sApplicationName);

            Refresh();
        }
Beispiel #4
0
        public static List <ITisServiceInfo> GetServicesInfoOfImplType(
            ITisServiceRegistry oServiceRegistry,
            Type oImplType)
        {
            List <ITisServiceInfo> servicesInfo = new List <ITisServiceInfo>();

            List <string> services = new List <string>(GetServicesOfImplType(oServiceRegistry, oImplType));

            services.ForEach(service => servicesInfo.Add(oServiceRegistry.GetInstalledServiceInfo(service)));

            return(servicesInfo);
        }
        public override void Dispose()
        {
            if (m_allApplicationValidators != null)
            {
                m_allApplicationValidators.Clear();
                m_allApplicationValidators = null;
            }

            m_serviceRegistry = null;

            base.Dispose();
        }
Beispiel #6
0
        public TisValidationContextManager(
            string sApplicationName,
            ITisServicesHost oServicesHost)
        {
            m_applicationName = sApplicationName;

            m_servicesHost = oServicesHost;

            m_serviceRegistry =
                m_servicesHost.GetServiceRegistry(sApplicationName);

            Refresh();
        }
        public ITisServiceInfo GetServiceInfo(
            string sAppName,
            string sServiceName)
        {
            // Get service registry
            ITisServiceRegistry oServiceRegistry =
                GetServiceRegistry(sAppName);

            // Obtain service info
            ITisServiceInfo oServiceInfo =
                oServiceRegistry.GetInstalledServiceInfo(sServiceName);

            return(oServiceInfo);
        }
        private void CopyServices(
            ITisServiceRegistry oSrc,
            ITisServiceRegistry oDst)
        {
            oDst.ServicesSchema = oSrc.ServicesSchema;

            foreach (ITisServiceInfo oServiceInfo in oSrc.InstalledServices)
            {
                if (!oServiceInfo.FromSchema)
                {
                    oDst.InstallService(
                        oServiceInfo.ServiceName,
                        oServiceInfo.ServiceCreatorType,
                        oServiceInfo.ServiceImplType,
                        oServiceInfo.RequiredRoles,
                        oServiceInfo.UsingMode == ServicesUsingMode.Free);
                }
            }
        }
        public bool AddLocalService(
            string applicationName,
            string serviceName,
            object serviceInstance        = null,
            string serviceCreatorFullName = null,
            string serviceTypeFullName    = null,
            string serviceInstanceName    = null)
        {
            if (!StringUtil.IsStringInitialized(serviceName))
            {
                Log.WriteWarning("Try to install service without name.");
                return(false);
            }

            ITisServiceRegistry applicationServiceRegistry = GetServiceRegistry(applicationName);

            bool isServiceInstalled = applicationServiceRegistry.IsServiceInstalled(serviceName);

            if (!isServiceInstalled)
            {
                if (!StringUtil.IsStringInitialized(serviceCreatorFullName))
                {
                    serviceCreatorFullName =
                        typeof(TisUniversalServiceCreator).FullName + "," +
                        typeof(TisUniversalServiceCreator).Assembly.GetName().Name;
                }

                if (!StringUtil.IsStringInitialized(serviceTypeFullName))
                {
                    serviceTypeFullName = String.Empty;
                }

                try
                {
                    applicationServiceRegistry.InstallService(
                        serviceName,
                        serviceCreatorFullName,
                        serviceTypeFullName,
                        TisServicesConst.NO_ROLES_REQUIRED,
                        false);
                }
                catch (Exception exc)
                {
                    Log.WriteWarning("Failed to install service [{0}]. Details : {1}", serviceName, exc.Message);
                }

                isServiceInstalled = applicationServiceRegistry.IsServiceInstalled(serviceName);
            }

            if (serviceInstance != null)
            {
                if (!StringUtil.IsStringInitialized(serviceInstanceName))
                {
                    serviceInstanceName = TisServicesConst.UNNAMED_INSTANCE;
                }

                TisServiceKey serviceKey = new TisServiceKey(
                    serviceName,
                    serviceInstanceName);

                ITisServiceProvider serviceProvider;

                serviceProvider = m_oServiceProvidersCache.GetServiceProvider(applicationName);

                serviceProvider.AddService(serviceKey, serviceInstance);

                ITisServiceInfo serviceInfo =
                    CheckedGetServiceInfo(applicationName, serviceName);

                // The events adapter will include only the services which implement ITisSupportEvents interface.
                TisServiceEventsAdapterBuilder.AddService(
                    this,
                    applicationName,
                    serviceInstance,
                    serviceInfo,
                    serviceInstanceName);
            }

            return(isServiceInstalled);
        }