/// <summary>
        /// Activates an instance of the specified concrete type using the provided argument collection.
        /// </summary>
        /// <typeparam name="T">The interface which must be implemented by the concrete type.</typeparam>
        /// <param name="concreteType">The type of object to be instantiated.</param>
        /// <param name="supportedPlatforms">The platform(s) on which the concrete type is supported.</param>
        /// <param name="args">Collection of arguments to provide to the concrete type's constructor.</param>
        /// <returns>An instance of the concrete type. Returns a default value of T (typically null) in the event of a failure.</returns>
        private T ActivateInstance <T>(Type concreteType, SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1), params object[] args) where T : IMixedRealityService
        {
            if (concreteType == null)
            {
                return(default(T));
            }

#if UNITY_EDITOR
            if (!UnityEditor.EditorUserBuildSettings.activeBuildTarget.IsPlatformSupported(supportedPlatforms))
#else
            if (!Application.platform.IsPlatformSupported(supportedPlatforms))
#endif
            {
                return(default(T));
            }

            if (!typeof(T).IsAssignableFrom(concreteType))
            {
                Debug.LogError($"Error: {concreteType.Name} service must implement {typeof(T)}.");
                return(default(T));
            }

            try
            {
                T serviceInstance = (T)Activator.CreateInstance(concreteType, args);
                return(serviceInstance);
            }
            catch (Exception e)
            {
                Debug.LogError($"Error: Failed to instantiate {concreteType.Name}: {e.GetType()} - {e.Message}");
                return(default(T));
            }
        }
Exemplo n.º 2
0
        private static bool IsPluginCompatible(
            IFanControlPluginMetadata metadata,
            SupportedPlatforms platform,
            Version platformVersion,
            SupportedCpuArchitectures arch)
        {
            if (!metadata.SupportedPlatforms.HasFlag(platform))
            {
                return(false);
            }

            if (!metadata.SupportedCpuArchitectures.HasFlag(arch))
            {
                return(false);
            }

            Version version;

            if (Version.TryParse(metadata.MinOSVersion, out version) &&
                version > platformVersion)
            {
                return(false);
            }

            if (Version.TryParse(metadata.MaxOSVersion, out version) &&
                version < platformVersion)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        private static SupportedPlatforms GetSupportedPlatformMask(UnityEditor.BuildTarget editorBuildTarget)
        {
            SupportedPlatforms supportedPlatforms = 0;

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                supportedPlatforms |= SupportedPlatforms.WindowsEditor;
            }

            switch (editorBuildTarget)
            {
            case UnityEditor.BuildTarget.StandaloneWindows:
            case UnityEditor.BuildTarget.StandaloneWindows64:
                supportedPlatforms |= SupportedPlatforms.WindowsStandalone;
                break;

            case UnityEditor.BuildTarget.WSAPlayer:
            case UnityEditor.BuildTarget.XboxOne:
                supportedPlatforms |= SupportedPlatforms.WindowsUniversal;
                break;

            case UnityEditor.BuildTarget.StandaloneOSX:
                supportedPlatforms |= SupportedPlatforms.MacStandalone;
                break;

            case UnityEditor.BuildTarget.StandaloneLinux:
            case UnityEditor.BuildTarget.StandaloneLinux64:
            case UnityEditor.BuildTarget.StandaloneLinuxUniversal:
                supportedPlatforms |= SupportedPlatforms.LinuxStandalone;
                break;
            }

            return(supportedPlatforms);
        }
Exemplo n.º 4
0
        private static SupportedPlatforms GetSupportedPlatformMask(RuntimePlatform runtimePlatform)
        {
            SupportedPlatforms supportedPlatforms = 0;

            switch (runtimePlatform)
            {
            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.WindowsEditor:
                supportedPlatforms |= SupportedPlatforms.WindowsStandalone;
                break;

            case RuntimePlatform.WSAPlayerARM:
            case RuntimePlatform.WSAPlayerX86:
            case RuntimePlatform.WSAPlayerX64:
            case RuntimePlatform.XboxOne:
                supportedPlatforms |= SupportedPlatforms.WindowsUniversal;
                break;

            case RuntimePlatform.OSXPlayer:
            case RuntimePlatform.OSXEditor:
                supportedPlatforms |= SupportedPlatforms.MacStandalone;
                break;

            case RuntimePlatform.LinuxPlayer:
            case RuntimePlatform.LinuxEditor:
                supportedPlatforms |= SupportedPlatforms.LinuxStandalone;
                break;
            }

            return(supportedPlatforms);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Activates an instance of the specified concrete type using the provided argument collection.
        /// </summary>
        /// <typeparam name="T">The interface which must be implemented by the concrete type.</typeparam>
        /// <param name="concreteType">The type of object to be instantiated.</param>
        /// <param name="supportedPlatforms">The platform(s) on which the concrete type is supported.</param>
        /// <param name="args">Collection of arguments to provide to the concrete type's constructor.</param>
        /// <returns>An instance of the concrete type. Returns a default value of T (typically null) in the event of a failure.</returns>
        private T ActivateInstance <T>(Type concreteType, SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1), params object[] args) where T : IMixedRealityService
        {
            if (concreteType == null)
            {
                return(default(T));
            }

            if (!PlatformUtility.IsPlatformSupported(supportedPlatforms))
            {
                return(default(T));
            }

            if (!typeof(T).IsAssignableFrom(concreteType))
            {
                Debug.LogError($"Error: {concreteType.Name} service must implement {typeof(T)}.");
                return(default(T));
            }

            try
            {
                T serviceInstance = (T)Activator.CreateInstance(concreteType, args);
                return(serviceInstance);
            }
            catch (Exception e)
            {
                Debug.LogError($"Error: Failed to instantiate {concreteType.Name}: {e.GetType()} - {e.Message}");
                return(default(T));
            }
        }
Exemplo n.º 6
0
        private void GatherBuildTargets(ProjectFile Project, List <PlatformAndConfigToBuild> OutToBuild)
        {
            foreach (ProjectTarget Target in Project.ProjectTargets)
            {
                string ProjectName = Target.TargetRules.Name;

                List <UnrealTargetConfiguration> Configs   = new List <UnrealTargetConfiguration>();
                List <UnrealTargetPlatform>      Platforms = new List <UnrealTargetPlatform>();
                Target.TargetRules.GetSupportedConfigurations(ref Configs, true);
                Target.TargetRules.GetSupportedPlatforms(ref Platforms);

                foreach (UnrealTargetPlatform Platform in Platforms)
                {
                    if (SupportedPlatforms.Contains(Platform))
                    {
                        foreach (UnrealTargetConfiguration Config in Configs)
                        {
                            OutToBuild.Add(new PlatformAndConfigToBuild {
                                ProjectName = ProjectName, Platform = Platform, Config = Config
                            });
                        }
                    }
                }
            }
        }
        public static bool IsSupported(this SupportedPlatforms currentPlatforms, RuntimePlatform platform)
        {
            switch (platform)
            {
            case RuntimePlatform.WindowsEditor:
            case RuntimePlatform.WindowsPlayer:
                return(IsSupported(currentPlatforms, SupportedPlatforms.Windows));

            case RuntimePlatform.OSXEditor:
            case RuntimePlatform.OSXPlayer:
                return(IsSupported(currentPlatforms, SupportedPlatforms.MacOS));

            case RuntimePlatform.LinuxEditor:
            case RuntimePlatform.LinuxPlayer:
                return(IsSupported(currentPlatforms, SupportedPlatforms.Linux));

            case RuntimePlatform.WebGLPlayer:
                return(IsSupported(currentPlatforms, SupportedPlatforms.Web));

            case RuntimePlatform.IPhonePlayer:
                return(IsSupported(currentPlatforms, SupportedPlatforms.iOS));

            case RuntimePlatform.Android:
                return(IsSupported(currentPlatforms, SupportedPlatforms.Android));

            default:
                return(false);
            }
        }
Exemplo n.º 8
0
 /// <inheritdoc />
 public bool RegisterDataProvider <T>(
     Type concreteType,
     SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
     params object[] args) where T : IMixedRealityDataProvider
 {
     return(RegisterService <T>(concreteType, supportedPlatforms, args));
 }
Exemplo n.º 9
0
        private static SupportedPlatforms GetSupportedPlatformMask(UnityEditor.BuildTarget editorBuildTarget)
        {
            SupportedPlatforms supportedPlatforms = 0;

            switch (editorBuildTarget)
            {
            case UnityEditor.BuildTarget.StandaloneWindows:
            case UnityEditor.BuildTarget.StandaloneWindows64:
                supportedPlatforms |= SupportedPlatforms.WindowsStandalone;
                break;

            case UnityEditor.BuildTarget.WSAPlayer:
            case UnityEditor.BuildTarget.XboxOne:
                supportedPlatforms |= SupportedPlatforms.WindowsUniversal;
                break;

            case UnityEditor.BuildTarget.StandaloneOSX:
                supportedPlatforms |= SupportedPlatforms.MacStandalone;
                break;

            case UnityEditor.BuildTarget.StandaloneLinux:
            case UnityEditor.BuildTarget.StandaloneLinux64:
            case UnityEditor.BuildTarget.StandaloneLinuxUniversal:
                supportedPlatforms |= SupportedPlatforms.LinuxStandalone;
                break;

            case UnityEditor.BuildTarget.Lumin:
                supportedPlatforms |= SupportedPlatforms.Lumin;
                break;
            }

            return(supportedPlatforms);
        }
Exemplo n.º 10
0
 public MixedRealityDataProviderAttribute(
     Type serviceInterfaceType,
     SupportedPlatforms runtimePlatforms,
     string profilePath   = "",
     string packageFolder = "MixedRealityToolkit") : base(runtimePlatforms, profilePath, packageFolder)
 {
     ServiceInterfaceType = serviceInterfaceType;
 }
Exemplo n.º 11
0
        public string GetPlatformLink(SupportedPlatforms platform)
        {
            // Check the platform
            string returnUrl = null;

            switch (platform)
            {
            case SupportedPlatforms.NativeIos:
                returnUrl = iosNativeLink;
                break;

            case SupportedPlatforms.WebiOS:
                returnUrl = iosWebLink;
                break;

            case SupportedPlatforms.NativeAmazon:
                returnUrl = amazonNativeLink;
                break;

            case SupportedPlatforms.WebAmazon:
                returnUrl = amazonWebLink;
                break;

            case SupportedPlatforms.NativeAndroid:
                returnUrl = androidNativeLink;
                if (string.IsNullOrEmpty(returnUrl) == true)
                {
                    returnUrl = amazonNativeLink;
                }
                break;

            case SupportedPlatforms.WebAndroid:
                returnUrl = androidWebLink;
                if (string.IsNullOrEmpty(returnUrl) == true)
                {
                    returnUrl = amazonWebLink;
                }
                break;

            case SupportedPlatforms.NativeWin10:
                returnUrl = windows10NativeLink;
                break;

            case SupportedPlatforms.WebWin10:
                returnUrl = windows10WebLink;
                break;
            }

            // Check if the string is empty
            if (string.IsNullOrEmpty(returnUrl) == true)
            {
                // Replace with a web URL
                returnUrl = WebLink;
            }

            // Return the URL
            return(returnUrl);
        }
Exemplo n.º 12
0
        public static bool IsPlatformSupported(SupportedPlatforms platforms)
        {
#if UNITY_EDITOR
            SupportedPlatforms target = GetSupportedPlatformMask(UnityEditor.EditorUserBuildSettings.activeBuildTarget);
#else
            SupportedPlatforms target = GetSupportedPlatformMask(Application.platform);
#endif
            return(IsPlatformSupported(target, platforms));
        }
Exemplo n.º 13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="runtimePlatforms">The platforms on which the extension service is supported.</param>
 /// <param name="profilePath">The relative path to the profile asset.</param>
 /// <param name="packageFolder">The folder to which the path is relative.</param>
 public MixedRealityExtensionServiceAttribute(
     SupportedPlatforms runtimePlatforms,
     string profilePath   = "",
     string packageFolder = "MixedRealityToolkit")
 {
     RuntimePlatforms = runtimePlatforms;
     ProfilePath      = profilePath;
     PackageFolder    = packageFolder;
 }
        private static void UpdateControlVisibility(GameObject[] controls, SupportedPlatforms support)
        {
            bool active = support.IsSupported();

            foreach (GameObject control in controls)
            {
                control.SetActive(active);
            }
        }
Exemplo n.º 15
0
 public FanControlPluginMetadataAttribute(
     string uniqueId,
     SupportedPlatforms supportedPlatforms,
     SupportedCpuArchitectures supportedCpuArchitectures)
     : base(typeof(IFanControlPluginMetadata))
 {
     this.UniqueId                  = uniqueId;
     this.SupportedPlatforms        = supportedPlatforms;
     this.SupportedCpuArchitectures = supportedCpuArchitectures;
 }
Exemplo n.º 16
0
 public FanControlPluginMetadataAttribute(
     string uniqueId, 
     SupportedPlatforms supportedPlatforms,
     SupportedCpuArchitectures supportedCpuArchitectures)
     : base(typeof(IFanControlPluginMetadata))
 {
     this.UniqueId = uniqueId;
     this.SupportedPlatforms = supportedPlatforms;
     this.SupportedCpuArchitectures = supportedCpuArchitectures;
 }
Exemplo n.º 17
0
 public MixedRealityDataProviderAttribute(
     Type serviceInterfaceType,
     SupportedPlatforms runtimePlatforms,
     string name          = "",
     string profilePath   = "",
     string packageFolder = "MixedRealityToolkit",
     bool requiresProfile = false) : base(runtimePlatforms, name, profilePath, packageFolder, requiresProfile)
 {
     ServiceInterfaceType = serviceInterfaceType;
 }
        public static bool IsThisBuildSupported(this SupportedPlatforms currentPlatforms)
        {
            bool returnFlag = IsSupported(currentPlatforms, Application.platform);

            if ((Singleton.Instance != null) && (Singleton.Instance.IsWebApp == true))
            {
                returnFlag = IsSupported(currentPlatforms, SupportedPlatforms.Web);
            }
            return(returnFlag);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initialize a service.
        /// </summary>
        /// <typeparam name="T">The interface type for the service to be initialized.</typeparam>
        /// <param name="concreteType">The concrete type of the service to initialize.</param>
        /// <param name="supportedPlatforms">The platform(s) on which the service is supported.</param>
        /// <param name="args">Arguments to provide to the service class constructor.</param>
        protected virtual void Initialize<T>(Type concreteType, SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1), params object[] args) where T : IMixedRealityService
        {
            if (!RegisterService<T>(concreteType, supportedPlatforms, args))
            {
                Debug.LogError($"Failed to register the {concreteType.Name} service.");
            }

            T serviceInstance = FindService<T>();
            serviceInstance?.Initialize();
        }
Exemplo n.º 20
0
 /// <summary>
 /// Registers a data provider of the specified type.
 /// </summary>
 protected bool RegisterDataProvider <T>(
     Type concreteType,
     SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
     params object[] args) where T : IMixedRealityDataProvider
 {
     return(RegisterDataProviderInternal <T>(
                true, // Retry with an added IMixedRealityService parameter
                concreteType,
                supportedPlatforms,
                args));
 }
 protected bool RegisterDataProvider <T>(
     Type concreteType,
     SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
     params object[] args) where T : IMixedRealityDataProvider
 {
     return(RegisterDataProvider <T>(
                concreteType,
                string.Empty,
                supportedPlatforms,
                args));
 }
Exemplo n.º 22
0
        /// <summary>
        /// Determines whether the specified known platforms is currently supported.
        /// </summary>
        /// <param name="platformToCheck">The platform to check.</param>
        /// <param name="currentPlatform">The current platform.</param>
        /// <returns><c>true</c> if the platform is supported; otherwise, <c>false</c>.</returns>
        public static bool IsPlatformSupported(KnownPlatforms platformToCheck, SupportedPlatforms currentPlatform)
        {
            switch (platformToCheck)
            {
            case KnownPlatforms.Unknown:
                return(false);

            case KnownPlatforms.NET:
                return(currentPlatform == SupportedPlatforms.NET45 ||
                       currentPlatform == SupportedPlatforms.NET46 ||
                       currentPlatform == SupportedPlatforms.NET47 ||
                       currentPlatform == SupportedPlatforms.NET50);

            case KnownPlatforms.NET45:
                return(currentPlatform == SupportedPlatforms.NET45);

            case KnownPlatforms.NET46:
                return(currentPlatform == SupportedPlatforms.NET46);

            case KnownPlatforms.NET47:
                return(currentPlatform == SupportedPlatforms.NET47);

            case KnownPlatforms.NET50:
                return(currentPlatform == SupportedPlatforms.NET50);

            case KnownPlatforms.NetStandard:
                return(currentPlatform == SupportedPlatforms.NetStandard20);

            case KnownPlatforms.NetStandard20:
                return(currentPlatform == SupportedPlatforms.NetStandard20);

            case KnownPlatforms.WindowsUniversal:
                return(currentPlatform == SupportedPlatforms.WindowsUniversal);

            case KnownPlatforms.Xamarin:
                return(currentPlatform == SupportedPlatforms.Android ||
                       currentPlatform == SupportedPlatforms.iOS);

            case KnownPlatforms.XamarinAndroid:
                return(currentPlatform == SupportedPlatforms.Android);

            case KnownPlatforms.XamariniOS:
                return(currentPlatform == SupportedPlatforms.iOS);

            case KnownPlatforms.XamarinForms:
                return(currentPlatform == SupportedPlatforms.PCL);

            case KnownPlatforms.PCL:
                return(currentPlatform == SupportedPlatforms.PCL);

            default:
                throw new ArgumentOutOfRangeException("platformToCheck");
            }
        }
Exemplo n.º 23
0
        /// <inheritdoc />
        public bool RegisterService <T>(Type concreteType, SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1), params object[] args) where T : IMixedRealityService
        {
            T serviceInstance = ActivateInstance <T>(concreteType, supportedPlatforms, args);

            if (serviceInstance == null)
            {
                return(false);
            }

            return(RegisterService <T>(serviceInstance));
        }
Exemplo n.º 24
0
 /// <summary>
 /// Registers the supported platforms.
 /// </summary>
 /// <param name="platforms">The platforms.</param>
 /// <exception cref="System.ArgumentNullException">platforms</exception>
 public static void RegisterSupportedPlatforms(List <SolutionPlatform> platforms)
 {
     if (platforms == null)
     {
         throw new ArgumentNullException("platforms");
     }
     if (SupportedPlatforms.Count > 0)
     {
         throw new InvalidOperationException("Cannot register new platforms. RegisterSupportedPlatforms can only be called once");
     }
     SupportedPlatforms.AddRange(platforms);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="componentType">The <see cref="Microsoft.MixedReality.Toolkit.Utilities.SystemType"/> of the observer.</param>
 /// <param name="componentName">The friendly name of the observer.</param>
 /// <param name="priority">The load priority of the observer.</param>
 /// <param name="runtimePlatform">The runtime platform(s) supported by the observer.</param>
 /// <param name="configurationProfile">The configuration profile for the observer.</param>
 public MixedRealitySpatialObserverConfiguration(
     SystemType componentType,
     string componentName,
     uint priority,
     SupportedPlatforms runtimePlatform,
     BaseSpatialAwarenessObserverProfile configurationProfile)
 {
     this.componentType   = componentType;
     this.componentName   = componentName;
     this.priority        = priority;
     this.runtimePlatform = runtimePlatform;
     this.observerProfile = configurationProfile;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="runtimePlatforms">The platforms on which the extension service is supported.</param>
 /// <param name="defaultProfilePath">The relative path to the default profile asset.</param>
 /// <param name="packageFolder">The package folder to which the path is relative.</param>
 public MixedRealityExtensionServiceAttribute(
     SupportedPlatforms runtimePlatforms,
     string name = "",
     string defaultProfilePath = "",
     string packageFolder      = "MixedRealityToolkit",
     bool requiresProfile      = false)
 {
     RuntimePlatforms   = runtimePlatforms;
     Name               = name;
     DefaultProfilePath = defaultProfilePath;
     PackageFolder      = packageFolder;
     RequiresProfile    = requiresProfile;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="componentType">The <see cref="Microsoft.MixedReality.Toolkit.Utilities.SystemType"/> of the data provider.</param>
 /// <param name="componentName">The friendly name of the data provider.</param>
 /// <param name="priority">The load priority of the data provider.</param>
 /// <param name="runtimePlatform">The runtime platform(s) supported by the data provider.</param>
 /// <param name="profile">The configuration profile for the data provider.</param>
 public MixedRealityInputDataProviderConfiguration(
     SystemType componentType,
     string componentName,
     uint priority,
     SupportedPlatforms runtimePlatform,
     BaseMixedRealityProfile profile)
 {
     this.componentType   = componentType;
     this.componentName   = componentName;
     this.priority        = priority;
     this.runtimePlatform = runtimePlatform;
     deviceManagerProfile = profile;
 }
        /// <summary>
        /// Checks if the profile can be inspected with the currently active build target and renders
        /// a hint to switch build target if not.
        /// </summary>
        /// <param name="supportedPlatforms">The supported platforms by the profile.</param>
        /// <param name="infoText">Optional info text to override info box text.</param>
        /// <returns>True, if the profile and the active build target match.</returns>
        public static bool CheckProfilePlatform(SupportedPlatforms supportedPlatforms, string infoText = null)
        {
            if (!PlatformUtility.IsPlatformSupported(EditorUserBuildSettings.activeBuildTarget, supportedPlatforms))
            {
                EditorGUILayout.HelpBox(string.IsNullOrWhiteSpace(infoText) ?
                                        $"You can't edit this profile with the current build target. Please switch to {supportedPlatforms}."
                   : infoText, MessageType.Info);

                return(false);
            }

            return(true);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="componentType">The concrete type for the system, feature or manager.</param>
 /// <param name="componentName">The simple, human readable name for the system, feature, or manager.</param>
 /// <param name="priority">The priority this system, feature, or manager will be initialized in.</param>
 /// <param name="runtimePlatform">The runtime platform(s) to run this system, feature, or manager on.</param>
 /// <param name="configurationProfile">The configuration profile for the service.</param>
 public MixedRealityServiceConfiguration(
     SystemType componentType,
     string componentName,
     uint priority,
     SupportedPlatforms runtimePlatform,
     BaseMixedRealityProfile configurationProfile)
 {
     this.componentType        = componentType;
     this.componentName        = componentName;
     this.priority             = priority;
     this.runtimePlatform      = runtimePlatform;
     this.configurationProfile = configurationProfile;
 }
 public PlatformSettings(SupportedPlatforms platform, AdvertiserId appId, AdvertiserId idBanner, AdvertiserId idInterstitial, AdvertiserId idRewarded, bool hasBanner, bool hasInterstitial, bool hasRewarded)
 {
     this.platform        = platform;
     this.appId           = appId;
     this.idBanner        = idBanner;
     this.idInterstitial  = idInterstitial;
     this.idRewarded      = idRewarded;
     this.hasBanner       = hasBanner;
     this.hasInterstitial = hasInterstitial;
     this.hasRewarded     = hasRewarded;
     enabled             = false;
     directedForChildren = false;
 }
Exemplo n.º 31
0
 public void TestAddOrReplace()
 {
     var supportedPlatforms = new SupportedPlatforms();
     CollectionAssert.IsEmpty(supportedPlatforms);
     supportedPlatforms.AddOrReplaceMinimumRequirement(DbPlatform.SqlServer2008);
     CollectionAssert.AreEquivalent(new[] { "SqlServer, Version: 10, Driver: AdoNet" }, supportedPlatforms.Select(n => n.ToString()).ToArray());
     supportedPlatforms.AddOrReplaceMinimumRequirement(DbPlatform.SqlServer2012);
     CollectionAssert.AreEquivalent(new[] { "SqlServer, Version: 11, Driver: AdoNet" }, supportedPlatforms.Select(n => n.ToString()).ToArray());
     supportedPlatforms.AddOrReplaceMinimumRequirement(new DbPlatform(Platform.SqlServer, 12, Driver.Odbc));
     CollectionAssert.AreEquivalent(new[]
         {
             "SqlServer, Version: 11, Driver: AdoNet",
             "SqlServer, Version: 12, Driver: Odbc"
         }, supportedPlatforms.Select(n => n.ToString()).ToArray());
 }
Exemplo n.º 32
0
        /// <summary>
        /// Registers a data provider of the specified type.
        /// </summary>
        /// <typeparam name="T">The interface type of the data provider to be registered.</typeparam>
        /// <returns>True if the data provider was successfully registered, false otherwise.</returns>
        protected bool RegisterDataProvider <T>(
            Type concreteType,
            SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
            params object[] args) where T : IMixedRealityDataProvider
        {
#if !UNITY_EDITOR
            if (!Application.platform.IsPlatformSupported(supportedPlatforms))
#else
            if (!EditorUserBuildSettings.activeBuildTarget.IsPlatformSupported(supportedPlatforms))
#endif
            {
                return(false);
            }

            if (concreteType == null)
            {
                Debug.LogError($"Unable to register {typeof(T).Name} service with a null concrete type.");
                return(false);
            }

            if (!typeof(IMixedRealityDataProvider).IsAssignableFrom(concreteType))
            {
                Debug.LogError($"Unable to register the {concreteType.Name} data provider. It does not implement {typeof(IMixedRealityDataProvider)}.");
                return(false);
            }

            T dataProviderInstance;

            try
            {
                dataProviderInstance = (T)Activator.CreateInstance(concreteType, args);
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to register the {concreteType.Name} data provider: {e.GetType()} - {e.Message}");

                // Failures to create the concrete type generally surface as nested exceptions - just logging
                // the top level exception itself may not be helpful. If there is a nested exception (for example,
                // null reference in the constructor of the object itself), it's helpful to also surface those here.
                if (e.InnerException != null)
                {
                    Debug.LogError("Underlying exception information: " + e.InnerException);
                }
                return(false);
            }

            return(RegisterDataProvider(dataProviderInstance));
        }
        public IdentifiableItemBase(IIdentifiable itemInstance, IComposition composition)
        {
            Contract.Requires(itemInstance != null, "itemInstance != null");
            Contract.Requires(composition != null, "composition != null");

            _composition = composition;

            _guid = Guid.NewGuid().ToString();

            _cachedInstanceId = itemInstance.Id;
            _cachedInstanceDescribes = new Describes(itemInstance);

            _cachedCaptionEdited = false;
            _cachedDescriptionEdited = false;

            _itemInstance = itemInstance;

            _xConstructor = Constructor(itemInstance);
            _xConnectivity = Connectivity(itemInstance);

            if (itemInstance is IBaseLinkableComponentProposed)
                _platforms = ((IBaseLinkableComponentProposed)itemInstance).SupportedPlatforms;
            else if (itemInstance is IBaseExchangeItemProposed)
                _platforms = ((IBaseExchangeItemProposed)itemInstance).SupportedPlatforms;
            else
                _platforms = composition.Platforms;

            if (itemInstance is IBaseLinkableComponent)
                _interface = IdentifiableItemType.IBaseLinkableComponent;
            else if (itemInstance is IBaseAdaptedOutput)
                _interface = IdentifiableItemType.IBaseAdaptedOutput;
            else if (itemInstance is IBaseOutput)
                _interface = IdentifiableItemType.IBaseOutput;
            else if (itemInstance is IBaseInput)
                _interface = IdentifiableItemType.IBaseInput;
            else if (itemInstance is IAdaptedOutputFactory)
                _interface = IdentifiableItemType.IAdaptedOutputFactory;
            else
                _interface = IdentifiableItemType.Unknown;
        }
Exemplo n.º 34
0
 public static XElement Persist(SupportedPlatforms platforms, IDocumentAccessor accessor)
 {
     return new XElement(Component.NamespaceOpenMIv2 + "Platforms",
         Persist(platforms).Select(value => new XElement(Component.NamespaceOpenMIv2 + "Platform", value)));
 }
Exemplo n.º 35
0
        /// <summary>
        /// Determines whether the specified known platforms is currently supported.
        /// </summary>
        /// <param name="platformToCheck">The platform to check.</param>
        /// <param name="currentPlatform">The current platform.</param>
        /// <returns><c>true</c> if the platform is supported; otherwise, <c>false</c>.</returns>
        public static bool IsPlatformSupported(KnownPlatforms platformToCheck, SupportedPlatforms currentPlatform)
        {
            switch (platformToCheck)
            {
                case KnownPlatforms.Unknown:
                    return false;

                case KnownPlatforms.NET:
                    return currentPlatform == SupportedPlatforms.NET40 ||
                           currentPlatform == SupportedPlatforms.NET45 ||
                           currentPlatform == SupportedPlatforms.NET46 ||
                           currentPlatform == SupportedPlatforms.NET50;

                case KnownPlatforms.NET40:
                    return currentPlatform == SupportedPlatforms.NET40;

                case KnownPlatforms.NET45:
                    return currentPlatform == SupportedPlatforms.NET45;

                case KnownPlatforms.NET46:
                    return currentPlatform == SupportedPlatforms.NET46;

                case KnownPlatforms.NET50:
                    return currentPlatform == SupportedPlatforms.NET50;

                case KnownPlatforms.Silverlight:
                    return currentPlatform == SupportedPlatforms.Silverlight5;

                case KnownPlatforms.Silverlight5:
                    return currentPlatform == SupportedPlatforms.Silverlight5;

                case KnownPlatforms.WindowsPhone:
                    return currentPlatform == SupportedPlatforms.WindowsPhone80 ||
                           currentPlatform == SupportedPlatforms.WindowsPhone81Silverlight ||
                           currentPlatform == SupportedPlatforms.WindowsPhone81Runtime;

                case KnownPlatforms.WindowsPhoneSilverlight:
                    return currentPlatform == SupportedPlatforms.WindowsPhone80 ||
                           currentPlatform == SupportedPlatforms.WindowsPhone81Silverlight;

                case KnownPlatforms.WindowsPhoneRuntime:
                    return currentPlatform == SupportedPlatforms.WindowsPhone81Runtime;

                case KnownPlatforms.WindowsPhone80:
                    return currentPlatform == SupportedPlatforms.WindowsPhone80;

                case KnownPlatforms.WindowsPhone81Silverlight:
                    return currentPlatform == SupportedPlatforms.WindowsPhone81Silverlight;

                case KnownPlatforms.WindowsPhone81Runtime:
                    return currentPlatform == SupportedPlatforms.WindowsPhone81Runtime;

                case KnownPlatforms.WindowsRuntime:
                    return currentPlatform == SupportedPlatforms.WindowsRuntime80 ||
                           currentPlatform == SupportedPlatforms.WindowsRuntime81;

                case KnownPlatforms.WindowsRuntime80:
                    return currentPlatform == SupportedPlatforms.WindowsRuntime80;

                case KnownPlatforms.WindowsRuntime81:
                    return currentPlatform == SupportedPlatforms.WindowsRuntime81;

                case KnownPlatforms.WindowsUniversal:
                    return currentPlatform == SupportedPlatforms.WindowsUniversal100;

                case KnownPlatforms.WindowsUniversal100:
                    return currentPlatform == SupportedPlatforms.WindowsUniversal100;

                case KnownPlatforms.Xamarin:
                    return currentPlatform == SupportedPlatforms.Android ||
                           currentPlatform == SupportedPlatforms.iOS;

                case KnownPlatforms.XamarinAndroid:
                    return currentPlatform == SupportedPlatforms.Android;

                case KnownPlatforms.XamariniOS:
                    return currentPlatform == SupportedPlatforms.iOS;

                case KnownPlatforms.PCL:
                    return currentPlatform == SupportedPlatforms.PCL;

                default:
                    throw new ArgumentOutOfRangeException("platformToCheck");
            }
        }
Exemplo n.º 36
0
            public static bool Instantiate(
                ExternalType componentType,
                SupportedPlatforms platforms,
                List<IReport> reports,
                out IBaseLinkableComponent component)
            {
                Contract.Requires(componentType != null, "componentType != null");
                Contract.Requires(reports != null, "reports != null");

                component = null;

                Type type;

                try
                {
                    component = componentType
                        .CreateInstance(out type) as IBaseLinkableComponent;
                }
                catch (System.Exception e)
                {
                    reports.Add(Report.Error(Report.ResourceIds.Instantiation,
                        "Cannot instantiate IBaseLinkableComponent", e.Message));
                    return false;
                }

                if (component == null)
                {
                    reports.Add(Report.Error(Report.ResourceIds.Instantiation,
                        "Cannot instantiate IBaseLinkableComponent", type.ToString()));
                    return false;
                }

                return true;
            }
Exemplo n.º 37
0
            public static bool Parse( 
                XElement xLinkableComponent,
                IDocumentAccessor accessor,
                List<IReport> reports,
                out ExternalType component,
                out SupportedPlatforms platforms,
                out List<Argument> argumentsOmi)
            {
                Contract.Requires(reports != null, "reports != null");

                component = null;
                platforms = SupportedPlatforms.Unknown;
                argumentsOmi = new List<Argument>();

                var ns = xLinkableComponent.Name.Namespace;

                if (!Validates(xLinkableComponent, Xsd.ComponentV2, reports))
                    return false;

                var xArgs = xLinkableComponent.Elements(NamespaceOpenMIv2.GetName(XArguments)).SingleOrDefault();
                var xArguments = xArgs != null
                    ? xArgs.Elements(NamespaceOpenMIv2.GetName(XArgument))
                    : null;

                var xPlatforms = xLinkableComponent.Elements(NamespaceOpenMIv2.GetName(XPlatforms)).SingleOrDefault();

                var assembly = Utilities.Xml.GetAttribute(xLinkableComponent, XAssembly);
                var type = Utilities.Xml.GetAttribute(xLinkableComponent, XType);

                AssemblyName assemblyName;
                Uri codeBaseUri = null;

                if (!ExternalType.AssemblyNameGet(assembly, codeBaseUri, type, reports, accessor, out assemblyName))
                    return false;

                component = new ExternalType(accessor);
                component.Initialise(assemblyName, type);

                if (xArguments != null)
                    argumentsOmi.AddRange(xArguments
                        .Select(x => new Argument(x, accessor)));

                platforms = Platforms.Parse(xPlatforms, accessor);

                return true;
            }
Exemplo n.º 38
0
            public static XElement Persist(
                IBaseLinkableComponent component,
                SupportedPlatforms platforms,
                IDocumentAccessor accessor)
            {
                // Original intention was to filter out arguments that were read only or
                // set explicitly to their default values to simplify what user sees by reducing
                // verbosity. However, components that aggregate other components might need to process
                // all the aggregated component arguments before those aggregated components ever get
                // instantiated (when defaults etc. would normally become visible).
                // Hence, welcome verbosity my DEAR old friend.

                Contract.Requires(component != null, "component != null");

                var args = component
                    .Arguments
                    .Select(a => ArgumentValueGet(a, accessor));

                return Persist(component, platforms, args, accessor);
            }
Exemplo n.º 39
0
            public static XElement Persist(
                IBaseLinkableComponent component,
                SupportedPlatforms platforms,
                IEnumerable<Argument> argumentsOmi,
                IDocumentAccessor accessor)
            {
                Contract.Requires(component != null, "component != null");
                Contract.Requires(argumentsOmi != null, "arguments != null");

                var location = new Uri(component.GetType().Assembly.Location);

                if (accessor != null && accessor.Uri != null)
                    location = accessor.Uri.MakeRelativeUri(location);

                return new XElement(NamespaceOpenMIv2 + "LinkableComponent",
                    new XAttribute("Type", component.GetType().ToString()),
                    new XAttribute("Assembly", location.ToString()),
                    new XElement(NamespaceOpenMIv2 + "Arguments",
                        argumentsOmi.Select(a => a.Persist(accessor))),
                    Platforms.Persist(platforms, accessor));
            }
        public virtual void Initialise(XElement xElement, IDocumentAccessor accessor)
        {
            xElement = Persistence.ThisOrSingleChild(XName, xElement);

            _guid = Utilities.Xml.GetAttribute(xElement, "id");
            _cachedInstanceId = Utilities.Xml.GetAttribute(xElement, "instanceId");

            var interfaceType = Utilities.Xml.GetAttribute(xElement, "interface");

            _cachedCaptionEdited = Utilities.Xml.GetAttribute(xElement, "captionEdited", false);
            _cachedDescriptionEdited = Utilities.Xml.GetAttribute(xElement, "descriptionEdited", false);

            var caption = Utilities.Xml.GetAttribute(xElement, "caption");

            var description = _cachedDescriptionEdited
                ? xElement.Element("Description").Value
                : "Description unavailable until ItemInstance(composition) accessed";

            _cachedInstanceDescribes = new Describes(caption, description);
            _cachedCaptionEdited = true;

            _xConstructor = Persistence.ThisOrSingleChild(XConstructor, xElement);
            _xConnectivity = Persistence.ThisOrSingleChild(XConnectivity, xElement);

            _platforms = Persistence.PlatformsChi.Parse(xElement, accessor);

            _interface = (IdentifiableItemType)Enum.Parse(typeof(IdentifiableItemType), interfaceType);
        }
Exemplo n.º 41
0
 public void ReturnsFalseForUnsupportedPlatform(KnownPlatforms platformToCheck, SupportedPlatforms currentPlatform)
 {
     Assert.IsFalse(Platforms.IsPlatformSupported(platformToCheck, currentPlatform));
 }
Exemplo n.º 42
0
            static List<string> Persist(SupportedPlatforms platforms)
            {
                var values = new List<string>();

                if ((platforms & SupportedPlatforms.Win) != 0)
                    values.Add(SupportedPlatforms.Win.ToString());
                if ((platforms & SupportedPlatforms.Win32) != 0)
                    values.Add(SupportedPlatforms.Win32.ToString());
                if ((platforms & SupportedPlatforms.Win64) != 0)
                    values.Add(SupportedPlatforms.Win64.ToString());

                if ((platforms & SupportedPlatforms.Unix) != 0)
                    values.Add(SupportedPlatforms.Unix.ToString());
                if ((platforms & SupportedPlatforms.Unix32) != 0)
                    values.Add(SupportedPlatforms.Unix32.ToString());
                if ((platforms & SupportedPlatforms.Unix64) != 0)
                    values.Add(SupportedPlatforms.Unix64.ToString());

                if ((platforms & SupportedPlatforms.Linux) != 0)
                    values.Add(SupportedPlatforms.Linux.ToString());
                if ((platforms & SupportedPlatforms.Linux32) != 0)
                    values.Add(SupportedPlatforms.Linux32.ToString());
                if ((platforms & SupportedPlatforms.Linux64) != 0)
                    values.Add(SupportedPlatforms.Linux64.ToString());

                if ((platforms & SupportedPlatforms.Mac) != 0)
                    values.Add(SupportedPlatforms.Mac.ToString());
                if ((platforms & SupportedPlatforms.Mac32) != 0)
                    values.Add(SupportedPlatforms.Mac32.ToString());
                if ((platforms & SupportedPlatforms.Mac64) != 0)
                    values.Add(SupportedPlatforms.Mac64.ToString());

                return values;
            }