Beispiel #1
0
        //----- params -----

        //----- field -----

        //----- property -----

        //----- method -----

        public static async Task <bool> Upload(S3Uploader uploader)
        {
            var exportPath = BuildManager.GetExportPath();

            if (string.IsNullOrEmpty(exportPath))
            {
                return(false);
            }

            var platformName = PlatformUtility.GetPlatformTypeName();

            var sw = System.Diagnostics.Stopwatch.StartNew();

            var result = await uploader.Execute(exportPath, platformName);

            sw.Stop();

            var success = !string.IsNullOrEmpty(result);

            using (new DisableStackTraceScope())
            {
                if (success)
                {
                    Debug.LogFormat("Upload Complete. ({0:F2}sec)\n\nVersion : {1}", sw.Elapsed.TotalSeconds, result);
                }
                else
                {
                    Debug.LogError("Upload Failed.");
                }
            }

            return(success);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the type of the implementation.
        /// </summary>
        /// <param name="interfaceType">Type of the interface.</param>
        /// <param name="referenceAssembly">The reference assembly.</param>
        /// <param name="referenceType">Type of the reference.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Interface implementation was not found. Ensure that the Handle method is called directly (without reflection).</exception>
        private static Type GetImplementationType(Type interfaceType, Assembly referenceAssembly, Type referenceType)
        {
            lock (Types)
            {
                if (Types.TryGetValue(interfaceType, out var implementationType))
                {
                    return(implementationType);
                }

                var interfaceAssembly = interfaceType.GetInformationReader().Assembly;
                var assemblies        = new[] { interfaceAssembly, PlatformUtility.GetCallingAssembly(), referenceAssembly, referenceType?.GetInformationReader().Assembly };
                implementationType = (from assembly in assemblies
                                      where !(assembly is null)
                                      from t in assembly.GetTypes()
                                      where t.GetInformationReader().BaseType == typeof(AdvisedInterface)
                                      let i = t.GetAssignmentReader().GetInterfaces()
                                              where i.Contains(interfaceType)
                                              select t).FirstOrDefault();
                if (implementationType == null)
                {
                    throw new ArgumentException("Interface implementation was not found. Ensure that the Handle<> method is called directly (without reflection) or that the interface is marked with [" + nameof(DynamicHandleAttribute) + "].");
                }
                Types[interfaceType] = implementationType;
                return(implementationType);
            }
        }
Beispiel #3
0
        public NativeTestLib()
        {
            if (NativeLib == null)
            { // can we use a static constructor, or interplay with load time?
                var fname = PlatformUtility.CreateLibraryFileName("test_native_library");

                var testLibPathEnv = "DynamicInteropTestLibPath";
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(testLibPathEnv)))
                {
                    string guess = GuessTestLibPath();
                    if (Directory.Exists(guess))
                    {
                        Environment.SetEnvironmentVariable(testLibPathEnv, guess);
                    }
                    else
                    {
                        //testLibPathEnv = "";
                        string msg = "You need to set an environment variable e.g.: " +
                                     @"set DynamicInteropTestLibPath=C:\src\dynamic-interop-dll\x64\Debug";
                        throw new Exception(msg);
                    }
                }
                string nativeLibFilename = PlatformUtility.FindFirstFullPath(fname, "test_delegate_library DLL", testLibPathEnv);
                NativeLib = new UnmanagedDll(nativeLibFilename);
            }
        }
Beispiel #4
0
        private static string PrepareExportDirectory(IApplicationBuilder applicationBuilder, bool batchMode)
        {
            // 出力先.
            var directory = string.Empty;

            directory = GetExportDirectory(applicationBuilder, batchMode);

            if (string.IsNullOrEmpty(directory))
            {
                return(null);
            }

            var platformName = PlatformUtility.GetPlatformName();

            var exportFolderName = applicationBuilder.GetExportFolderName();

            directory = PathUtility.Combine(new string[] { directory, platformName, exportFolderName });

            // 既存の成果物を破棄.
            FileUtil.DeleteFileOrDirectory(directory);

            // 出力先作成.
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            return(directory);
        }
Beispiel #5
0
        public override DResult <UserResult> User()
        {
            var code = "code".Query(string.Empty);

            var accessToken = AccessToken(code, Callback);

            if (accessToken.IsNullOrEmpty())
            {
                return(new DResult <UserResult>("授权失败!"));
            }

            var val = PlatformUtility.GetContext(accessToken);

            if (!string.IsNullOrWhiteSpace(val["error"]))
            {
                return(new DResult <UserResult>(val["error"]));
            }
            var info = new UserResult();

            info.Id = val["uid"];
            var token = val["access_token"];
            var json  = Config.UserUrl.FormatWith(info.Id, token).As <IHtml>().GetHtml(Encoding.UTF8);

            val          = PlatformUtility.GetContext(json);
            info.Gender  = (val["gender"] == "m" ? "男" : "女");
            info.Nick    = val["name"];
            info.Profile = val["profile_image_url"];
            return(new DResult <UserResult>(true, info));
        }
        public static bool Execute()
        {
            string logfile = HugsLibUtility.TryGetLogFilePath();

            if (logfile.NullOrEmpty() || !File.Exists(logfile))
            {
                HugsLibController.Logger.ReportException(new FileNotFoundException("Log file path is unknown or log file does not exist. Path:" + logfile));
                return(false);
            }
            var platform = PlatformUtility.GetCurrentPlatform();

            switch (platform)
            {
            case PlatformType.Linux:
                return(Shell.StartProcess(new Shell.ShellCommand {
                    FileName = logfile
                }));

            case PlatformType.MacOSX:
                return(Shell.StartProcess(new Shell.ShellCommand {
                    FileName = "open", Args = logfile
                }));

            case PlatformType.Windows:
                return(Shell.StartProcess(new Shell.ShellCommand {
                    FileName = logfile
                }));

            default:
                HugsLibController.Logger.ReportException(new Shell.UnsupportedPlatformException("ShellOpenLog"));
                return(false);
            }
        }
Beispiel #7
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));
            }
        }
Beispiel #8
0
        public override DResult <UserResult> User()
        {
            var code = "code".Query(string.Empty);
            var col  = AccessToken(code);

            if (string.IsNullOrWhiteSpace(col["access_token"]))
            {
                return(new DResult <UserResult>("授权失败!"));
            }
            var result = new UserResult
            {
                Id          = col["openid"],
                AccessToken = col["access_token"]
            };
            var url         = string.Format(Config.UserUrl, result.AccessToken, result.Id);
            var html        = url.As <IHtml>().GetHtml(Encoding.UTF8);
            var userCollect = PlatformUtility.GetContext(html);

            if (!string.IsNullOrWhiteSpace(userCollect["errcode"]))
            {
                return(new DResult <UserResult>(userCollect["errmsg"]));
            }
            result.Nick    = userCollect["nickname"];
            result.Gender  = (userCollect["sex"] == "1" ? "男" : "女");
            result.Profile = userCollect["headimgurl"];
            return(new DResult <UserResult>(true, result));
        }
Beispiel #9
0
        private NameValueCollection AccessToken(string code)
        {
            var    url     = Config.TokenUrl.FormatWith(Config.Partner, Config.Key, code);
            string content = url.As <IHtml>().GetHtml(Encoding.UTF8);

            return(PlatformUtility.GetContext(content));
        }
Beispiel #10
0
        /// <summary>
        /// Render axis information view.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context instance.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            base.OnPaint(dc);

            var ai = AxisInfo;

            if (ai == null)
            {
                return;
            }

            var g = dc.Graphics;

            var ds         = Chart.DataSource;
            var clientRect = ClientBounds;

            RGFloat fontHeight = (RGFloat)(this.FontSize * PlatformUtility.GetDPI() / 72.0) + 4;

            double rowValue = ai.Minimum;

            if (Orientation == AxisOrientation.Vertical)
            {
                RGFloat stepY    = (clientRect.Height - fontHeight) / ai.Levels;
                var     textRect = new Rectangle(0, clientRect.Bottom - fontHeight, clientRect.Width, fontHeight);

                for (int level = 0; level <= ai.Levels; level++)
                {
                    g.DrawText(Math.Round(rowValue, Math.Abs(ai.Scaler)).ToString(), FontName, FontSize, ForeColor, textRect, ReoGridHorAlign.Right, ReoGridVerAlign.Middle);

                    textRect.Y -= stepY;
                    rowValue   += Math.Round(ai.LargeStride, Math.Abs(ai.Scaler));
                }
            }
            else if (Orientation == AxisOrientation.Horizontal)
            {
                var maxWidth = Math.Max(
                    PlatformUtility.MeasureText(dc,
                                                Math.Round(ai.Minimum, Math.Abs(ai.Scaler)).ToString(),
                                                FontName, FontSize, Drawing.Text.FontStyles.Regular
                                                ).Width,
                    PlatformUtility.MeasureText(dc,
                                                Math.Round(ai.Maximum, Math.Abs(ai.Scaler)).ToString(),
                                                FontName, FontSize, Drawing.Text.FontStyles.Regular
                                                ).Width);

                int showTitleStride = Math.Max((int)Math.Ceiling(ai.Levels * maxWidth / clientRect.Width), 1);

                RGFloat columnWidth = clientRect.Width / ai.Levels * showTitleStride;
                var     textRect    = new Rectangle(clientRect.Left - (columnWidth / 2), clientRect.Top, columnWidth, clientRect.Height);

                for (int level = 0; level <= ai.Levels; level += showTitleStride)
                {
                    g.DrawText(Math.Round(rowValue, Math.Abs(ai.Scaler)).ToString(), FontName, FontSize, ForeColor, textRect, ReoGridHorAlign.Center, ReoGridVerAlign.Top);

                    textRect.X += columnWidth;
                    rowValue   += Math.Round(ai.LargeStride, Math.Abs(ai.Scaler)) * showTitleStride;
                }
            }
        }
 static void BeforeBuild(BuildTarget targetPlatform)
 {
     if (Directory.Exists(_outPath) == false)
     {
         Directory.CreateDirectory(_outPath);
     }
     PlatformUtility.Switch(targetPlatform);
 }
Beispiel #12
0
        public string BuildDownloadUrl(AssetInfo assetInfo)
        {
            var platformName = PlatformUtility.GetPlatformTypeName();

            var url = PathUtility.Combine(new string[] { remoteUrl, platformName, versionHash, assetInfo.FileName });

            return(string.Format("{0}?v={1}", url, assetInfo.Hash));
        }
Beispiel #13
0
        public static string GetBundlePath(string bundleName)
        {
            string bundlePath = Path.Combine(PlatformUtility.GetExternalPath(), bundleName);

            if (File.Exists(bundlePath))
            {
                return(bundlePath);
            }
            return(Path.Combine(PlatformUtility.GetStreamingAssetsPath(), bundleName));
        }
Beispiel #14
0
        /// <summary>
        /// Render axis information view.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context instance.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            base.OnPaint(dc);

            if (this.Chart == null)
            {
                return;
            }

            var ai = this.AxisType == AxisTypes.Primary ?
                     this.Chart.PrimaryAxisInfo : this.Chart.SecondaryAxisInfo;

            if (ai == null)
            {
                return;
            }

            var g = dc.Graphics;

            var ds         = this.Chart.DataSource;
            var clientRect = this.ClientBounds;

            RGFloat fontHeight = (RGFloat)(this.FontSize * PlatformUtility.GetDPI() / 72.0) + 4;

            double rowValue = ai.Minimum;

            if (orientation == AxisOrientation.Vertical)
            {
                RGFloat stepY    = (clientRect.Height - fontHeight) / ai.Levels;
                var     textRect = new Rectangle(0, clientRect.Bottom - fontHeight, clientRect.Width, fontHeight);

                for (int level = 0; level <= ai.Levels; level++)
                {
                    g.DrawText(Math.Round(rowValue, Math.Abs(ai.Scaler)).ToString(), this.FontName, this.FontSize, this.ForeColor, textRect, ReoGridHorAlign.Right, ReoGridVerAlign.Middle);

                    textRect.Y -= stepY;
                    rowValue   += Math.Round(ai.LargeStride, Math.Abs(ai.Scaler));
                }
            }
            else if (orientation == AxisOrientation.Horizontal)
            {
                RGFloat columnWidth = clientRect.Width / ai.Levels;
                var     textRect    = new Rectangle(clientRect.Left - (columnWidth / 2), clientRect.Top, columnWidth, clientRect.Height);

                for (int level = 0; level <= ai.Levels; level++)
                {
                    g.DrawText(Math.Round(rowValue, Math.Abs(ai.Scaler)).ToString(), this.FontName, this.FontSize, this.ForeColor, textRect, ReoGridHorAlign.Center, ReoGridVerAlign.Top);

                    textRect.X += columnWidth;
                    rowValue   += Math.Round(ai.LargeStride, Math.Abs(ai.Scaler));
                }
            }
        }
Beispiel #15
0
        private string GetAccessToken(string code, string callBackUrl)
        {
            var    url     = Config.TokenUrl.FormatWith(Config.Partner, Config.Key, code, callBackUrl);
            string content = url.As <IHtml>().GetHtml(Encoding.UTF8);
            var    val     = PlatformUtility.GetContext(content);

            if (val["access_token"].IsNotNullOrEmpty())
            {
                return(val["access_token"]);
            }
            return(string.Empty);
        }
Beispiel #16
0
        /// <summary>
        /// Measure serial label size.
        /// </summary>
        /// <param name="index">Index of serial in data source.</param>
        /// <returns>Measured size for serial label.</returns>
        protected virtual Size GetLabelSize(int index)
        {
            var ds = this.Chart.DataSource;

            if (ds == null)
            {
                return(Size.Zero);
            }

            string label = ds[index].Label;

            return(PlatformUtility.MeasureText(null, label, this.FontName, this.FontSize, this.FontStyles));
        }
        /// <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);
        }
 public void WellKnownSystemDll()
 {
     if (PlatformUtility.IsUnix)
     {
         TestLoadLibc();
     }
     else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         TestLoadKernel32();
     }
     else
     {
         throw new NotSupportedException(PlatformUtility.GetPlatformNotSupportedMsg());
     }
 }
Beispiel #19
0
        private string BuildDownloadUrl(AssetInfo assetInfo)
        {
            var platformName = PlatformUtility.GetPlatformTypeName();

            var url = PathUtility.Combine(new string[] { remoteUrl, platformName, versionHash, assetInfo.FileName });

            var downloadUrl = string.Format("{0}{1}", url, PackageExtension);

            if (!assetInfo.Hash.IsNullOrEmpty())
            {
                downloadUrl = string.Format("{0}?v={1}", downloadUrl, assetInfo.Hash);
            }

            return(downloadUrl);
        }
Beispiel #20
0
        public string GetAssetBundleOutputPath()
        {
            var projectPath = UnityPathUtility.GetProjectFolderPath();
            var folderName  = PlatformUtility.GetPlatformTypeName();

            var paths = new string[] { projectPath, UnityPathUtility.LibraryFolder, AssetBundleCacheFolder, folderName };

            var assetBundlePath = PathUtility.Combine(paths);

            if (!Directory.Exists(assetBundlePath))
            {
                Directory.CreateDirectory(assetBundlePath);
            }

            return(assetBundlePath);
        }
        private string RedactHomeDirectoryPaths(string log)
        {
            // not necessary for windows logs
            if (PlatformUtility.GetCurrentPlatform() == PlatformType.Windows)
            {
                return(log);
            }
            const string pathReplacement = "[Home_dir]";
            var          homePath        = Environment.GetEnvironmentVariable("HOME");

            if (homePath == null)
            {
                return(log);
            }
            return(log.Replace(homePath, pathReplacement));
        }
Beispiel #22
0
        public static string GetExportPath()
        {
            var config = ManageConfig.Instance;

            var exportDirectory = config.ExportDirectory;

            if (string.IsNullOrEmpty(exportDirectory))
            {
                return(null);
            }

            var platformFolderName = PlatformUtility.GetPlatformTypeName();

            var paths = new string[] { exportDirectory, ExportFolderName, platformFolderName };

            return(PathUtility.Combine(paths) + PathUtility.PathSeparator);
        }
Beispiel #23
0
        public override DResult <UserResult> User()
        {
            var    code    = "code".Query(string.Empty);
            string context = GetAccessToken(code, Callback);

            var info = PlatformUtility.GetContext(context);

            if (info["errorCode"] == "0")
            {
                return(new DResult <UserResult>(true, new UserResult
                {
                    Id = info["openid"],
                    Nick = info["nick"]
                }));
            }
            return(new DResult <UserResult>(info["errorMsg"]));
        }
Beispiel #24
0
            public void ShowEditControl(Graphics.Rectangle bounds, Cell cell)
            {
                var sheet = this.canvas.CurrentWorksheet;

                Color textColor;

                if (!cell.RenderColor.IsTransparent)
                {
                    textColor = cell.RenderColor;
                }
                else if (cell.InnerStyle.HasStyle(PlainStyleFlag.TextColor))
                {
                    // cell text color, specified by SetRangeStyle
                    textColor = cell.InnerStyle.TextColor;
                }
                else
                {
                    // default cell text color
                    textColor = this.canvas.controlStyle[ControlAppearanceColors.GridText];
                }

                Canvas.SetLeft(this.editTextbox, bounds.X);
                Canvas.SetTop(this.editTextbox, bounds.Y);

                this.editTextbox.Width      = bounds.Width;
                this.editTextbox.Height     = bounds.Height;
                this.editTextbox.RenderSize = bounds.Size;

                this.editTextbox.CellSize   = cell.Bounds.Size;
                this.editTextbox.VAlign     = cell.InnerStyle.VAlign;
                this.editTextbox.FontFamily = new FontFamily(cell.InnerStyle.FontName);
                this.editTextbox.FontSize   = cell.InnerStyle.FontSize * sheet.ScaleFactor * 96f / 72f;
                this.editTextbox.FontStyle  = PlatformUtility.ToWPFFontStyle(cell.InnerStyle.fontStyles);
                this.editTextbox.Foreground = this.Renderer.GetBrush(textColor);
                this.editTextbox.Background = this.Renderer.GetBrush(cell.InnerStyle.HasStyle(PlainStyleFlag.BackColor)
                                        ? cell.InnerStyle.BackColor : this.canvas.controlStyle[ControlAppearanceColors.GridBackground]);
                this.editTextbox.SelectionStart = this.editTextbox.Text.Length;
                this.editTextbox.TextWrap       = cell.InnerStyle.TextWrapMode != TextWrapMode.NoWrap;
                this.editTextbox.TextWrapping   = (cell.InnerStyle.TextWrapMode == TextWrapMode.NoWrap)
                                        ? TextWrapping.NoWrap : TextWrapping.Wrap;

                this.editTextbox.Visibility = Visibility.Visible;
                this.editTextbox.Focus();
            }
Beispiel #25
0
        public static void CheckInstallationPackage(string versionPath)
        {
            updateTaskType = TaskType.CheckInstallationPackage;
            string bundleName;

            if (!AssetBundleManager.Instance.GetBundleName(versionPath, out bundleName))
            {
                return;
            }

            string bundlePath = Path.Combine(PlatformUtility.GetExternalPath(), bundleName);

            if (!File.Exists(bundlePath))
            {
                return;
            }

            AssetBundleManager.Instance.UnloadAssetBundle(bundleName);
            bundlePath = Path.Combine(PlatformUtility.GetStreamingAssetsPath(), bundleName);
            AssetBundle bundle = AssetBundle.LoadFromFile(bundlePath);

            if (bundle == null)
            {
                return;
            }

            string            assetName          = Path.GetFileNameWithoutExtension(versionPath);
            VersionUpdateData packageVersionData = bundle.LoadAsset <VersionUpdateData>(assetName);

            bundle.Unload(false);
            if (packageVersionData == null || versionData.versionNumber >= packageVersionData.versionNumber)
            {
                return;
            }

            Debug.LogFormat("The external path version is {0}, package version is {1}, Delete the external path.", versionData.versionNumber, packageVersionData.versionNumber);
            AssetBundleManager.Instance.UnloadAllAssetBundle();
            Directory.Delete(PlatformUtility.GetExternalPath(), true);
            AssetBundleManager.Instance.LoadedManifestAssetBundle();
        }
Beispiel #26
0
        protected override Rectangle GetPlotViewBounds(DrawingContext dc, Rectangle bodyBounds)
        {
            var rect = base.GetPlotViewBounds(dc, bodyBounds);

            RGFloat extraWidth = 0;

            for (int i = 0; i < DataSource.CategoryCount; i++)
            {
                var title = DataSource.GetCategoryName(i);

                if (!string.IsNullOrEmpty(title))
                {
                    var size = PlatformUtility.MeasureText(dc, title, FontName, FontSize, Drawing.Text.FontStyles.Regular);
                    if (extraWidth < size.Width)
                    {
                        extraWidth = size.Width;
                    }
                }
            }

            extraWidth -= 30;             // to compensate for the 30 units set aside by base.GetPlotViewBounds()

            return(new Rectangle(rect.X + extraWidth, rect.Y, rect.Width - extraWidth, rect.Height));
        }
Beispiel #27
0
 public System.Drawing.Font GetFont(string name, float size, FontStyles style)
 {
     return(this.resourceManager.GetFont(name, size, PlatformUtility.ToWFFontStyle(style)));
 }
        /// <summary>
        /// Internal method that creates an instance of the specified concrete type and registers the provider.
        /// </summary>
        private bool RegisterDataProviderInternal <T>(
            bool retryWithRegistrar,
            Type concreteType,
            string providerName,
            SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
            params object[] args) where T : IMixedRealityDataProvider
        {
            if (!PlatformUtility.IsPlatformSupported(supportedPlatforms))
            {
                DebugUtilities.LogVerboseFormat(
                    "Not registering data provider of type {0} with name {1} because the current platform is not in supported platforms {2}",
                    concreteType,
                    providerName,
                    supportedPlatforms);
                return(false);
            }

            if (concreteType == null)
            {
                Debug.LogError($"Unable to register {typeof(T).Name} data provider ({(!string.IsNullOrWhiteSpace(providerName) ? providerName : "unknown")}) because the value of concreteType is null.\n" +
                               "This may be caused by code being stripped during linking. The link.xml file in the MixedRealityToolkit.Generated folder is used to control code preservation.\n" +
                               "More information can be found at https://docs.unity3d.com/Manual/ManagedCodeStripping.html.");
                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)
            {
                if (retryWithRegistrar && (e is MissingMethodException))
                {
                    Debug.LogWarning($"Failed to find an appropriate constructor for the {concreteType.Name} data provider. Adding the Registrar instance and re-attempting registration.");
#pragma warning disable 0618
                    List <object> updatedArgs = new List <object>();
                    updatedArgs.Add(Registrar);
                    if (args != null)
                    {
                        updatedArgs.AddRange(args);
                    }
                    return(RegisterDataProviderInternal <T>(
                               false, // Do NOT retry, we have already added the configured IMIxedRealityServiceRegistrar
                               concreteType,
                               providerName,
                               supportedPlatforms,
                               updatedArgs.ToArray()));

#pragma warning restore 0618
                }

                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));
        }
Beispiel #29
0
 /// <summary>
 /// Execute a command in a new process
 /// </summary>
 /// <param name="processName">Process name e.g. "uname"</param>
 /// <param name="arguments">Arguments e.g. "-s"</param>
 /// <returns>The output of the command to the standard output stream</returns>
 public static string ExecCommand(string processName, string arguments)
 {
     return(PlatformUtility.ExecCommand(processName, arguments));
 }
Beispiel #30
0
 /// <summary>
 /// Gets the platform on which the current process runs.
 /// </summary>
 /// <remarks>
 /// <see cref="Environment.OSVersion"/>'s platform is not <see cref="PlatformID.MacOSX"/> even on Mac OS X.
 /// This method returns <see cref="PlatformID.MacOSX"/> when the current process runs on Mac OS X.
 /// This method uses UNIX's uname command to check the operating system,
 /// so this method cannot check the OS correctly if the PATH environment variable is changed (will returns <see cref="PlatformID.Unix"/>).
 /// </remarks>
 /// <returns>The current platform.</returns>
 public static PlatformID GetPlatform()
 {
     return(PlatformUtility.GetPlatform());
 }