コード例 #1
0
        /// <summary>
        /// Obtains the path to an NDK file
        /// </summary>
        /// <param name="registryValueName">[Required] registry value to check first</param>
        /// <param name="ndkRoot">[Required] Path to the NDK</param>
        /// <param name="possiblePaths">[Required] IEnumerable of possible paths with in the NDK where the file may be found</param>
        /// <param name="matchedPath">[Optional] If the returned path comes from an NDK location, returns the source object</param>
        /// <returns>[Required] value to use, file path will exist</returns>
        private static string GetNDKFilePath(string registryValueName, string ndkRoot, IEnumerable <INDKFilePath> possiblePaths, out INDKFilePath matchedPath)
        {
            matchedPath = null;

            if (string.IsNullOrEmpty(ndkRoot))
            {
                throw new ArgumentNullException("ndkRoot");
            }

            if (possiblePaths == null || !possiblePaths.Any())
            {
                throw new ArgumentOutOfRangeException("possiblePaths");
            }

            string value = TryGetRegistryValue(RegistryRoot.Value + @"\Debugger", registryValueName, RegistryView.Default);

            if (value != null)
            {
                if (File.Exists(value))
                {
                    return(value);
                }

                // fall through to throw an exception
            }
            else
            {
                foreach (INDKFilePath pathObject in possiblePaths)
                {
                    value = pathObject.TryResolve(ndkRoot);
                    if (value != null)
                    {
                        matchedPath = pathObject;
                        return(value);
                    }
                }

                value = possiblePaths.First().GetSearchPathDescription(ndkRoot);
                // fall through to throw an exception
            }

            ThrowExternalFileNotFoundException(value, LauncherResources.ProductName_NDK);
            return(null); // unreachable code
        }
コード例 #2
0
ファイル: InstallPaths.cs プロジェクト: wesrupert/MIEngine
        /// <summary>
        /// Obtains the path to an NDK file
        /// </summary>
        /// <param name="registryValueName">[Required] registry value to check first</param>
        /// <param name="ndkRoot">[Required] Path to the NDK</param>
        /// <param name="possiblePaths">[Required] IEnumerable of possible paths with in the NDK where the file may be found</param>
        /// <param name="matchedPath">[Optional] If the returned path comes from an NDK location, returns the source object</param>
        /// <returns>[Required] value to use, file path will exist</returns>
        private static string GetNDKFilePath(string registryValueName, string ndkRoot, IEnumerable<INDKFilePath> possiblePaths, out INDKFilePath matchedPath)
        {
            matchedPath = null;

            if (string.IsNullOrEmpty(ndkRoot))
            {
                throw new ArgumentNullException("ndkRoot");
            }

            if (possiblePaths == null || !possiblePaths.Any())
            {
                throw new ArgumentOutOfRangeException("possiblePaths");
            }

            string value = TryGetRegistryValue(RegistryRoot.Value + @"\Debugger", registryValueName, RegistryView.Default);
            if (value != null)
            {
                if (File.Exists(value))
                {
                    return value;
                }

                // fall through to throw an exception
            }
            else
            {
                foreach (INDKFilePath pathObject in possiblePaths)
                {
                    value = pathObject.TryResolve(ndkRoot);
                    if (value != null)
                    {
                        matchedPath = pathObject;
                        return value;
                    }
                }

                value = possiblePaths.First().GetSearchPathDescription(ndkRoot);
                // fall through to throw an exception
            }

            ThrowExternalFileNotFoundException(value, LauncherResources.ProductName_NDK);
            return null; // unreachable code
        }