Esempio n. 1
0
        /// <summary>
        /// Tries to get the icu native binaries by searching the Runtime
        /// ID graph to find the first set of paths that have those binaries.
        /// </summary>
        /// <returns>Unique relative paths to the native assets; empty if none
        /// could be found.</returns>
        private static bool TryGetNativeAssetPaths(DependencyContext context, out string[] nativeAssetPaths)
        {
            var assetPaths = Enumerable.Empty <string>();

            if (context == null)
            {
                nativeAssetPaths = assetPaths.ToArray();
                return(false);
            }

            var defaultNativeAssets = context.GetDefaultNativeAssets().ToArray();

            // This goes through the runtime graph and tries to find icu native
            // asset paths matching that runtime.
            foreach (var runtime in context.RuntimeGraph)
            {
                var nativeAssets = context.GetRuntimeNativeAssets(runtime.Runtime);
                assetPaths = nativeAssets.Except(defaultNativeAssets).Where(assetPath => IcuBinaryRegex.IsMatch(assetPath));

                if (assetPaths.Any())
                {
                    break;
                }
            }

            nativeAssetPaths = assetPaths.ToArray();

            return(nativeAssetPaths.Length > 0);
        }