示例#1
0
        public void PackageUpgrade_PackageIsNotInstalled()
        {
            NugetPackage installedPackage = null;
            NugetPackage newPackage       = new NugetPackage(Path.Combine(sourcePath, bigFilesPackages));

            EmbeddedResourceExtensions.CopyEmbeddedResource(namespaceForEmbbededResources, bigFilesPackages, sourcePath);

            Stopwatch stopwatch = Stopwatch.StartNew();

            newPackage.Upgrade(NullLogger.Instance, new DeploymentComponentFactory(new HoneyInstallLocation(), new PathInstallLocation(targetPath)), installedPackage);
            stopwatch.Stop();
            Console.WriteLine($"Install takes {stopwatch.ElapsedMilliseconds } ms.");

            Assert.That(File.Exists(Path.Combine(targetPath, "dhbx2w3k.3tc")), Is.True);
        }
示例#2
0
        internal static UIFont EmbeddedFont(string resourceId, nfloat size, Assembly assembly = null)
        {
            if (resourceId == "STIXGeneral")
            {
                resourceId = "Forms9Patch.Resources.Fonts.STIXGeneral.otf";
            }

            lock (_loadFontLock)
            {
                if (_embeddedResourceFonts.ContainsKey(resourceId))
                {
                    string family = _embeddedResourceFonts[resourceId];
                    return(UIFont.FromName(family, size));
                }
                if (EmbeddedResourceExtensions.FindAssemblyForResource(resourceId, assembly) is Assembly resourceAssembly &&
                    LoadAndRegisterEmbeddedFont(resourceId, size, resourceAssembly) is UIFont uIFont)
                {
                    return(uIFont);
                }
            }
            return(null);
        }
示例#3
0
        public void PackageUpgrade_PackageIsChanged()
        {
            NugetPackage installedPackage = null;
            NugetPackage newPackage       = new NugetPackage(Path.Combine(sourcePath, bigFilesPackages));

            EmbeddedResourceExtensions.CopyEmbeddedResource(namespaceForEmbbededResources, bigFilesPackages, sourcePath);
            EmbeddedResourceExtensions.CopyEmbeddedResource(namespaceForEmbbededResources, bigFilesPackages2, sourcePath);

            newPackage.Upgrade(NullLogger.Instance, new DeploymentComponentFactory(new HoneyInstallLocation(), new PathInstallLocation(targetPath)), installedPackage);
            installedPackage = newPackage;

            NugetPackage newPackage2 = new NugetPackage(Path.Combine(sourcePath, bigFilesPackages2));

            Console.WriteLine("Begin of performance calculation");
            Stopwatch stopwatch = Stopwatch.StartNew();

            newPackage2.Upgrade(NullLogger.Instance, new DeploymentComponentFactory(new HoneyInstallLocation(), new PathInstallLocation(targetPath)), installedPackage);
            stopwatch.Stop();
            Console.WriteLine($"Upgrade with one file removed and one added takes {stopwatch.ElapsedMilliseconds } ms.");

            Assert.That(File.Exists(Path.Combine(targetPath, "dhbx2w3k.3tc")), Is.False);
            Assert.That(File.Exists(Path.Combine(targetPath, "dhbx2w3k.4tc")), Is.True);
        }
示例#4
0
        /*
         * {
         *  get
         *  {
         *      if (_serif != null)
         *          return _serif;
         *      _serif = TrySystemFont("serif");
         *      if (_serif != null)
         *          return _serif;
         *      _serif = TrySystemFont("Droid Serif");
         *      if (_serif != null)
         *          return _serif;
         *      return _serif;
         *  }
         * }
         */

        public static Typeface TypefaceForFontFamily(string fontFamilys, Assembly assembly = null)
        {
            if (string.IsNullOrWhiteSpace(fontFamilys))
            {
                return(null);
            }
            var fontFamiliesList = fontFamilys.Split(',');

            if (fontFamiliesList != null && fontFamiliesList.Any())
            {
                foreach (var fontFamilyString in fontFamiliesList)
                {
                    var fontFamily = fontFamilyString?.Trim().Trim(';');
                    if (string.IsNullOrWhiteSpace(fontFamily))
                    {
                        continue;
                    }

                    Typeface result;

                    if (fontFamily.ToLower() == "monospace" && MonoSpace != null)
                    {
                        return(MonoSpace);
                    }
                    if (fontFamily.ToLower() == "serif" && Serif != null)
                    {
                        return(Serif);
                    }
                    if (fontFamily.ToLower() == "sans-serif" && DroidSans != null)
                    {
                        return(DroidSans);
                    }

                    result = TrySystemFont(fontFamily);
                    if (result != null)
                    {
                        return(result);
                    }

                    if (DroidSans != null && (fontFamily.ToLower() == "arial" || fontFamily.ToLower() == "helvetica"))
                    {
                        return(DroidSans);
                    }

                    if (fontFamily.Contains(".Resources."))
                    {
                        // it's an Embedded Resource
                        if (!fontFamily.EndsWith(".ttf", StringComparison.OrdinalIgnoreCase) && !fontFamily.EndsWith(".otf", StringComparison.OrdinalIgnoreCase))
                        {
                            throw new InvalidObjectException("Embedded Font file names must end with \".ttf\" or \".otf\".");
                        }
                        // what is the assembly?

                        /*
                         * var assemblyName = fontFamily.Substring(0, fontFamily.IndexOf(".Resources.Fonts."));
                         *
                         * //var assembly = System.Reflection.Assembly.Load (assemblyName);
                         * var assembly = ReflectionExtensions.GetAssemblyByName(assemblyName) ?? Forms9Patch.Droid.Settings.ApplicationAssembly;
                         *
                         * if (assembly == null)
                         * {
                         *  // try using the current application assembly instead (as is the case with Shared Applications)
                         *  assembly = ReflectionExtensions.GetAssemblyByName(assemblyName + ".Droid");
                         *  ///System.Console.WriteLine ("Assembly for FontFamily \"" + fontFamily + "\" not found.");
                         *  //return null;
                         * }
                         */
                        // move it to the Application's CustomFontDirRoot
                        if (EmbeddedResourceExtensions.FindAssemblyForResource(fontFamily, assembly) is Assembly asm)
                        {
                            return(LoadAndRegisterEmbeddedFont(fontFamily, asm));
                        }
                    }
                }
            }
            return(null);
        }
 public string ExtractProtobufModel(string embeddedResourceName)
 {
     CreateTestCaseDataPath();
     EmbeddedResourceExtensions.CopyEmbeddedResource(namespaceForEmbbededResources, embeddedResourceName, testCaseDataPath);
     return(Path.Combine(testCaseDataPath, embeddedResourceName));
 }