Page 1 of 1

Customizing UriConverter

Posted: 11 Oct 2019, 08:55
by nikobarli
Hi,

We currently place our XAMLs as follows, and access them using our custom XAML provider in our code.
<RootDir>/<DllName>/*.xaml
Now, from FirstDll/A.xaml, we want to load SecondDll/B.xaml as a resource as follows:
<ResourceDictionary Source="/SecondDll:component/B.xaml"/>
(We use this format so that Blend can also understand where to find the A.xaml)

However, the current Noesis implementation of UriConverter seems to just ignore the Packed URI's AssemblyReference path, and doesn't pass the information to our custom Xaml provider.

////////////////////////////////////////////////////////////////////////////////////////////////////
/// Converts a path in the XAML file to a valid resource path: Module/Package/ResourcePathFileName
///
/// We support the following path formats:
///     1. "RelativePath/resource.ext"
///     2. "/ReferencedAssembly;component/LocalPath/resource.ext"
///     3. "pack://application:,,,/ReferencedAssembly;component/LocalPath/resource.ext"
///
/// Example uses:
///
///     XAML File Path  : "Demos/DuckHunt/Xaml/MainWindow.xaml"
///     URI String      : "Resources.xaml"
///     Noesis Path     : "Demos/DuckHunt/Xaml/Resources.xaml"
///
///     XAML File Path  : "Demos/Browser/MainPage.xaml"
///     URI String      : "Theme/Style.xaml"
///     Noesis Path     : "Demos/Browser/Theme/Style.xaml"
///
///     XAML File Path  : "Demos/Browser/MainPage.xaml"
///     URI String      : "/Browser;component/Theme/Resources.xaml"
///     Noesis Path     : "Demos/Browser/Theme/Resources.xaml"
///
///     XAML File Path  : "Demos/Browser/MainPage.xaml"
///     URI String      : "pack://application:,,,/Browser;component/Theme/Resources.xaml"
///     Noesis Path     : "Demos/Browser/Theme/Resources.xaml"
///
////////////////////////////////////////////////////////////////////////////////////////////////////
struct UriConverter: public TypeConverter, public IXamlContextReceiver
{
...
}
Is there any workaround for this issue ?

Re: Customizing UriConverter

Posted: 14 Oct 2019, 10:25
by sfernandez
Our curretn UriConverter implementation is removing all packed Uri prefixes and passing only the path part to the providers.
In order to fully support what you are explaining we probably need to do changes to our providers too.
Could you please open a ticket in our bugtracker to discuss about this?

In the meantime I can think of having your custom provider to be able to find resources in more than one root, so you can configure it to look for files under FirtstDll/ and SecondDll/ folders, and that will allow the provider to find A.xaml and B.xaml. This is not the right solution though, because it won't work when using same file names in different folders, but maybe this is not your case now.

Re: Customizing UriConverter

Posted: 15 Oct 2019, 03:36
by nikobarli
Thanks. I added a new issue here: https://www.noesisengine.com/bugs/view.php?id=1569

I will discuss with the team on how to workaround this for the moment.

Re: Customizing UriConverter

Posted: 16 Oct 2019, 12:35
by sfernandez
Thanks for the report.