Ejemplo n.º 1
0
        public void SetService(IMixedRealityService service, Transform facadeParent)
        {
            this.service      = service;
            this.facadeParent = facadeParent;

            if (service == null)
            {
                serviceType = null;
                name        = "(Destroyed)";
                gameObject.SetActive(false);
                return;
            }
            else
            {
                this.serviceType = service.GetType();

                name = serviceType.Name;
                gameObject.SetActive(true);

                if (!FacadeServiceLookup.ContainsKey(serviceType))
                {
                    FacadeServiceLookup.Add(serviceType, this);
                }
                else
                {
                    FacadeServiceLookup[serviceType] = this;
                }

                if (!ActiveFacadeObjects.Contains(this))
                {
                    ActiveFacadeObjects.Add(this);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check if the interface type and name matches the registered interface type and service instance found.
        /// </summary>
        /// <param name="interfaceType">The interface type of the service to check.</param>
        /// <param name="serviceName">The name of the service to check.</param>
        /// <param name="registeredInterfaceType">The registered interface type.</param>
        /// <param name="serviceInstance">The instance of the registered service.</param>
        /// <returns>True, if the registered service contains the interface type and name.</returns>
        private static bool CheckServiceMatch(Type interfaceType, string serviceName, Type registeredInterfaceType, IMixedRealityService serviceInstance)
        {
            bool isValid = string.IsNullOrEmpty(serviceName) || serviceInstance.Name == serviceName;

            if ((registeredInterfaceType.Name == interfaceType.Name || serviceInstance.GetType().Name == interfaceType.Name) && isValid)
            {
                return(true);
            }

            var interfaces = serviceInstance.GetType().GetInterfaces();

            for (int i = 0; i < interfaces.Length; i++)
            {
                if (interfaces[i].Name == interfaceType.Name && isValid)
                {
                    return(true);
                }
            }

            return(false);
        }