Example #1
0
 public void ComparePackUriTest()
 {
     Assert.AreEqual(0, PackUriHelper.ComparePackUri(null, null), "#1");
     Assert.IsTrue(PackUriHelper.ComparePackUri(a, null) > 0, "#2");
     Assert.AreEqual(0, PackUriHelper.ComparePackUri(a, a), "#3");
     Assert.IsTrue(PackUriHelper.ComparePackUri(a, b) < 0, "#4");
 }
Example #2
0
        internal void UriHitHandler(int node, Uri uri)
        {
            if (_uniqueUriRef != null)
            {
                if (_uniqueUriRef.Contains(uri))
                {
                    if ((int)_uniqueUriRef[uri] != node)
                    {
                        throw new FileFormatException(SR.Get(SRID.XpsValidatingLoaderDuplicateReference));
                    }
                }
                else
                {
                    _uniqueUriRef.Add(uri, node);
                }
            }
            Hashtable validResources = _validResources.Peek();

            if (validResources != null)
            {
                if (!validResources.ContainsKey(uri))
                {
                    // The hashtable is case sensitive, packuris are not, so if we do not find in hashtable,
                    // do true comparison and add when found for next time...
                    bool found = false;
                    foreach (Uri resUri in validResources.Keys)
                    {
                        if (PackUriHelper.ComparePackUri(resUri, uri) == 0)
                        {
                            validResources.Add(uri, validResources[resUri]);
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        throw new FileFormatException(SR.Get(SRID.XpsValidatingLoaderUnlistedResource));
                    }
                }
                if (!(bool)validResources[uri])
                {
                    throw new FileFormatException(SR.Get(SRID.XpsValidatingLoaderUnsupportedMimeType));
                }
            }
        }
Example #3
0
        // Token: 0x06003F7A RID: 16250 RVA: 0x00124974 File Offset: 0x00122B74
        internal void UriHitHandler(int node, Uri uri)
        {
            if (this._uniqueUriRef != null)
            {
                if (this._uniqueUriRef.Contains(uri))
                {
                    if ((int)this._uniqueUriRef[uri] != node)
                    {
                        throw new FileFormatException(SR.Get("XpsValidatingLoaderDuplicateReference"));
                    }
                }
                else
                {
                    this._uniqueUriRef.Add(uri, node);
                }
            }
            Hashtable hashtable = XpsValidatingLoader._validResources.Peek();

            if (hashtable != null)
            {
                if (!hashtable.ContainsKey(uri))
                {
                    bool flag = false;
                    foreach (object obj in hashtable.Keys)
                    {
                        Uri uri2 = (Uri)obj;
                        if (PackUriHelper.ComparePackUri(uri2, uri) == 0)
                        {
                            hashtable.Add(uri, hashtable[uri2]);
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        throw new FileFormatException(SR.Get("XpsValidatingLoaderUnlistedResource"));
                    }
                }
                if (!(bool)hashtable[uri])
                {
                    throw new FileFormatException(SR.Get("XpsValidatingLoaderUnsupportedMimeType"));
                }
            }
        }
Example #4
0
        public static void SwitchMetro()
        {
            var resources = Application.Current.Resources;


            var insertTo = resources.MergedDictionaries.Count - resoursesAfterThemes;

            foreach (var th in MahThemes)
            {
                var oldThemeResource = resources.MergedDictionaries.FirstOrDefault(d =>
                                                                                   PackUriHelper.ComparePackUri(d.Source, th.Resources.Source) == 0);
                if (oldThemeResource == null)
                {
                    resources.MergedDictionaries.Insert(insertTo, th.Resources);
                }
                else
                {
                    resources.MergedDictionaries.Remove(oldThemeResource);
                }
            }
        }
Example #5
0
 public void NonPackUriCompareRelativeTest()
 {
     PackUriHelper.ComparePackUri(new Uri("wtest.com", UriKind.Relative), a);
 }
Example #6
0
 public void NonPackUriCompareTest()
 {
     PackUriHelper.ComparePackUri(new Uri("http://wtest.com"), a);
 }
Example #7
0
        public void CompareInvalidTest()
        {
            Uri a = new Uri("pack://url1");

            PackUriHelper.ComparePackUri(a, a);
        }
Example #8
0
        public static void SwitchFont(string newSizeName)
        {
            var resources = Application.Current.Resources;

            int insertTo    = 0; // in case no FontResources in App.xaml
            var newAppTheme = FontThemes.FirstOrDefault(x => x.Name == newSizeName);

            // first font res
            var oldThemeResource = resources.MergedDictionaries.FirstOrDefault(d =>
                                                                               FontThemes.Any(x => PackUriHelper.ComparePackUri(d.Source, x.Resources.Source) == 0));

            if (oldThemeResource != null)
            {
                insertTo = resources.MergedDictionaries.IndexOf(oldThemeResource);
                resources.MergedDictionaries.Remove(oldThemeResource);
            }
            if (newAppTheme != null)
            {
                resources.MergedDictionaries.Insert(insertTo, newAppTheme.Resources);
            }
        }