示例#1
0
        public void When_Relative_Path_With_Leading_Slash_From_Root()
        {
            var withSlash    = XamlFilePathHelper.ResolveAbsoluteSource("App.xaml", "/App/Xaml/Test_Dictionary.xaml");
            var withoutSlash = XamlFilePathHelper.ResolveAbsoluteSource("App.xaml", "App/Xaml/Test_Dictionary.xaml");

            Assert.AreEqual(withoutSlash, withSlash);
        }
示例#2
0
        public static ResourceDictionary RetrieveDictionaryForSource(string source, string currentAbsolutePath)
        {
            if (source == null)
            {
                // Null is unusual but valid in this context
                return(new ResourceDictionary());
            }

            if (!XamlFilePathHelper.IsAbsolutePath(source))
            {
                // If we don't have an absolute path it must be a local resource reference
                source = XamlFilePathHelper.LocalResourcePrefix + XamlFilePathHelper.ResolveAbsoluteSource(currentAbsolutePath, source);
            }
            if (_registeredDictionariesByUri.TryGetValue(source, out var factory))
            {
                return(factory());
            }

            throw new InvalidOperationException($"Cannot locate resource from '{source}'");
        }