private static XamlNamespaceRegistry CreateXamlNamespaceRegistry() { var xamlNamespaceRegistry = new XamlNamespaceRegistry(); var forcedAssemblies = new[] { typeof(Control), typeof(Style) }.Select(t => t.GetTypeInfo().Assembly); foreach (var nsa in forcedAssemblies .Concat(PerspexLocator.Current.GetService <IPclPlatformWrapper>().GetLoadedAssemblies()) .Distinct() .SelectMany(asm => asm.GetCustomAttributes <XmlnsDefinitionAttribute>().Select(attr => new { asm, attr })) .GroupBy(entry => entry.attr.XmlNamespace)) { var def = XamlNamespace.Map(nsa.Key) .With(nsa.GroupBy(x => x.asm).Select( a => Route.Assembly(a.Key) .WithNamespaces(a.Select(entry => entry.attr.ClrNamespace).ToList()) )); xamlNamespaceRegistry.AddNamespace(def); } xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration(string.Empty, PerspexNs)); return(xamlNamespaceRegistry); }
public CleanWiringContextBuilder() { var xamlNamespaceRegistry = new XamlNamespaceRegistry(); TypeContext = new TypeContext(new XamlTypeRepository(xamlNamespaceRegistry), xamlNamespaceRegistry, new TypeFactory()); ContentPropertyProvider = new ContentPropertyProvider(); TypeConverterProvider = new TypeConverterProvider(); }
private static XamlNamespaceRegistry CreateXamlNamespaceRegistry() { var xamlNamespaceRegistry = new XamlNamespaceRegistry(); var windowType = typeof (Window); var textBlockType = typeof (System.Windows.Controls.TextBlock); var toggleButtonType = typeof (ToggleButton); var bindingType = typeof (BindingExtension); var rootNs = XamlNamespace.Map(WpfRootNs) .With( new[] { Route.Assembly(bindingType.Assembly).WithNamespaces( new[] {bindingType.Namespace}), Route.Assembly(windowType.Assembly).WithNamespaces( new[] { windowType.Namespace, textBlockType.Namespace, toggleButtonType.Namespace, }) }); foreach (var ns in new List<XamlNamespace> {rootNs}) { xamlNamespaceRegistry.AddNamespace(ns); } xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration("", WpfRootNs)); return xamlNamespaceRegistry; }
public void Initialize() { type = typeof(DummyClass); registry = new XamlNamespaceRegistry(); registry.RegisterPrefix(new PrefixRegistration("my", "target")); clrNamespace = $"clr-namespace:{type.Namespace};Assembly={type.GetTypeInfo().Assembly}"; registry.RegisterPrefix(new PrefixRegistration("clr", clrNamespace)); registry.AddNamespace( XamlNamespace.Map("target") .With(new[] { Route.Assembly(type.Assembly).WithNamespaces(new[] { type.Namespace }) })); }
private static XamlNamespaceRegistry CreateXamlNamespaceRegistry() { var xamlNamespaceRegistry = new XamlNamespaceRegistry(); var rootType = typeof(DummyClass); var anotherType = typeof(Foreigner); var definitionForRoot = XamlNamespace .Map("root") .With( new[] { Route.Assembly(rootType.GetTypeInfo().Assembly) .WithNamespaces( new[] { rootType.Namespace, typeof(Window).Namespace, }) }); var definitionForAnother = XamlNamespace .Map("another") .With( new[] { Route.Assembly(anotherType.GetTypeInfo().Assembly) .WithNamespaces(new[] { anotherType.Namespace }) }); foreach (var ns in new List <XamlNamespace> { definitionForRoot, definitionForAnother }) { xamlNamespaceRegistry.AddNamespace(ns); } xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration("", "root")); xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration("x", "another")); return(xamlNamespaceRegistry); }
private static XamlNamespaceRegistry CreateXamlNamespaceRegistry() { var xamlNamespaceRegistry = new XamlNamespaceRegistry(); var rootType = typeof(Control); var bindingType = typeof(BindingExtension); var templateType = typeof(XamlDataTemplate); var definitionForRoot = XamlNamespace .Map(PerspexNs) .With( new[] { Route.Assembly(rootType.GetTypeInfo().Assembly).WithNamespaces( new[] { rootType.Namespace }), Route.Assembly(bindingType.GetTypeInfo().Assembly).WithNamespaces( new[] { bindingType.Namespace, }), Route.Assembly(templateType.GetTypeInfo().Assembly).WithNamespaces( new[] { templateType.Namespace, }) }); foreach (var ns in new List <XamlNamespace> { definitionForRoot }) { xamlNamespaceRegistry.AddNamespace(ns); } xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration(string.Empty, PerspexNs)); return(xamlNamespaceRegistry); }
private static XamlNamespaceRegistry CreateXamlNamespaceRegistry() { var xamlNamespaceRegistry = new XamlNamespaceRegistry(); var windowType = typeof(Window); var textBlockType = typeof(System.Windows.Controls.TextBlock); var toggleButtonType = typeof(ToggleButton); var rotateTransformType = typeof(RotateTransform); var bindingType = typeof(BindingExtension); var rootNs = XamlNamespace.Map(WpfRootNs) .With( new[] { Route.Assembly(bindingType.Assembly).WithNamespaces( new[] { bindingType.Namespace }), Route.Assembly(rotateTransformType.Assembly).WithNamespaces( new[] { rotateTransformType.Namespace }), Route.Assembly(bindingType.Assembly).WithNamespaces( new[] { bindingType.Namespace }), Route.Assembly(windowType.Assembly).WithNamespaces( new[] { windowType.Namespace, textBlockType.Namespace, toggleButtonType.Namespace, }) }); foreach (var ns in new List <XamlNamespace> { rootNs }) { xamlNamespaceRegistry.AddNamespace(ns); } xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration("", WpfRootNs)); return(xamlNamespaceRegistry); }