public void DynamicResourceExtensionBaseTest() { string text = @" <StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:test='clr-namespace:Granular.Presentation.Tests;assembly=Granular.Presentation.Tests' x:Name='panel1'> <StackPanel.Resources> <test:ResourceTestObject x:Key='key1' Value='1'/> </StackPanel.Resources> <FrameworkElement x:Name='child1' test:ResourceTestObject.TestValue='{DynamicResource key1}'/> <StackPanel x:Name='panel2'> <FrameworkElement x:Name='child2' test:ResourceTestObject.TestValue='{DynamicResource key1}'/> </StackPanel> </StackPanel>"; FrameworkElement panel1 = XamlLoader.Load(XamlParser.Parse(text)) as FrameworkElement; FrameworkElement panel2 = NameScope.GetNameScope(panel1).FindName("panel2") as FrameworkElement; FrameworkElement child1 = NameScope.GetNameScope(panel1).FindName("child1") as FrameworkElement; FrameworkElement child2 = NameScope.GetNameScope(panel1).FindName("child2") as FrameworkElement; Assert.AreEqual(1, (child1.GetValue(ResourceTestObject.TestValueProperty) as ResourceTestObject).Value); Assert.AreEqual(1, (child2.GetValue(ResourceTestObject.TestValueProperty) as ResourceTestObject).Value); panel2.Resources = new ResourceDictionary(); panel2.Resources.Add("key1", new ResourceTestObject { Value = 2 }); Assert.AreEqual(1, (child1.GetValue(ResourceTestObject.TestValueProperty) as ResourceTestObject).Value); Assert.AreEqual(2, (child2.GetValue(ResourceTestObject.TestValueProperty) as ResourceTestObject).Value); }
public void XamlLoadKeyElementTest() { string text = @" <ResourceDictionary xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests'> <test:LoaderTestElement Value1='1' Value2='2'> <x:Key> <test:LoaderTestElement Value1='3' Value2='4'/> </x:Key> </test:LoaderTestElement> </ResourceDictionary>"; XamlElement rootElement = XamlParser.Parse(text); ResourceDictionary dictionary = XamlLoader.Load(rootElement) as ResourceDictionary; Assert.IsNotNull(dictionary); Assert.AreEqual(1, dictionary.Count); LoaderTestElement key = (LoaderTestElement)dictionary.Keys.First(); LoaderTestElement value = (LoaderTestElement)dictionary[key]; Assert.AreEqual(1, value.Value1); Assert.AreEqual(2, value.Value2); Assert.AreEqual(3, key.Value1); Assert.AreEqual(4, key.Value2); }
public void Int() { var actual = XamlLoader.Load(Dummy.Int); Assert.IsInstanceOfType(actual, typeof(int)); Assert.AreEqual(123, actual); }
public void DockPanelLayoutParseTest() { string text = @" <DockPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <FrameworkElement Width='100' DockPanel.Dock='Left'/> <FrameworkElement Height='100' DockPanel.Dock='Top'/> <FrameworkElement Width='100' DockPanel.Dock='Right'/> <FrameworkElement Height='100' DockPanel.Dock='Bottom'/> <FrameworkElement/> </DockPanel>"; XamlElement rootElement = XamlParser.Parse(text); DockPanel panel = XamlLoader.Load(rootElement) as DockPanel; panel.Measure(new Size(1000, 1000)); Assert.AreEqual(new Size(200, 200), panel.DesiredSize); panel.Arrange(new Rect(1000, 1000)); Assert.AreEqual(new Size(1000, 1000), panel.VisualSize); Assert.AreEqual(new Size(100, 1000), panel.Children[0].VisualSize); Assert.AreEqual(new Size(900, 100), panel.Children[1].VisualSize); Assert.AreEqual(new Size(100, 900), panel.Children[2].VisualSize); Assert.AreEqual(new Size(800, 100), panel.Children[3].VisualSize); Assert.AreEqual(new Size(800, 800), panel.Children[4].VisualSize); Assert.AreEqual(new Point(0, 0), panel.Children[0].VisualOffset); Assert.AreEqual(new Point(100, 0), panel.Children[1].VisualOffset); Assert.AreEqual(new Point(900, 100), panel.Children[2].VisualOffset); Assert.AreEqual(new Point(100, 900), panel.Children[3].VisualOffset); Assert.AreEqual(new Point(100, 100), panel.Children[4].VisualOffset); }
public void StringWithWhitespace() { var actual = XamlLoader.Load(Dummy.StringWithWhitespace); Assert.IsInstanceOfType(actual, typeof(string)); Assert.AreEqual("Text", actual); }
public void StringAsProperty() { var actual = XamlLoader.Load(Dummy.StringAsProperty); Assert.IsInstanceOfType(actual, typeof(DummyClass)); Assert.AreEqual("Text", ((DummyClass)actual).SampleProperty); }
public void TemplatedParentSourceObserverTest() { string text = @" <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <FrameworkElement x:Name='child'/> </ControlTemplate>"; ControlTemplate template = XamlLoader.Load(XamlParser.Parse(text)) as ControlTemplate; Control control = new Control(); control.Template = template; control.ApplyTemplate(); FrameworkElement child = NameScope.GetTemplateNameScope(control).FindName("child") as FrameworkElement; Freezable value = new Freezable(); TemplatedParentSourceObserver observer = new TemplatedParentSourceObserver(value); Assert.AreEqual(ObservableValue.UnsetValue, observer.Value); child.SetValue(ValueProperty, value); Assert.AreEqual(control, observer.Value); child.SetValue(ValueProperty, null); Assert.AreEqual(ObservableValue.UnsetValue, observer.Value); }
public void StackPanelLayoutParseTest() { string text = @" <StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <FrameworkElement Height='100'/> <FrameworkElement Height='100'/> <FrameworkElement Height='100'/> </StackPanel>"; XamlElement rootElement = XamlParser.Parse(text); StackPanel panel = XamlLoader.Load(rootElement) as StackPanel; panel.Measure(new Size(1000, 1000)); Assert.AreEqual(new Size(0, 300), panel.DesiredSize); panel.Arrange(new Rect(1000, 300)); Assert.AreEqual(new Size(1000, 300), panel.VisualSize); Assert.AreEqual(new Size(1000, 100), panel.Children[0].VisualSize); Assert.AreEqual(new Size(1000, 100), panel.Children[1].VisualSize); Assert.AreEqual(new Size(1000, 100), panel.Children[2].VisualSize); Assert.AreEqual(new Point(0, 0), panel.Children[0].VisualOffset); Assert.AreEqual(new Point(0, 100), panel.Children[1].VisualOffset); Assert.AreEqual(new Point(0, 200), panel.Children[2].VisualOffset); }
public void StaticResourceExtensionBaseTest() { string text = @" <StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:test='clr-namespace:Granular.Presentation.Tests;assembly=Granular.Presentation.Tests' x:Name='panel1'> <StackPanel.Resources> <test:ResourceTestObject x:Key='key1' Value='1'/> <test:ResourceTestObject x:Key='key2' Child='{StaticResource key1}'/> </StackPanel.Resources> <FrameworkElement x:Name='child1' test:ResourceTestObject.TestValue='{StaticResource key1}'/> <FrameworkElement x:Name='child2' test:ResourceTestObject.TestValue='{StaticResource key2}'/> </StackPanel>"; FrameworkElement panel1 = XamlLoader.Load(XamlParser.Parse(text)) as FrameworkElement; FrameworkElement child1 = NameScope.GetNameScope(panel1).FindName("child1") as FrameworkElement; FrameworkElement child2 = NameScope.GetNameScope(panel1).FindName("child2") as FrameworkElement; ResourceTestObject testValue1 = (ResourceTestObject)child1.GetValue(ResourceTestObject.TestValueProperty); ResourceTestObject testValue2 = (ResourceTestObject)child2.GetValue(ResourceTestObject.TestValueProperty); Assert.AreEqual(1, testValue1.Value); Assert.AreEqual(testValue1, testValue2.Child); panel1.Resources.Clear(); Assert.AreEqual(1, testValue1.Value); Assert.AreEqual(testValue1, testValue2.Child); }
public void XamlLoadCollectionReplacePropertyTest() { string text = @" <test:LoaderTestCollectionElement xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests'> <test:LoaderTestCollectionElement.Items> <test:LoaderTestCollection> <test:LoaderTestElement Value1='1'/> <test:LoaderTestElement Value1='2'/> <test:LoaderTestElement Value1='3'/> </test:LoaderTestCollection> </test:LoaderTestCollectionElement.Items> </test:LoaderTestCollectionElement>"; XamlElement rootElement = XamlParser.Parse(text); object root1 = XamlLoader.Load(rootElement); Assert.IsTrue(root1 is LoaderTestCollectionElement); Assert.AreEqual(3, (root1 as LoaderTestCollectionElement).Items.Count); Assert.IsTrue((root1 as LoaderTestCollectionElement).Items[0] is LoaderTestElement); Assert.IsTrue((root1 as LoaderTestCollectionElement).Items[1] is LoaderTestElement); Assert.IsTrue((root1 as LoaderTestCollectionElement).Items[2] is LoaderTestElement); Assert.AreEqual(1, ((root1 as LoaderTestCollectionElement).Items[0] as LoaderTestElement).Value1); Assert.AreEqual(2, ((root1 as LoaderTestCollectionElement).Items[1] as LoaderTestElement).Value1); Assert.AreEqual(3, ((root1 as LoaderTestCollectionElement).Items[2] as LoaderTestElement).Value1); }
public void TemplateAndStyleFindDefaultTest() { Style style = new Style { TargetType = typeof(Control) }; style.Setters.Add(new Setter { Property = new DependencyPropertyPathElement(FrameworkElement.WidthProperty), Value = 100 }); string text = @" <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' TargetType='{x:Type Control}'> <FrameworkElement/> </ControlTemplate>"; ControlTemplate controlTemplate = XamlLoader.Load(XamlParser.Parse(text)) as ControlTemplate; ResourceDictionary resources = new ResourceDictionary(); resources.Add(new StyleKey(typeof(Control)), style); resources.Add(new TemplateKey(typeof(Control)), controlTemplate); Control control = new Control(); control.Resources = resources; Assert.AreEqual(style, control.Style); Assert.AreEqual(controlTemplate, control.Template); }
public Theme(string xamlFile) : this() { if (string.IsNullOrEmpty(xamlFile)) { throw new ArgumentNullException("The xaml file path cannot be null or empty string", nameof(xamlFile)); } try { using (var reader = XmlReader.Create(xamlFile)) { XamlLoader.Load(this, reader); } } catch (global::System.IO.IOException e) { Tizen.Log.Info("NUI", $"Could not load \"{xamlFile}\".\n"); throw e; } catch (Exception e) { Tizen.Log.Info("NUI", $"Could not parse \"{xamlFile}\".\n"); Tizen.Log.Info("NUI", "Make sure the all used assemblies (e.g. Tizen.NUI.Components) are included in the application project.\n"); Tizen.Log.Info("NUI", "Make sure the type and namespace are correct.\n"); throw e; } }
public void XamlLoadEventsTest() { string text = @" <test:LoaderTestElement xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests'> <test:LoaderTestElement x:Name='element1' Action1='Handler1' Action2='Handler2'/> <test:LoaderTestElement x:Name='element2' test:LoaderTestElement.Action1='Handler3' test:LoaderTestElement.Action2='Handler4'/> </test:LoaderTestElement>"; LoaderTestTopElement root = new LoaderTestTopElement(); XamlLoader.Load(root, XamlParser.Parse(text)); LoaderTestElement element1 = NameScope.GetNameScope(root).FindName("element1") as LoaderTestElement; LoaderTestElement element2 = NameScope.GetNameScope(root).FindName("element2") as LoaderTestElement; element1.RaiseAction1(); element1.RaiseAction2(); element2.RaiseAction1(); element2.RaiseAction1(); element2.RaiseAction2(); element2.RaiseAction2(); Assert.IsTrue(root != null); Assert.AreEqual(1, root.Handler1Calls); //Assert.AreEqual(1, root.Handler2Calls); Assert.AreEqual(2, root.Handler3Calls); //Assert.AreEqual(2, root.Handler4Calls); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var xamlLoader = new XamlLoader(new[] { Assembly.Load(new AssemblyName("OmniGui")), Assembly.Load(new AssemblyName("OmniGui.Xaml")), Assembly.Load(new AssemblyName("AndroidApp")), Assembly.Load(new AssemblyName("ViewModels")), }); string xaml; using (var r = new StreamReader(Assets.Open("layout.xaml"))) { xaml = r.ReadToEnd(); } var layout = (Layout)xamlLoader.Load(xaml).Instance; var omniGuiView = new OmniGuiView(ApplicationContext, layout); Platform.Current = new AndroidPlatform(omniGuiView); SetContentView(omniGuiView); }
public void DeferredValueSharedTest() { string text = @" <test:DeferredDictionary xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests'> <test:TestDictionaryValue x:Key='key1'/> <test:TestDictionaryValue x:Key='key2' x:Shared='false'/> </test:DeferredDictionary>"; DeferredDictionary dictionary = (DeferredDictionary)XamlLoader.Load(XamlParser.Parse(text)); Assert.IsTrue(dictionary.ContainsKey("key1")); Assert.IsTrue(dictionary.ContainsKey("key2")); ValueProvider valueProvider1 = dictionary["key1"] as ValueProvider; ValueProvider valueProvider2 = dictionary["key2"] as ValueProvider; Assert.IsNotNull(valueProvider1); Assert.IsNotNull(valueProvider2); TestDictionaryValue value1 = valueProvider1.ProvideValue() as TestDictionaryValue; TestDictionaryValue value2 = valueProvider2.ProvideValue() as TestDictionaryValue; Assert.IsNotNull(value1); Assert.IsNotNull(value2); TestDictionaryValue value1a = valueProvider1.ProvideValue() as TestDictionaryValue; TestDictionaryValue value2a = valueProvider2.ProvideValue() as TestDictionaryValue; Assert.IsTrue(ReferenceEquals(value1, value1a)); Assert.IsFalse(ReferenceEquals(value2, value2a)); }
public void CanvasLayoutParseTest() { string text = @" <Canvas xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <FrameworkElement Width='200' Height='100' Canvas.Left='20' Canvas.Top='10'/> <FrameworkElement Width='200' Height='100' Canvas.Right='20' Canvas.Top='10'/> <FrameworkElement Width='200' Height='100' Canvas.Right='20' Canvas.Bottom='10'/> <FrameworkElement Width='200' Height='100' Canvas.Left='20' Canvas.Bottom='10'/> </Canvas>"; XamlElement rootElement = XamlParser.Parse(text); Canvas panel = XamlLoader.Load(rootElement) as Canvas; panel.Measure(new Size(1000, 1000)); Assert.AreEqual(Size.Zero, panel.DesiredSize); panel.Arrange(new Rect(1000, 1000)); Assert.AreEqual(new Size(1000, 1000), panel.VisualSize); Assert.AreEqual(new Size(200, 100), panel.Children[0].VisualSize); Assert.AreEqual(new Size(200, 100), panel.Children[1].VisualSize); Assert.AreEqual(new Size(200, 100), panel.Children[2].VisualSize); Assert.AreEqual(new Size(200, 100), panel.Children[3].VisualSize); Assert.AreEqual(new Point(20, 10), panel.Children[0].VisualOffset); Assert.AreEqual(new Point(780, 10), panel.Children[1].VisualOffset); Assert.AreEqual(new Point(780, 890), panel.Children[2].VisualOffset); Assert.AreEqual(new Point(20, 890), panel.Children[3].VisualOffset); }
public void BindingExtensionRelativeSourceTemplatedParentTest() { string text = @" <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' x:Name='root'> <FrameworkElement x:Name='child' Width='{Binding Height, RelativeSource={RelativeSource TemplatedParent}}'/> </ControlTemplate>"; ControlTemplate template = XamlLoader.Load(XamlParser.Parse(text)) as ControlTemplate; Control control = new Control(); control.Template = template; control.ApplyTemplate(); FrameworkElement child = NameScope.GetTemplateNameScope(control).FindName("child") as FrameworkElement; Assert.AreEqual(control, child.TemplatedParent); control.Height = 100; Assert.AreEqual(100, child.Width); control.ClearValue(FrameworkElement.HeightProperty); child.SetValue(FrameworkElement.WidthProperty, 200.0, BaseValueSource.ParentTemplate); Assert.AreEqual(200, control.Height); }
public void CompileText() { try { if (mainViewModel.TextContent.IsNullOrWhiteSpace()) { contentPresenter.Child = null; } else { FrameworkElement child = (FrameworkElement)XamlLoader.Load(XamlParser.Parse(mainViewModel.TextContent, new Uri("pack://application:,,,/GranularPad;component/"))); child.DataContext = null; contentPresenter.Child = child; } HideErrorMessage(); HideContentPresenterOverlay(); } catch (Exception e) { errorTextBlock.Text = e.Message; errorPosition = ParseErrorPosition(e.Message); ShowErrorMessage(); ShowContentPresenterOverlay(); } }
public void ItemsControlMeasureTest() { string text = @" <ItemsControl xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <ItemsControl.Template> <ControlTemplate> <ItemsPresenter ItemContainerGenerator='{TemplateBinding ItemsControl.ItemContainerGenerator}' Template='{TemplateBinding ItemsControl.ItemsPanel}'/> </ControlTemplate> </ItemsControl.Template> </ItemsControl>"; ItemsControl itemsControl = XamlLoader.Load(XamlParser.Parse(text)) as ItemsControl; itemsControl.Items.Add(new Border { Width = 100, Height = 50 }); itemsControl.Items.Add(new Border { Width = 100, Height = 50 }); itemsControl.Items.Add(new Border { Width = 100, Height = 50 }); itemsControl.Measure(Size.Infinity); Assert.AreEqual(new Size(100, 150), itemsControl.DesiredSize); }
public override void FinishInitialization(IParserContext context) { base.FinishInitialization(context); if (!string.IsNullOrEmpty(_source)) { ISkinResourceBundle resourceBundle; string sourceFilePath = SkinContext.SkinResources.GetResourceFilePath(_source, true, out resourceBundle); if (sourceFilePath == null) { throw new XamlLoadException("Could not open ResourceDictionary source file '{0}' (evaluated path is '{1}')", _source, sourceFilePath); } object obj = XamlLoader.Load(sourceFilePath, resourceBundle, (IModelLoader)context.GetContextVariable(typeof(IModelLoader))); ResourceDictionary mergeDict = obj as ResourceDictionary; if (mergeDict == null) { if (obj != null) { TryDispose(ref obj); } throw new Exception(String.Format("Resource '{0}' doesn't contain a resource dictionary", _source)); } TakeOver(mergeDict, false, true); } if (_mergedDictionaries != null && _mergedDictionaries.Count > 0) { foreach (ResourceDictionary dictionary in _mergedDictionaries) { TakeOver(dictionary, false, true); } _mergedDictionaries.Clear(); } FireChanged(); }
public void XamlLoadContentTest() { string text = "<test:LoaderTestContentElement xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests'>1</test:LoaderTestContentElement>"; object element1 = XamlLoader.Load(XamlParser.Parse(text)); Assert.IsTrue(element1 is LoaderTestContentElement); Assert.AreEqual(1, (element1 as LoaderTestContentElement).Content1); }
public void RegisterOneChildInNameScope() { WiringContext.EnableNameScope <DummyClass>(); var actualInstance = XamlLoader.Load(Dummy.ChildInNameScope); var childInScope = ((DummyObject)actualInstance).Find("MyObject"); Assert.IsInstanceOfType(childInScope, typeof(ChildClass)); }
public void KeyDirective() { var actual = XamlLoader.Load(Dummy.KeyDirective); Assert.IsInstanceOfType(actual, typeof(DummyClass)); var dictionary = (IDictionary)((DummyClass)actual).Resources; Assert.IsTrue(dictionary.Count > 0); }
public void DirectiveInSpecialNamespaceThatIsNotX() { var actual = XamlLoader.Load(Dummy.KeyDirectiveNotInX); Assert.IsInstanceOfType(actual, typeof(DummyClass)); var dictionary = (IDictionary)((DummyClass)actual).Resources; Assert.IsTrue(dictionary.Count > 0); }
public void BindingExtensionRelativeSourceSelfTest() { string text = @"<TextBlock xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Name='textBlock' Text=""{Binding RelativeSource={RelativeSource Self}, Path=Name, StringFormat='Self name is {0}'}""/>"; TextBlock textBlock = XamlLoader.Load(XamlParser.Parse(text)) as TextBlock; Assert.AreEqual("Self name is textBlock", textBlock.Text); }
public void AttachedProperty() { var actualInstance = XamlLoader.Load(Dummy.AttachedProperty); Assert.IsInstanceOfType(actualInstance, typeof(DummyClass), "The retrieved instance should be of type DummyClass"); var dummyClass = actualInstance as DummyClass; Assert.IsNotNull(dummyClass); Assert.AreEqual(Container.GetProperty(dummyClass), "Value"); }
public void Ignorable() { var actualInstance = XamlLoader.Load(Dummy.Ignorable); Assert.IsInstanceOfType(actualInstance, typeof(DummyClass), "The retrieved instance should be of type DummyClass"); var dummyClass = actualInstance as DummyClass; Assert.IsNotNull(dummyClass); Assert.AreEqual("Property!", dummyClass.SampleProperty); }
public void ReadInstanceWithChild() { var actualInstance = XamlLoader.Load(Dummy.InstanceWithChild); Assert.IsInstanceOfType(actualInstance, typeof(DummyClass), "The retrieved instance should be of type DummyClass"); var dummyClass = actualInstance as DummyClass; Debug.Assert(dummyClass != null, "dummyClass != null"); Assert.IsInstanceOfType(dummyClass.Child, typeof(ChildClass)); }
public void XamlMarkupExtensionTest() { string text = @"<test:LoaderTestElement xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests' Value3='{test:LoaderTestBinding Path=A.B.C}'/>"; XamlElement rootElement = XamlParser.Parse(text); object root1 = XamlLoader.Load(rootElement); Assert.IsTrue((root1 as LoaderTestElement).Value3 is LoaderTestBindingExpression); Assert.AreEqual("A.B.C", ((root1 as LoaderTestElement).Value3 as LoaderTestBindingExpression).Path); }
public void XamlTypesTest() { object element1 = XamlLoader.Load(XamlParser.Parse("<x:Null xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'/>")); Assert.IsNull(element1); object element2 = XamlLoader.Load(XamlParser.Parse("<x:Type xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:s='clr-namespace:System' Type='s:Double'/>")); Assert.AreEqual(typeof(Double), element2); }
public void LoadWithRootInstance() { var dummy = new DummyClass { AnotherProperty = "Other value", SampleProperty = "Will be overwritten" }; var loader = new XamlLoader(new DummyXamlParserFactory(WiringContext)); var actual = loader.Load("<DummyClass xmlns=\"root\" SampleProperty=\"Value\" />", dummy); Assert.IsInstanceOfType(actual, dummy.GetType()); Assert.AreEqual("Value", ((DummyClass)actual).SampleProperty); Assert.AreEqual("Other value", ((DummyClass)actual).AnotherProperty); }