This commit is contained in:
Súper JMN 2015-04-18 13:08:30 +02:00
Родитель 12f481bfa4
Коммит 267451111a
107 изменённых файлов: 5030 добавлений и 63 удалений

20
External/Glass/EnumerableExtensions.cs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,20 @@
namespace Glass
{
using System.Collections;
using System.Text;
public static class EnumerableExtensions
{
public static string ToString(this IEnumerable items)
{
var builder = new StringBuilder();
foreach (var xamlNodeType in items)
{
builder.Append(" ·" + xamlNodeType + "\n");
}
return builder.ToString();
}
}
}

53
External/Glass/Glass.csproj поставляемый Normal file
Просмотреть файл

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B719FF91-BC7A-4145-8597-811D504FCFEF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Glass</RootNamespace>
<AssemblyName>Glass</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<Compile Include="Guard.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="EnumerableExtensions.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

16
External/Glass/Guard.cs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,16 @@
using System;
using System.Runtime.CompilerServices;
namespace Glass
{
public static class Guard
{
public static void ThrowIfNull(object argumentValue, string argumentName, [CallerMemberName] string methodName = null)
{
if (argumentValue == null)
{
throw new ArgumentNullException(argumentName, $"{methodName} requires you to provide a value for {argumentName}");
}
}
}
}

30
External/Glass/Properties/AssemblyInfo.cs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,30 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MissU")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MissU")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

148
External/Glass/ReflectionExtensions.cs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,148 @@
namespace Glass
{
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
public static class ReflectionExtensions
{
public static string GetFullPropertyName<T, TProperty>(this Expression<Func<T, TProperty>> propertySelector)
{
MemberExpression memberExp;
if (!TryFindMemberExpression(propertySelector.Body, out memberExp))
{
return string.Empty;
}
var memberNames = new Stack<string>();
do
{
memberNames.Push(memberExp.Member.Name);
}
while (TryFindMemberExpression(memberExp.Expression, out memberExp));
return string.Join(".", memberNames.ToArray());
}
private static bool TryFindMemberExpression(this Expression exp, out MemberExpression memberExp)
{
memberExp = exp as MemberExpression;
if (memberExp != null)
{
return true;
}
if (IsConversion(exp) && exp is UnaryExpression)
{
memberExp = ((UnaryExpression)exp).Operand as MemberExpression;
if (memberExp != null)
{
return true;
}
}
return false;
}
public static MemberExpression GetMemberExpression(this Expression expression)
{
MemberExpression memberExpression;
if (TryFindMemberExpression(expression, out memberExpression))
{
return memberExpression;
}
throw new InvalidOperationException();
}
private static bool IsConversion(Expression exp)
{
return (exp.NodeType == ExpressionType.Convert || exp.NodeType == ExpressionType.ConvertChecked);
}
public static Action<T> GetSetterFromPropertySelector<T, TInst>(this Expression<Func<TInst, T>> sourcePropertySelector, TInst instance)
{
MemberExpression exp;
if (sourcePropertySelector.Body.TryFindMemberExpression(out exp))
{
var propInfo = exp.Member as PropertyInfo;
var deleg = propInfo.SetMethod.CreateDelegate(typeof(Action<T>), instance);
var action = (Action<T>)deleg;
return action;
}
throw new InvalidOperationException();
}
public static Action<object> GetSetterFromProperty(object instance, string propertyName)
{
var propInfo = instance.GetType().GetTypeInfo().GetDeclaredProperty(propertyName);
var deleg = propInfo.SetMethod.CreateDelegate(typeof(Action<object>), instance);
var action = (Action<object>)deleg;
return action;
}
public static Expression<Func<TIn, TOut>> CreatePropertyAccessor<TIn, TOut>(string propertyName)
{
var param = Expression.Parameter(typeof(TIn));
var body = Expression.PropertyOrField(param, propertyName);
return Expression.Lambda<Func<TIn, TOut>>(body, param);
}
public static dynamic GetGetterFromProperty(object instance, string propertyName)
{
var propInfo = instance.GetType().GetTypeInfo().GetDeclaredProperty(propertyName);
var delegateType = typeof(Func<>).MakeGenericType(propInfo.PropertyType);
var deleg = propInfo.GetMethod.CreateDelegate(delegateType, instance);
return deleg;
}
private static object DynamicGenericCall(
object ownerInstance,
Type ownerType,
string methodName,
Type[] methodTypeArguments,
object[] parameters,
Func<IEnumerable<MethodInfo>, MethodInfo> overloadSelector = null)
{
var invoker = GenericMethodInvoker(ownerType, methodName, methodTypeArguments, overloadSelector);
return invoker.Invoke(ownerInstance, parameters);
}
private static MethodBase GenericMethodInvoker(
Type type,
string methodName,
Type[] types,
Func<IEnumerable<MethodInfo>, MethodInfo> overloadSelector = null)
{
var typeInfo = type.GetTypeInfo();
MethodInfo declaredMethod;
if (overloadSelector != null)
{
var declaredMethods = typeInfo.GetDeclaredMethods(methodName);
declaredMethod = overloadSelector(declaredMethods);
}
else
{
declaredMethod = typeInfo.GetDeclaredMethod(methodName);
}
return declaredMethod.MakeGenericMethod(types);
}
public static Delegate GetSetterFromPropertyPath(object instance, string propertyPath)
{
var typeInfo = instance.GetType().GetTypeInfo();
var declaredProperty = typeInfo.GetDeclaredProperty(propertyPath);
var methodInfo = declaredProperty.SetMethod;
var type = typeof(Action<>).MakeGenericType(declaredProperty.PropertyType);
return methodInfo.CreateDelegate(type, instance);
}
}
}

28
External/Xaml.Tests.Resources/Properties/AssemblyInfo.cs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,28 @@
using System.Reflection;
using System.Resources;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OmniXaml.Tests.Resources")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OmniXaml.Tests.Resources")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

154
External/Xaml.Tests.Resources/ScannerInputs.Designer.cs сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,154 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Xaml.Tests.Resources {
using System;
using System.Reflection;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class ScannerInputs {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal ScannerInputs() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xaml.Tests.Resources.ScannerInputs", typeof(ScannerInputs).GetTypeInfo().Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; xmlns:a=&quot;another&quot; /&gt;.
/// </summary>
public static string ElementWith2NsDeclarations {
get {
return ResourceManager.GetString("ElementWith2NsDeclarations", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass&gt;
///&lt;DummyClass.Child&gt;
///&lt;ChildClass /&gt;
///&lt;/DummyClass.Child&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ElementWithChild {
get {
return ResourceManager.GetString("ElementWithChild", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass&gt;
///&lt;Parent.Property/&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ElementWithCollapsedProperty {
get {
return ResourceManager.GetString("ElementWithCollapsedProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass&gt;
///&lt;Parent.Property&gt;
///&lt;/Parent.Property&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ElementWithPropertyNoContents {
get {
return ResourceManager.GetString("ElementWithPropertyNoContents", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Parent.Property&gt;.
/// </summary>
public static string PropertyTagOpen {
get {
return ResourceManager.GetString("PropertyTagOpen", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass/&gt;.
/// </summary>
public static string SingleCollapsed {
get {
return ResourceManager.GetString("SingleCollapsed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; /&gt;.
/// </summary>
public static string SingleCollapsedWithNs {
get {
return ResourceManager.GetString("SingleCollapsedWithNs", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string SingleOpenAndClose {
get {
return ResourceManager.GetString("SingleOpenAndClose", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string SingleOpenAndCloseWithNs {
get {
return ResourceManager.GetString("SingleOpenAndCloseWithNs", resourceCulture);
}
}
}
}

156
External/Xaml.Tests.Resources/ScannerInputs.resx поставляемый Normal file
Просмотреть файл

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ElementWithCollapsedProperty" xml:space="preserve">
<value>&lt;DummyClass&gt;
&lt;Parent.Property/&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="ElementWithPropertyNoContents" xml:space="preserve">
<value>&lt;DummyClass&gt;
&lt;Parent.Property&gt;
&lt;/Parent.Property&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="PropertyTagOpen" xml:space="preserve">
<value>&lt;Parent.Property&gt;</value>
</data>
<data name="ElementWithChild" xml:space="preserve">
<value>&lt;DummyClass&gt;
&lt;DummyClass.Child&gt;
&lt;ChildClass /&gt;
&lt;/DummyClass.Child&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="SingleCollapsed" xml:space="preserve">
<value>&lt;DummyClass/&gt;</value>
</data>
<data name="SingleCollapsedWithNs" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" /&gt;</value>
</data>
<data name="SingleOpenAndClose" xml:space="preserve">
<value>&lt;DummyClass&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="SingleOpenAndCloseWithNs" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="ElementWith2NsDeclarations" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" xmlns:a="another" /&gt;</value>
</data>
</root>

424
External/Xaml.Tests.Resources/Xaml.Designer.cs сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,424 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Xaml.Tests.Resources {
using System;
using System.Reflection;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Xaml {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Xaml() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xaml.Tests.Resources.Xaml", typeof(Xaml).GetTypeInfo().Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; Container.Property=&quot;Value&quot;&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string AttachedProperty {
get {
return ResourceManager.GetString("AttachedProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;BadFormat&lt;/&gt;.
/// </summary>
public static string BadFormat {
get {
return ResourceManager.GetString("BadFormat", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;DummyClass.Items&gt;
/// &lt;Item /&gt;
/// &lt;Item /&gt;
/// &lt;Item /&gt;
/// &lt;/DummyClass.Items&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ChildCollection {
get {
return ResourceManager.GetString("ChildCollection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;DummyClass.Items&gt;
/// &lt;Item/&gt;
/// &lt;/DummyClass.Items&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ClassWithInnerCollection {
get {
return ResourceManager.GetString("ClassWithInnerCollection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; /&gt;.
/// </summary>
public static string CollapsedTag {
get {
return ResourceManager.GetString("CollapsedTag", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; SampleProperty=&quot;SomeText&quot; /&gt;.
/// </summary>
public static string CollapsedTagWithProperty {
get {
return ResourceManager.GetString("CollapsedTagWithProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;DummyClass.Items&gt;
/// &lt;Item Title=&quot;SomeTitle&quot; /&gt;
/// &lt;/DummyClass.Items&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string CollectionWithClosedItemAndProperty {
get {
return ResourceManager.GetString("CollectionWithClosedItemAndProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;DummyClass.Items&gt;
/// &lt;Item/&gt;
/// &lt;Item/&gt;
/// &lt;Item/&gt;
/// &lt;/DummyClass.Items&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string CollectionWithMoreThanOneItem {
get {
return ResourceManager.GetString("CollectionWithMoreThanOneItem", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;Item /&gt;
/// &lt;Item /&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ContentPropertyForCollectionMoreThanOneElement {
get {
return ResourceManager.GetString("ContentPropertyForCollectionMoreThanOneElement", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;Item /&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ContentPropertyForCollectionOneElement {
get {
return ResourceManager.GetString("ContentPropertyForCollectionOneElement", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;ChildClass xmlns=&quot;root&quot;&gt;
/// &lt;Item /&gt;
///&lt;/ChildClass&gt;.
/// </summary>
public static string ContentPropertyForSingleMember {
get {
return ResourceManager.GetString("ContentPropertyForSingleMember", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;
/// xmlns:x=&quot;another&quot; &gt;
/// &lt;DummyClass.ChildFromAnotherNamespace&gt;
/// &lt;x:Foreigner /&gt;
/// &lt;/DummyClass.ChildFromAnotherNamespace&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string DifferentNamespaces {
get {
return ResourceManager.GetString("DifferentNamespaces", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;
/// xmlns:x=&quot;another&quot; SampleProperty=&quot;One&quot; AnotherProperty=&quot;Two&quot;&gt;
/// &lt;DummyClass.ChildFromAnotherNamespace&gt;
/// &lt;x:Foreigner /&gt;
/// &lt;/DummyClass.ChildFromAnotherNamespace&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string DifferentNamespacesAndMoreThanOneProperty {
get {
return ResourceManager.GetString("DifferentNamespacesAndMoreThanOneProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
public static string Empty {
get {
return ResourceManager.GetString("Empty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to NamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueE [rest of string was truncated]&quot;;.
/// </summary>
public static string ExpectedStage1 {
get {
return ResourceManager.GetString("ExpectedStage1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;DummyClass.Child&gt;
/// &lt;ChildClass&gt;&lt;/ChildClass&gt;
/// &lt;/DummyClass.Child&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string InstanceWithChild {
get {
return ResourceManager.GetString("InstanceWithChild", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; SampleProperty=&quot;Property!&quot;&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string InstanceWithStringPropertyAndNsDeclaration {
get {
return ResourceManager.GetString("InstanceWithStringPropertyAndNsDeclaration", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; SampleProperty=&quot;{Parameterized Parameter}&quot;/&gt;.
/// </summary>
public static string MarkupExtensionCtorWith1StringArgument {
get {
return ResourceManager.GetString("MarkupExtensionCtorWith1StringArgument", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;
/// SampleProperty=&quot;{Dummy Property=&apos;Some Value&apos;}&quot;
/// AnotherProperty=&quot;{Dummy Property=&apos;Another Value&apos;}&quot; /&gt;.
/// </summary>
public static string MarkupExtensionTwoQuotedValues {
get {
return ResourceManager.GetString("MarkupExtensionTwoQuotedValues", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;ChildClass /&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string NestedChildWithoutPropertyName {
get {
return ResourceManager.GetString("NestedChildWithoutPropertyName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;x:DummyClass xmlns:x=&quot;nonRoot&quot;&gt;&lt;/x:DummyClass&gt;.
/// </summary>
public static string NonRootNamespace {
get {
return ResourceManager.GetString("NonRootNamespace", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; Number=&quot;1234&quot;&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string NonStringProperty {
get {
return ResourceManager.GetString("NonStringProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string RootNamespace {
get {
return ResourceManager.GetString("RootNamespace", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; SampleProperty=&quot;{Dummy}&quot;/&gt;.
/// </summary>
public static string SimpleExtension {
get {
return ResourceManager.GetString("SimpleExtension", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot; SampleProperty=&quot;{Dummy Property=SomeValue}&quot;/&gt;.
/// </summary>
public static string SimpleExtensionWithOneAssignment {
get {
return ResourceManager.GetString("SimpleExtensionWithOneAssignment", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;&lt;/DummyClass&gt;.
/// </summary>
public static string SingleInstance {
get {
return ResourceManager.GetString("SingleInstance", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;DummyClass xmlns=&quot;root&quot;&gt;
/// &lt;DummyClass.Child&gt;
/// &lt;ChildClass&gt;
/// &lt;ChildClass.Child&gt;
/// &lt;ChildClass/&gt;
/// &lt;/ChildClass.Child&gt;
/// &lt;/ChildClass&gt;
/// &lt;/DummyClass.Child&gt;
///&lt;/DummyClass&gt;.
/// </summary>
public static string ThreeLevelsOfNesting {
get {
return ResourceManager.GetString("ThreeLevelsOfNesting", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Unknown&gt;&lt;/Unknown&gt;.
/// </summary>
public static string UnknownType {
get {
return ResourceManager.GetString("UnknownType", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Window x:Class=&quot;WpfApplication_test1.MainWindow&quot;
/// xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
/// xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
/// xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
/// xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
/// xmlns:local=&quot;clr-namespace:WpfApplication_test1&quot;
/// mc:Ignorable=&quot;d&quot;
/// Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot;&gt;
/// &lt;Grid Background=&quot;BlueViolet&quot;&gt; [rest of string was truncated]&quot;;.
/// </summary>
public static string XamlStage1 {
get {
return ResourceManager.GetString("XamlStage1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to NamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueE [rest of string was truncated]&quot;;.
/// </summary>
public static string XamlStage1_Result {
get {
return ResourceManager.GetString("XamlStage1_Result", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;UserControl
/// x:Class=&quot;NcoreCpuMarkW8.UI.Controls.UcSpeedmeter&quot;
/// xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
/// xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
/// xmlns:local=&quot;using:NcoreCpuMarkW8.UI.Controls&quot;
/// xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
/// xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
/// mc:Ignorable=&quot;d&quot;
/// d:DesignHeight=&quot;400&quot;
/// d:DesignWidth=&quot;600&quot;&gt;
///
/// &lt;Grid MinHeight=&quot;400&quot; MinWidth=&quot;600&quot;&gt; /// [rest of string was truncated]&quot;;.
/// </summary>
public static string XamlStage2 {
get {
return ResourceManager.GetString("XamlStage2", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to NamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationStartObjectStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberEndObjectEndM [rest of string was truncated]&quot;;.
/// </summary>
public static string XamlStage2_Result {
get {
return ResourceManager.GetString("XamlStage2_Result", resourceCulture);
}
}
}
}

79
External/Xaml.Tests.Resources/Xaml.Tests.Resources.csproj поставляемый Normal file
Просмотреть файл

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9B517520-4D99-4BF5-8219-A643F718F6DD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xaml.Tests.Resources</RootNamespace>
<AssemblyName>Xaml.Tests.Resources</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Xaml.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Xaml.resx</DependentUpon>
</Compile>
<Compile Include="ScannerInputs.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>ScannerInputs.resx</DependentUpon>
</Compile>
<Compile Include="XamlWpf.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>XamlWpf.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Xaml.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Xaml.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="ScannerInputs.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>ScannerInputs.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="XamlWpf.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>XamlWpf.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

318
External/Xaml.Tests.Resources/Xaml.resx поставляемый Normal file
Просмотреть файл

@ -0,0 +1,318 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="BadFormat" xml:space="preserve">
<value>&lt;BadFormat&lt;/&gt;</value>
</data>
<data name="ChildCollection" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;DummyClass.Items&gt;
&lt;Item /&gt;
&lt;Item /&gt;
&lt;Item /&gt;
&lt;/DummyClass.Items&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="CollapsedTag" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" /&gt;</value>
</data>
<data name="DifferentNamespaces" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"
xmlns:x="another" &gt;
&lt;DummyClass.ChildFromAnotherNamespace&gt;
&lt;x:Foreigner /&gt;
&lt;/DummyClass.ChildFromAnotherNamespace&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="Empty" xml:space="preserve">
<value />
</data>
<data name="ExpectedStage1" xml:space="preserve">
<value>NamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberEndObjectEndMemberEndObjectEndMemberEndObject</value>
</data>
<data name="InstanceWithChild" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;DummyClass.Child&gt;
&lt;ChildClass&gt;&lt;/ChildClass&gt;
&lt;/DummyClass.Child&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="MarkupExtensionCtorWith1StringArgument" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" SampleProperty="{Parameterized Parameter}"/&gt;</value>
</data>
<data name="NestedChildWithoutPropertyName" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;ChildClass /&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="NonRootNamespace" xml:space="preserve">
<value>&lt;x:DummyClass xmlns:x="nonRoot"&gt;&lt;/x:DummyClass&gt;</value>
</data>
<data name="NonStringProperty" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" Number="1234"&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="RootNamespace" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="SimpleExtension" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" SampleProperty="{Dummy}"/&gt;</value>
</data>
<data name="SingleInstance" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="InstanceWithStringPropertyAndNsDeclaration" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" SampleProperty="Property!"&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="ThreeLevelsOfNesting" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;DummyClass.Child&gt;
&lt;ChildClass&gt;
&lt;ChildClass.Child&gt;
&lt;ChildClass/&gt;
&lt;/ChildClass.Child&gt;
&lt;/ChildClass&gt;
&lt;/DummyClass.Child&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="UnknownType" xml:space="preserve">
<value>&lt;Unknown&gt;&lt;/Unknown&gt;</value>
</data>
<data name="XamlStage1" xml:space="preserve">
<value>&lt;Window x:Class="WpfApplication_test1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication_test1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525"&gt;
&lt;Grid Background="BlueViolet"&gt;
&lt;Grid.RowDefinitions&gt;
&lt;RowDefinition Height="57*"/&gt;
&lt;RowDefinition Height="44*"/&gt;
&lt;RowDefinition Height="59*"/&gt;
&lt;/Grid.RowDefinitions&gt;
&lt;TextBlock Text="Hello to OmniXaml!" Foreground="Bisque" FontSize="50"
HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1"/&gt;
&lt;/Grid&gt;
&lt;/Window&gt;</value>
</data>
<data name="XamlStage1_Result" xml:space="preserve">
<value>NamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberEndObjectEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberEndObjectEndMemberEndObjectEndMemberEndObject</value>
</data>
<data name="XamlStage2" xml:space="preserve">
<value>&lt;UserControl
x:Class="NcoreCpuMarkW8.UI.Controls.UcSpeedmeter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:NcoreCpuMarkW8.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="400"
d:DesignWidth="600"&gt;
&lt;Grid MinHeight="400" MinWidth="600"&gt;
&lt;Canvas&gt;
&lt;Image Source= "/Assets/velocimetro.png" &gt;&lt;/Image&gt;
&lt;Image x:Name="mgBigSpeed" Source= "/Assets/medidorGrande.png" Canvas.Left="300" Canvas.Top="58"
RenderTransformOrigin="0.5, 0.9"&gt;
&lt;Image.RenderTransform&gt;
&lt;RotateTransform x:Name="RotateTransformBig" Angle="-90.00"/&gt;
&lt;/Image.RenderTransform&gt;
&lt;/Image&gt;
&lt;Image x:Name="mgSmallSpeed" Source= "/Assets/medidorPequeno.png" Canvas.Left="300" Canvas.Top="168"
RenderTransformOrigin="0.5, 0.81" UseLayoutRounding="False" d:LayoutRounding="Auto"&gt;
&lt;Image.RenderTransform&gt;
&lt;RotateTransform x:Name="RotateTransformSmall" Angle="-90.00"/&gt;
&lt;/Image.RenderTransform&gt;
&lt;/Image&gt;
&lt;Image Source="/Assets/bolaVelocimetro.png" Canvas.Left="233" Canvas.Top="244"&gt;&lt;/Image&gt;
&lt;TextBlock x:Name="txtSpeedBig" Canvas.Left="227" TextWrapping="Wrap" Text="speedBig" Canvas.Top="57" Height="29" Width="159" FontFamily="Calibri" FontSize="22" Foreground="#FF026A9C" HorizontalAlignment="Center" TextAlignment="Center"/&gt;
&lt;TextBlock x:Name="txtSpeedSmall" Canvas.Left="227" TextWrapping="Wrap" Text="speedSmall" Canvas.Top="162" Height="29" Width="159" FontFamily="Calibri" FontSize="22" Foreground="#FFBD0B0E" HorizontalAlignment="Center" TextAlignment="Center"/&gt;
&lt;/Canvas&gt;
&lt;/Grid&gt;
&lt;/UserControl&gt;</value>
</data>
<data name="XamlStage2_Result" xml:space="preserve">
<value>NamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationNamespaceDeclarationStartObjectStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberStartObjectStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberEndObjectEndMemberEndObjectValueStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberStartObjectStartMemberValueEndMemberStartMemberValueEndMemberEndObjectEndMemberEndObjectValueStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberEndObjectValueStartObjectStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberStartMemberValueEndMemberEndObjectEndMemberEndObjectEndMemberEndObjectEndMemberEndObject</value>
</data>
<data name="ClassWithInnerCollection" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;DummyClass.Items&gt;
&lt;Item/&gt;
&lt;/DummyClass.Items&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="CollectionWithMoreThanOneItem" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;DummyClass.Items&gt;
&lt;Item/&gt;
&lt;Item/&gt;
&lt;Item/&gt;
&lt;/DummyClass.Items&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="DifferentNamespacesAndMoreThanOneProperty" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"
xmlns:x="another" SampleProperty="One" AnotherProperty="Two"&gt;
&lt;DummyClass.ChildFromAnotherNamespace&gt;
&lt;x:Foreigner /&gt;
&lt;/DummyClass.ChildFromAnotherNamespace&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="CollectionWithClosedItemAndProperty" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;DummyClass.Items&gt;
&lt;Item Title="SomeTitle" /&gt;
&lt;/DummyClass.Items&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="CollapsedTagWithProperty" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" SampleProperty="SomeText" /&gt;</value>
</data>
<data name="SimpleExtensionWithOneAssignment" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" SampleProperty="{Dummy Property=SomeValue}"/&gt;</value>
</data>
<data name="MarkupExtensionTwoQuotedValues" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"
SampleProperty="{Dummy Property='Some Value'}"
AnotherProperty="{Dummy Property='Another Value'}" /&gt;</value>
</data>
<data name="AttachedProperty" xml:space="preserve">
<value>&lt;DummyClass xmlns="root" Container.Property="Value"&gt;&lt;/DummyClass&gt;</value>
</data>
<data name="ContentPropertyForCollectionOneElement" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;Item /&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="ContentPropertyForCollectionMoreThanOneElement" xml:space="preserve">
<value>&lt;DummyClass xmlns="root"&gt;
&lt;Item /&gt;
&lt;Item /&gt;
&lt;/DummyClass&gt;</value>
</data>
<data name="ContentPropertyForSingleMember" xml:space="preserve">
<value>&lt;ChildClass xmlns="root"&gt;
&lt;Item /&gt;
&lt;/ChildClass&gt;</value>
</data>
</root>

108
External/Xaml.Tests.Resources/XamlWpf.Designer.cs сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,108 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Xaml.Tests.Resources {
using System;
using System.Reflection;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class XamlWpf {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal XamlWpf() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xaml.Tests.Resources.XamlWpf", typeof(XamlWpf).GetTypeInfo().Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Window xmlns=&quot;root&quot; Title=&quot;Hello OmniXaml!&quot;&gt;
/// &lt;Window.Content&gt;
/// &lt;Grid&gt;
/// &lt;Grid.ColumnDefinitions&gt;
/// &lt;ColumnDefinition /&gt;
/// &lt;ColumnDefinition /&gt;
/// &lt;/Grid.ColumnDefinitions&gt;
/// &lt;Grid.Children&gt;
/// &lt;TextBlock Text=&quot;XAML is the way&quot; Grid.Column=&quot;0&quot; /&gt;
/// &lt;TextBlock Text=&quot;To make you invincible :D&quot; Grid.Column=&quot;1&quot; /&gt;
/// &lt;/Grid.Children&gt;
/// &lt;/Grid&gt;
/// &lt;/Window.Content&gt;
///&lt;/Window&gt;.
/// </summary>
public static string Stage1 {
get {
return ResourceManager.GetString("Stage1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Window xmlns=&quot;root&quot;&gt;&lt;/Window&gt;.
/// </summary>
public static string Window {
get {
return ResourceManager.GetString("Window", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Window xmlns=&quot;root&quot;&gt;
/// &lt;Window.Content&gt;
/// &lt;TextBlock Text=&quot;Saludos cordiales!&quot; /&gt;
/// &lt;/Window.Content&gt;
///&lt;/Window&gt;.
/// </summary>
public static string WindowWithContent {
get {
return ResourceManager.GetString("WindowWithContent", resourceCulture);
}
}
}
}

146
External/Xaml.Tests.Resources/XamlWpf.resx поставляемый Normal file
Просмотреть файл

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Stage1" xml:space="preserve">
<value>&lt;Window xmlns="root" Title="Hello OmniXaml!"&gt;
&lt;Window.Content&gt;
&lt;Grid&gt;
&lt;Grid.ColumnDefinitions&gt;
&lt;ColumnDefinition /&gt;
&lt;ColumnDefinition /&gt;
&lt;/Grid.ColumnDefinitions&gt;
&lt;Grid.Children&gt;
&lt;TextBlock Text="XAML is the way" Grid.Column="0" /&gt;
&lt;TextBlock Text="To make you invincible :D" Grid.Column="1" /&gt;
&lt;/Grid.Children&gt;
&lt;/Grid&gt;
&lt;/Window.Content&gt;
&lt;/Window&gt;</value>
</data>
<data name="Window" xml:space="preserve">
<value>&lt;Window xmlns="root"&gt;&lt;/Window&gt;</value>
</data>
<data name="WindowWithContent" xml:space="preserve">
<value>&lt;Window xmlns="root"&gt;
&lt;Window.Content&gt;
&lt;TextBlock Text="Saludos cordiales!" /&gt;
&lt;/Window.Content&gt;
&lt;/Window&gt;</value>
</data>
</root>

Просмотреть файл

@ -0,0 +1,6 @@
namespace OmniXaml.Tests.Classes.Another
{
public class Foreigner
{
}
}

Просмотреть файл

@ -0,0 +1,13 @@
namespace OmniXaml.Tests.Classes
{
public class AnotherExtension : MarkupExtension
{
public string Property { get; set; }
public string AnotherProperty { get; set; }
public override object ProvideValue(XamlToObjectWiringContext toObjectWiringContext)
{
return "Text From Markup Extension";
}
}
}

Просмотреть файл

@ -0,0 +1,13 @@
using OmniXaml.Tests.Classes;
namespace OmniXaml.Tests.Classes
{
using Attributes;
[ContentProperty("Content")]
public class ChildClass
{
public ChildClass Child { get; set; }
public Item Content { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,19 @@
namespace OmniXaml.Tests.Classes
{
using System.Collections.Generic;
public class Container
{
static readonly IDictionary<object, object> AttachedProperties = new Dictionary<object, object>();
public static void SetProperty(object instance, object value)
{
AttachedProperties.Add(instance, value);
}
public static object GetProperty(object instance)
{
return AttachedProperties[instance];
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
namespace OmniXaml.Tests.Classes
{
using System.Collections.ObjectModel;
using Another;
using Attributes;
[ContentProperty("Items")]
public class DummyClass
{
public DummyClass()
{
Items = new Collection<Item>();
}
public string SampleProperty { get; set; }
public string AnotherProperty { get; set; }
public ChildClass Child { get; set; }
public Foreigner ChildFromAnotherNamespace { get; set; }
public int Number { get; set; }
public Collection<Item> Items { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,13 @@
namespace OmniXaml.Tests.Classes
{
public class DummyExtension : MarkupExtension
{
public string Property { get; set; }
public string AnotherProperty { get; set; }
public override object ProvideValue(XamlToObjectWiringContext serviceProvider)
{
return Property ?? "Text From Markup Extension";
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
namespace OmniXaml.Tests.Classes
{
public class IntExtension : MarkupExtension
{
public int Number { get; set; }
public override object ProvideValue(XamlToObjectWiringContext serviceProvider)
{
return Number;
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
namespace OmniXaml.Tests.Classes
{
public class Item
{
public string Title { get; set; }
public string Text { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OmniXaml.Tests.Classes</RootNamespace>
<AssemblyName>OmniXaml.Tests.Classes</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnotherExtension.cs" />
<Compile Include="Container.cs" />
<Compile Include="IntExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Another\Foreigner.cs" />
<Compile Include="ChildClass.cs" />
<Compile Include="DummyClass.cs" />
<Compile Include="DummyExtension.cs" />
<Compile Include="Item.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OmniXaml\OmniXaml.csproj">
<Project>{0d9cc1de-84c3-40d7-9cc5-b7751e0b25d1}</Project>
<Name>OmniXaml</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OmniXaml.Tests.SysXaml")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OmniXaml.Tests.SysXaml")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e6fda529-90c2-4dda-9080-7e7eef64b2ca")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,16 @@
namespace OmniXaml.Tests
{
using Classes;
using Classes.Another;
public class GivenAWiringContext
{
protected WiringContext WiringContext
{ get; }
= new WiringContextBuilder()
.AddNsForThisType("", "root", typeof(DummyClass))
.AddNsForThisType("x", "another", typeof(Foreigner))
.WithContentPropertiesFromAssemblies(new[] { typeof(DummyClass).Assembly })
.Build();
}
}

Просмотреть файл

@ -1,10 +1,11 @@
namespace OmniXaml.Tests.MarkupExtensionParser
namespace OmniXaml.Tests.MarkupExtensionParserTests
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parsers.Sprache.MarkupExtension;
using Sprache;
using MarkupExtensionParser = OmniXaml.MarkupExtensionParser;
using MarkupExtensionParser = Parsers.Sprache.MarkupExtension.MarkupExtensionParser;
[TestClass]
public class ParserTests

Просмотреть файл

@ -0,0 +1,24 @@
namespace OmniXaml.Tests
{
using Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Typing;
[TestClass]
public class NamespaceTest
{
[TestMethod]
public void TryGetType()
{
var expectedType = typeof(DummyClass);
var ns = new XamlNamespace("mynamespace");
ns.AddMapping(new ClrAssemblyPair(expectedType.Assembly, expectedType.Namespace));
var actualType = ns.GetXamlType(expectedType.Name);
Assert.AreEqual(expectedType, actualType.UnderlyingType);
}
}
}

Просмотреть файл

@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A37CD2B1-8272-4785-9FB0-CBA2C62FA9B4}</ProjectGuid>
<ProjectGuid>{4A7491E9-E218-45F5-BF42-430247765630}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OmniXaml.Tests</RootNamespace>
@ -16,6 +16,7 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -25,6 +26,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -35,11 +37,17 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq, Version=4.2.1409.1722, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sprache, Version=2.0.0.45, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sprache.2.0.0.45\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid1+MonoTouch1\Sprache.dll</HintPath>
<HintPath>..\..\packages\Sprache.2.0.0.45\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid1+MonoTouch1\Sprache.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
@ -54,18 +62,40 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="MarkupExtensionParser\ParserTests.cs" />
<Compile Include="MarkupExtensionParserTests\ParserTests.cs" />
<Compile Include="TestingExtensions.cs" />
<Compile Include="NamespaceTest.cs" />
<Compile Include="XamlTypeRepositoryTests.cs" />
<Compile Include="XamlNamespaceRegistryTests.cs" />
<Compile Include="XamlPullParserTests\ParsingTests.cs" />
<Compile Include="XamlNodeBuilder.cs" />
<Compile Include="XamlNodesAssert.cs" />
<Compile Include="GivenAWiringContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XamlXmlReaderTests\NodeDumpTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\External\Glass\Glass.csproj">
<Project>{b719ff91-bc7a-4145-8597-811d504fcfef}</Project>
<Name>Glass</Name>
</ProjectReference>
<ProjectReference Include="..\External\Xaml.Tests.Resources\Xaml.Tests.Resources.csproj">
<Project>{9b517520-4d99-4bf5-8219-a643f718f6dd}</Project>
<Name>Xaml.Tests.Resources</Name>
</ProjectReference>
<ProjectReference Include="..\OmniXaml.Tests.Classes\OmniXaml.Tests.Classes.csproj">
<Project>{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}</Project>
<Name>OmniXaml.Tests.Classes</Name>
</ProjectReference>
<ProjectReference Include="..\OmniXaml\OmniXaml.csproj">
<Project>{0d9cc1de-84c3-40d7-9cc5-b7751e0b25d1}</Project>
<Name>OmniXaml</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OmniXaml\OmniXaml.csproj">
<Project>{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}</Project>
<Name>OmniXaml</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>

Просмотреть файл

@ -4,11 +4,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MarkupExtensions")]
[assembly: AssemblyTitle("OmniReader.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MarkupExtensions")]
[assembly: AssemblyProduct("OmniReader.Tests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -19,7 +19,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a37cd2b1-8272-4785-9fb0-cba2c62fa9b4")]
[assembly: Guid("4a7491e9-e218-45f5-bf42-430247765630")]
// Version information for an assembly consists of the following four values:
//

Просмотреть файл

@ -0,0 +1,20 @@
namespace OmniXaml.Tests
{
using System.Collections;
using System.Text;
public static class TestingExtensions
{
public static string ToString(this IEnumerable items)
{
var builder = new StringBuilder();
foreach (var xamlNodeType in items)
{
builder.Append(" ·" + xamlNodeType + "\n");
}
return builder.ToString();
}
}
}

Просмотреть файл

@ -0,0 +1,61 @@
namespace OmniXaml.Tests
{
using System.Collections.Generic;
using System.Linq;
using Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Typing;
[TestClass]
public class XamlNamespaceRegistryTests
{
private XamlNamespaceRegistry registry;
private IXamlTypeRepository xamlTypeRepository;
[TestInitialize]
public void Initialize()
{
registry = new XamlNamespaceRegistry();
xamlTypeRepository = new XamlTypeRepository(new XamlNamespaceRegistry());
}
[TestMethod]
public void RegisterPrefixTest()
{
registry.RegisterPrefix(new PrefixRegistration("my", "target"));
CollectionAssert.AreEqual(registry.RegisteredPrefixes.ToList(), new List<string> { "my" });
}
[TestMethod]
public void GetXamlNamespaceOfNotRegisteredPrefix()
{
Assert.IsNull(registry.GetXamlNamespace("namespace"));
}
[TestMethod]
public void GetNamespaceByPrefix()
{
var type = typeof (DummyClass);
registry.RegisterPrefix(new PrefixRegistration("my", "target"));
registry.RegisterNamespace(
new XamlNamespace(
"target",
new[] {new ClrAssemblyPair(type.Assembly, type.Namespace)}));
var ns = registry.GetXamlNamespaceByPrefix("my");
Assert.AreEqual("target", ns.NamespaceUri);
}
[TestMethod]
public void GetNamespace()
{
var type = typeof (DummyClass);
registry.RegisterPrefix(new PrefixRegistration("my", "target"));
registry.RegisterNamespace(new XamlNamespace("target", new[] {new ClrAssemblyPair(type.Assembly, type.Namespace)}));
var ns = registry.GetXamlNamespace("target");
Assert.AreEqual("target", ns.NamespaceUri);
}
}
}

Просмотреть файл

@ -0,0 +1,74 @@
namespace OmniXaml.Tests
{
using System;
using System.Linq.Expressions;
using Glass;
using Typing;
internal class XamlNodeBuilder
{
private readonly IXamlTypeRepository registry;
public XamlNodeBuilder(IXamlTypeRepository registry)
{
this.registry = registry;
}
public XamlNode None()
{
return new XamlNode(XamlNodeType.None);
}
public XamlNode NamespaceDeclaration(string ns, string prefix)
{
return new XamlNode(XamlNodeType.NamespaceDeclaration, new NamespaceDeclaration(ns, prefix));
}
public XamlNode StartObject(Type type)
{
return new XamlNode(XamlNodeType.StartObject, registry.Get(type));
}
public XamlNode StartObject<T>()
{
return StartObject(typeof(T));
}
public XamlNode EndObject()
{
return new XamlNode(XamlNodeType.EndObject, null);
}
public XamlNode StartMember<T>(Expression<Func<T, object>> selector)
{
var name = ReflectionExtensions.GetFullPropertyName(selector);
var xamlMember = registry.Get(typeof(T)).GetMember(name);
return new XamlNode(XamlNodeType.StartMember, xamlMember);
}
public XamlNode EndMember()
{
return new XamlNode(XamlNodeType.EndMember);
}
public XamlNode Value(object value)
{
return new XamlNode(XamlNodeType.Value, value);
}
public XamlNode Items()
{
return new XamlNode(XamlNodeType.StartMember, CoreTypes.Items);
}
public XamlNode GetObject()
{
return new XamlNode(XamlNodeType.GetObject);
}
public XamlNode MarkupExtensionArgument()
{
return new XamlNode(XamlNodeType.StartMember, CoreTypes.MarkupExtensionArguments);
}
}
}

Просмотреть файл

@ -0,0 +1,70 @@
namespace OmniXaml.Tests
{
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
internal static class XamlNodesAssert
{
public static void AreEssentiallyTheSame(ICollection<XamlNode> expectedNodes, ICollection<XamlNode> actualNodes)
{
CollectionAssert.AreEqual(
expectedNodes.ToList(),
actualNodes.ToList(),
new XamlNodeComparer { CheckNameOnlyForXamlTypes = true });
}
private class XamlNodeComparer : IComparer
{
private bool checkNameOnlyForXamlTypes;
public bool CheckNameOnlyForXamlTypes
{
get
{
return checkNameOnlyForXamlTypes;
}
set
{
checkNameOnlyForXamlTypes = value;
}
}
public int Compare(object x, object y)
{
var nodeA = (XamlNode)x;
var nodeB = (XamlNode)y;
var areXamlTypesConsideredEqual = nodeA.XamlType == nodeB.XamlType;
if (nodeA.XamlType != null && nodeB.XamlType != null)
{
areXamlTypesConsideredEqual = checkNameOnlyForXamlTypes
? nodeA.XamlType.Name == nodeB.XamlType.Name
: nodeA.XamlType == nodeB.XamlType;
}
var areMembersConsideredEqual = nodeA.Member == nodeB.Member;
if (nodeA.Member != null && nodeB.Member != null)
{
areMembersConsideredEqual = checkNameOnlyForXamlTypes
? nodeA.Member.Name == nodeB.Member.Name
: nodeA.Member == nodeB.Member;
}
var areNamespacesEqual = nodeA.NamespaceDeclaration == nodeB.NamespaceDeclaration;
if (nodeA.NamespaceDeclaration != null && nodeB.NamespaceDeclaration != null)
{
areNamespacesEqual = nodeA.NamespaceDeclaration.Namespace == nodeB.NamespaceDeclaration.Namespace
&& nodeA.NamespaceDeclaration.Prefix == nodeB.NamespaceDeclaration.Prefix;
}
var equal = nodeA.NodeType == nodeB.NodeType &&
areMembersConsideredEqual && areNamespacesEqual &&
areXamlTypesConsideredEqual;
return equal ? 0 : -1;
}
}
}
}

Просмотреть файл

@ -0,0 +1,376 @@
namespace OmniXaml.Tests.XamlPullParserTests
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Classes;
using Classes.Another;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xaml.Tests.Resources;
[TestClass]
public class ParsingTests : GivenAWiringContext
{
private readonly XamlNodeBuilder nodeBuilder;
public ParsingTests()
{
nodeBuilder = new XamlNodeBuilder(WiringContext.TypeContext);
}
[TestMethod]
[ExpectedException(typeof(XmlException))]
public void EmptyString()
{
ExtractNodesFromPullParser(new StringReader(string.Empty));
}
[TestMethod]
public void SingleInstance()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof (DummyClass)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.SingleInstance));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void RootNamespace()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.RootNamespace));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void InstanceWithStringPropertyAndNsDeclaration()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.SampleProperty),
nodeBuilder.Value("Property!"),
nodeBuilder.EndMember(),
nodeBuilder.None(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.InstanceWithStringPropertyAndNsDeclaration));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void InstanceWithChild()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.Child),
nodeBuilder.StartObject(typeof(ChildClass)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.InstanceWithChild));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void DifferentNamespaces()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", string.Empty),
nodeBuilder.NamespaceDeclaration("another", "x"),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.ChildFromAnotherNamespace),
nodeBuilder.StartObject(typeof(Foreigner)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.DifferentNamespaces));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void DifferentNamespacesAndMoreThanOneProperty()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", string.Empty),
nodeBuilder.NamespaceDeclaration("another", "x"),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.SampleProperty),
nodeBuilder.Value("One"),
nodeBuilder.EndMember(),
nodeBuilder.StartMember<DummyClass>(d => d.AnotherProperty),
nodeBuilder.Value("Two"),
nodeBuilder.EndMember(),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.ChildFromAnotherNamespace),
nodeBuilder.StartObject(typeof(Foreigner)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.DifferentNamespacesAndMoreThanOneProperty));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void ClassWithInnerCollection()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.Items),
nodeBuilder.GetObject(),
nodeBuilder.Items(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.ClassWithInnerCollection));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void CollectionWithMoreThanOneItem()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.Items),
nodeBuilder.GetObject(),
nodeBuilder.Items(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.CollectionWithMoreThanOneItem));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void CollapsedTagWithProperty()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.SampleProperty),
nodeBuilder.Value("Property!"),
nodeBuilder.EndMember(),
nodeBuilder.None(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.CollapsedTagWithProperty));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void CollectionWithClosedItemAndProperty()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.Items),
nodeBuilder.GetObject(),
nodeBuilder.Items(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.StartMember<Item>(d => d.Title),
nodeBuilder.Value("SomeText"),
nodeBuilder.EndMember(),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.CollectionWithClosedItemAndProperty));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void SimpleExtension()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.SampleProperty),
nodeBuilder.StartObject(typeof(DummyExtension)),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.None(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.SimpleExtension));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void SimpleExtensionWithOneAssignment()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.SampleProperty),
nodeBuilder.StartObject(typeof(DummyExtension)),
nodeBuilder.StartMember<DummyExtension>(d => d.Property),
nodeBuilder.Value("SomeProperty"),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.None(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.SimpleExtensionWithOneAssignment));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void ContentPropertyForCollectionOneElement()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.Items),
nodeBuilder.GetObject(),
nodeBuilder.Items(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.ContentPropertyForCollectionOneElement));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void ContentPropertyForCollectionMoreThanOneElement()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(DummyClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<DummyClass>(d => d.Items),
nodeBuilder.GetObject(),
nodeBuilder.Items(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.ContentPropertyForCollectionMoreThanOneElement));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
[TestMethod]
public void ContentPropertyForSingleProperty()
{
var expectedNodes = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof(ChildClass)),
nodeBuilder.None(),
nodeBuilder.StartMember<ChildClass>(d => d.Content),
nodeBuilder.StartObject(typeof(Item)),
nodeBuilder.None(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
var actualNodes = ExtractNodesFromPullParser(new StringReader(Xaml.ContentPropertyForSingleMember));
XamlNodesAssert.AreEssentiallyTheSame(expectedNodes, actualNodes);
}
private ICollection<XamlNode> ExtractNodesFromPullParser(TextReader stringReader)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,49 @@
namespace OmniXaml.Tests
{
using Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Typing;
[TestClass]
public class XamlTypeRepositoryTests
{
private readonly Mock<IXamlNamespaceRegistry> nsRegistryMock;
public XamlTypeRepositoryTests()
{
nsRegistryMock = new Mock<IXamlNamespaceRegistry>();
var type = typeof(DummyClass);
var clrAssemblyPair = new ClrAssemblyPair(type.Assembly, type.Namespace);
nsRegistryMock.Setup(registry => registry.GetXamlNamespace("root"))
.Returns(new XamlNamespace("root", new[] { clrAssemblyPair }));
}
[TestMethod]
public void GetWithFullAddressReturnsCorrectType()
{
var sut = new XamlTypeRepository(nsRegistryMock.Object);
var xamlType = sut.GetWithFullAddress(new XamlTypeName("root", "DummyClass"));
Assert.IsFalse(xamlType.IsUnreachable);
Assert.AreEqual(xamlType.UnderlyingType, typeof(DummyClass));
}
[TestMethod]
public void FullAddressOfUnknownReturnUnreachable()
{
var sut = new XamlTypeRepository(nsRegistryMock.Object);
const string UnreachableTypeName = "UnreachableType";
var xamlType = sut.GetWithFullAddress(new XamlTypeName("root", UnreachableTypeName));
Assert.IsTrue(xamlType.IsUnreachable);
Assert.AreEqual(UnreachableTypeName, xamlType.Name);
}
}
}

Просмотреть файл

@ -0,0 +1,207 @@
namespace OmniXaml.Tests.XamlXmlReaderTests
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Classes;
using Glass;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xaml.Tests.Resources;
[TestClass]
public class NodeDumpTests
{
private readonly XamlNodeBuilder nodeBuilder;
private readonly WiringContext wiringContext;
public NodeDumpTests()
{
wiringContext = new WiringContextBuilder()
.AddNsForThisType("", "root", typeof (DummyClass))
.Build();
nodeBuilder = new XamlNodeBuilder(wiringContext.TypeContext);
}
[TestMethod]
public void ReadSingleInstance()
{
var contents = FlattenNodesFromXaml(Xaml.SingleInstance);
var expected = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof (DummyClass)),
nodeBuilder.EndObject(),
};
XamlNodesAssert.AreEssentiallyTheSame(expected, contents);
}
[TestMethod]
[Description("With no namespace, it fails")]
public void ReadWithChild()
{
var contents = FlattenNodesFromXaml(Xaml.InstanceWithChild);
var expected = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof (DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.Child),
nodeBuilder.StartObject(typeof(ChildClass)),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
XamlNodesAssert.AreEssentiallyTheSame(expected, contents);
}
[TestMethod]
public void InstanceWithStringPropertyAndNsDeclaration()
{
var contents = FlattenNodesFromXaml(Xaml.InstanceWithStringPropertyAndNsDeclaration);
var expected = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof (DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.SampleProperty),
nodeBuilder.Value("Property!"),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
XamlNodesAssert.AreEssentiallyTheSame(expected, contents);
}
[TestMethod]
public void ClassWithInnerCollection()
{
var contents = FlattenNodesFromXaml(Xaml.ClassWithInnerCollection);
var expected = new List<XamlNode>
{
nodeBuilder.NamespaceDeclaration("root", ""),
nodeBuilder.StartObject(typeof (DummyClass)),
nodeBuilder.StartMember<DummyClass>(d => d.Items),
nodeBuilder.GetObject(),
nodeBuilder.Items(),
nodeBuilder.StartObject(typeof (Item)),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
nodeBuilder.EndMember(),
nodeBuilder.EndObject(),
};
XamlNodesAssert.AreEssentiallyTheSame(expected, contents);
}
[TestMethod]
[Ignore]
public void ReadRealXamlStage1()
{
var actualNodes = FlattenNodesFromXaml(Xaml.XamlStage1);
var expectedNodes = ParseResult(Xaml.XamlStage1_Result);
AssertNodesAreEqual(expectedNodes, actualNodes.Select(node => node.NodeType).ToList());
}
[TestMethod]
[Ignore]
public void ReadRealXamlStage2()
{
var actualNodes = FlattenNodesFromXaml(Xaml.XamlStage2);
var expectedNodes = ParseResult(Xaml.XamlStage2_Result);
AssertNodesAreEqual(expectedNodes, actualNodes.Select(node => node.NodeType).ToList());
}
private static void AssertNodesAreEqual(IList<XamlNodeType> expectedNodes, IList<XamlNodeType> actualNodes)
{
CollectionAssert.AreEqual(
expectedNodes.ToList(),
actualNodes.ToList(),
"\nExpected:\n{0}\n\nActual:\n{1}",
EnumerableExtensions.ToString(expectedNodes),
EnumerableExtensions.ToString(actualNodes));
}
private static IList<XamlNodeType> ParseResult(string str)
{
var nodes = new List<XamlNodeType>();
var nodeTypes = Enum.GetNames(typeof(XamlNodeType));
using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(str))))
{
var builder = new StringBuilder();
while (!reader.EndOfStream)
{
var readChar = (char)reader.Read();
builder.Append(readChar);
var currentBuffer = builder.ToString();
var nodeType = nodeTypes.FirstOrDefault(nodeName => nodeName == currentBuffer);
if (nodeType != null)
{
XamlNodeType parsedNode;
if (Enum.TryParse(nodeType, out parsedNode))
{
nodes.Add(parsedNode);
builder.Clear();
}
}
}
}
return nodes;
}
private IList<XamlNode> FlattenNodesFromXaml(string xaml)
{
throw new NotImplementedException();
}
private static IList<XamlNode> DumpReaderNodes(IXamlReader sut)
{
var nodes = new List<XamlNode>();
while (sut.Read())
{
nodes.Add(ExtractXamlNodeFromReader(sut));
}
return nodes;
}
private static XamlNode ExtractXamlNodeFromReader(IXamlReader sut)
{
object data = null;
switch (sut.NodeType)
{
case XamlNodeType.StartObject:
data = sut.Type;
break;
case XamlNodeType.StartMember:
data = sut.Member;
break;
case XamlNodeType.NamespaceDeclaration:
data = sut.Namespace;
break;
case XamlNodeType.Value:
data = sut.Value;
break;
}
return new XamlNode(sut.NodeType, data);
}
}
}

Просмотреть файл

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1409.1722" targetFramework="net46" userInstalled="true" />
<package id="Sprache" version="2.0.0.45" targetFramework="net46" userInstalled="true" />
</packages>

Просмотреть файл

@ -3,9 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22609.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmniXaml", "OmniXaml\OmniXaml.csproj", "{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmniXaml", "OmniXaml\OmniXaml.csproj", "{0D9CC1DE-84C3-40D7-9CC5-B7751E0B25D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmniXaml.Tests", "OmniXaml.Tests\OmniXaml.Tests.csproj", "{A37CD2B1-8272-4785-9FB0-CBA2C62FA9B4}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FCCAF8EF-B08E-4442-90B6-A41903CFB93A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glass", "External\Glass\Glass.csproj", "{B719FF91-BC7A-4145-8597-811D504FCFEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmniXaml.Tests.Classes", "OmniXaml.Tests.Classes\OmniXaml.Tests.Classes.csproj", "{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xaml.Tests.Resources", "External\Xaml.Tests.Resources\Xaml.Tests.Resources.csproj", "{9B517520-4D99-4BF5-8219-A643F718F6DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmniXaml.Tests", "OmniXaml.Tests\OmniXaml.Tests.csproj", "{4A7491E9-E218-45F5-BF42-430247765630}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -13,16 +21,34 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}.Release|Any CPU.Build.0 = Release|Any CPU
{A37CD2B1-8272-4785-9FB0-CBA2C62FA9B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37CD2B1-8272-4785-9FB0-CBA2C62FA9B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A37CD2B1-8272-4785-9FB0-CBA2C62FA9B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A37CD2B1-8272-4785-9FB0-CBA2C62FA9B4}.Release|Any CPU.Build.0 = Release|Any CPU
{0D9CC1DE-84C3-40D7-9CC5-B7751E0B25D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D9CC1DE-84C3-40D7-9CC5-B7751E0B25D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D9CC1DE-84C3-40D7-9CC5-B7751E0B25D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D9CC1DE-84C3-40D7-9CC5-B7751E0B25D1}.Release|Any CPU.Build.0 = Release|Any CPU
{B719FF91-BC7A-4145-8597-811D504FCFEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B719FF91-BC7A-4145-8597-811D504FCFEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B719FF91-BC7A-4145-8597-811D504FCFEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B719FF91-BC7A-4145-8597-811D504FCFEF}.Release|Any CPU.Build.0 = Release|Any CPU
{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA}.Release|Any CPU.Build.0 = Release|Any CPU
{9B517520-4D99-4BF5-8219-A643F718F6DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B517520-4D99-4BF5-8219-A643F718F6DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B517520-4D99-4BF5-8219-A643F718F6DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B517520-4D99-4BF5-8219-A643F718F6DD}.Release|Any CPU.Build.0 = Release|Any CPU
{4A7491E9-E218-45F5-BF42-430247765630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A7491E9-E218-45F5-BF42-430247765630}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A7491E9-E218-45F5-BF42-430247765630}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A7491E9-E218-45F5-BF42-430247765630}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B719FF91-BC7A-4145-8597-811D504FCFEF} = {FCCAF8EF-B08E-4442-90B6-A41903CFB93A}
{E6FDA529-90C2-4DDA-9080-7E7EEF64B2CA} = {FCCAF8EF-B08E-4442-90B6-A41903CFB93A}
{9B517520-4D99-4BF5-8219-A643F718F6DD} = {FCCAF8EF-B08E-4442-90B6-A41903CFB93A}
{4A7491E9-E218-45F5-BF42-430247765630} = {FCCAF8EF-B08E-4442-90B6-A41903CFB93A}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,19 @@
namespace OmniXaml.Attributes
{
using System;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class ContentPropertyAttribute : Attribute
{
public string Name { get; }
public ContentPropertyAttribute()
{
}
public ContentPropertyAttribute(string name)
{
this.Name = name;
}
}
}

Просмотреть файл

@ -0,0 +1,30 @@
namespace OmniXaml.Attributes
{
using System;
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class XmlnsDefinitionAttribute : Attribute
{
public string XmlNamespace { get; }
public string ClrNamespace { get; }
public string AssemblyName { get; set; }
public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace)
{
if (xmlNamespace == null)
{
throw new ArgumentNullException("xmlNamespace");
}
if (clrNamespace == null)
{
throw new ArgumentNullException("clrNamespace");
}
XmlNamespace = xmlNamespace;
ClrNamespace = clrNamespace;
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
namespace OmniXaml.Catalogs
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Attributes;
public class AttributeBasedClrMappingCatalog : ClrMappingCatalog
{
public AttributeBasedClrMappingCatalog(IEnumerable<Assembly> assemblies)
{
var attributes = from assembly in assemblies
let attribute = assembly.GetCustomAttribute<XmlnsDefinitionAttribute>()
where attribute != null
select new { Assembly = assembly, attribute.ClrNamespace, attribute.XmlNamespace };
foreach (var mapping in attributes)
{
InternalMappings.Add(new ClrMapping(mapping.Assembly, mapping.XmlNamespace, mapping.ClrNamespace));
}
}
}
}

Просмотреть файл

@ -0,0 +1,28 @@
namespace OmniXaml.Catalogs
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Attributes;
public class AttributeBasedContentPropertyCatalog : ContentPropertyCatalog
{
public AttributeBasedContentPropertyCatalog(IEnumerable<Assembly> assemblies)
{
var types = assemblies.SelectMany(assembly => assembly.DefinedTypes).ToList();
var typeAndAttributePairs = from typeAndAttributePair in
from type in types
let att = type.GetCustomAttribute<ContentPropertyAttribute>()
select new { type, att }
where typeAndAttributePair.att != null
select typeAndAttributePair;
var typeWithAttributes = typeAndAttributePairs.ToList();
foreach (var typeWithAttribute in typeWithAttributes)
{
InternalMappings.Add(typeWithAttribute.type.AsType(), typeWithAttribute.att.Name);
}
}
}
}

Просмотреть файл

@ -0,0 +1,29 @@
namespace OmniXaml.Catalogs
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using TypeConversion;
public class AttributeBasedConverterCatalog : Dictionary<Type, ITypeConverter>
{
public AttributeBasedConverterCatalog(IEnumerable<Assembly> assemblies)
{
var types = assemblies.SelectMany(assembly => assembly.DefinedTypes).ToList();
var typeAndAttributePairs = from typeAndAttributePair in
from type in types
let att = type.GetCustomAttribute<TypeConverterAttribute>()
select new { type, att }
where typeAndAttributePair.att != null
select typeAndAttributePair;
foreach (var typeWithAttribute in typeAndAttributePairs)
{
var converterInstance = (ITypeConverter)Activator.CreateInstance(typeWithAttribute.att.Converter);
Add(typeWithAttribute.type.AsType(), converterInstance);
}
}
}
}

Просмотреть файл

@ -0,0 +1,13 @@
namespace OmniXaml.Catalogs
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
public class ClrMappingCatalog
{
public IEnumerable<ClrMapping> Mappings => new ReadOnlyCollection<ClrMapping>(InternalMappings.ToList());
protected HashSet<ClrMapping> InternalMappings { get; } = new HashSet<ClrMapping>();
}
}

Просмотреть файл

@ -0,0 +1,13 @@
namespace OmniXaml.Catalogs
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
public class ContentPropertyCatalog
{
public IDictionary<Type, string> Mappings => new ReadOnlyDictionary<Type, string>(InternalMappings);
protected IDictionary<Type, string> InternalMappings { get; } = new Dictionary<Type, string>();
}
}

Просмотреть файл

@ -0,0 +1,15 @@
namespace OmniXaml.Catalogs
{
using System.Collections.Generic;
public class EnumerableBasedClrCatalog : ClrMappingCatalog
{
public EnumerableBasedClrCatalog(IEnumerable<ClrMapping> mappings)
{
foreach (var clrMapping in mappings)
{
InternalMappings.Add(clrMapping);
}
}
}
}

18
OmniXaml/ClrMapping.cs Normal file
Просмотреть файл

@ -0,0 +1,18 @@
namespace OmniXaml
{
using System.Reflection;
public class ClrMapping
{
public Assembly Assembly { get; }
public string XamlNamespace { get; }
public string ClrNamespace { get; }
public ClrMapping(Assembly assembly, string xamlNamespace, string clrNamespace)
{
this.Assembly = assembly;
this.XamlNamespace = xamlNamespace;
this.ClrNamespace = clrNamespace;
}
}
}

Просмотреть файл

@ -0,0 +1,58 @@
namespace OmniXaml
{
using System;
using System.Collections.Generic;
using System.Reflection;
using Catalogs;
public class ContentPropertyProvider : IContentPropertyProvider
{
private readonly IDictionary<Type, string> registeredContentProperties = new Dictionary<Type, string>();
public string GetContentPropertyName(Type type)
{
string member;
var explictRegistration = registeredContentProperties.TryGetValue(type, out member) ? member : null;
if (explictRegistration == null)
{
return ResolveFromHierarchy(type);
}
return explictRegistration;
}
private string ResolveFromHierarchy(Type type)
{
if (type == null)
{
return null;
}
string member;
var baseRegistration = registeredContentProperties.TryGetValue(type, out member) ? member : null;
if (baseRegistration != null)
{
return baseRegistration;
}
var typeToLookFor = type.GetTypeInfo().BaseType;
return ResolveFromHierarchy(typeToLookFor);
}
public void AddCatalog(ContentPropertyCatalog catalog)
{
try
{
foreach (var propertyInfo in catalog.Mappings)
{
registeredContentProperties.Add(propertyInfo);
}
}
catch (ArgumentException ex)
{
throw new InvalidOperationException(string.Format("There has been a problem adding the catalog: {0}", ex));
}
}
}
}

Просмотреть файл

@ -0,0 +1,31 @@
namespace OmniXaml
{
using System;
using System.Collections.Generic;
using Glass;
public class DefaultTypeFactory : ITypeFactory
{
public object Create(Type type)
{
Guard.ThrowIfNull(type, nameof(type));
return Create(type, null);
}
public object Create(Type type, object[] args)
{
return Activator.CreateInstance(type, args);
}
public bool CanLocate(Type type)
{
return true;
}
public IList<Type> LookupUserInjectableParameters(Type type, int parameterCount)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
namespace OmniXaml
{
using System;
using Catalogs;
public interface IContentPropertyProvider
{
string GetContentPropertyName(Type type);
void AddCatalog(ContentPropertyCatalog catalog);
}
}

Просмотреть файл

@ -0,0 +1,7 @@
namespace OmniXaml
{
public interface IMarkupExtension
{
object ProvideValue(XamlToObjectWiringContext toObjectWiringContext);
}
}

9
OmniXaml/ITypeContext.cs Normal file
Просмотреть файл

@ -0,0 +1,9 @@
namespace OmniXaml
{
using Typing;
public interface ITypeContext : IXamlNamespaceRegistry, IXamlTypeRepository
{
ITypeFactory TypeFactory { get; }
}
}

13
OmniXaml/ITypeFactory.cs Normal file
Просмотреть файл

@ -0,0 +1,13 @@
namespace OmniXaml
{
using System;
using System.Collections.Generic;
public interface ITypeFactory
{
object Create(Type type);
object Create(Type type, object[] args);
bool CanLocate(Type type);
IList<Type> LookupUserInjectableParameters(Type type, int parameterCount);
}
}

Просмотреть файл

@ -0,0 +1,8 @@
namespace OmniXaml
{
public interface IValueConverter<TFirst, TSecond>
{
TSecond Convert(TFirst first);
TFirst Convert(TSecond first);
}
}

13
OmniXaml/IXamlLoader.cs Normal file
Просмотреть файл

@ -0,0 +1,13 @@
namespace OmniXaml
{
using System.IO;
public interface IXamlLoader
{
object Load(Stream stream);
object Load(Stream stream, object rootInstance);
object Load(IXamlReader reader, object rootObject = null);
}
}

Просмотреть файл

@ -0,0 +1,14 @@
namespace OmniXaml
{
using System;
using System.Reflection;
using Catalogs;
public interface IXamlNamespaceTypeResolver
{
Type Resolve(string typeName, string xamlNamespace);
void AddCatalog(ClrMappingCatalog catalog);
void Map(string xamlNs, Assembly assembly, string clrNs);
}
}

Просмотреть файл

@ -0,0 +1,9 @@
namespace OmniXaml
{
public interface IXamlObjectWriter
{
void WriteNode(IXamlReader reader);
object Result { get; }
}
}

Просмотреть файл

@ -0,0 +1,9 @@
namespace OmniXaml
{
using System.Collections.Generic;
public interface IXamlPullParser
{
IEnumerable<XamlNode> Nodes();
}
}

17
OmniXaml/IXamlReader.cs Normal file
Просмотреть файл

@ -0,0 +1,17 @@
namespace OmniXaml
{
using Typing;
public interface IXamlReader
{
XamlNodeType NodeType { get; }
bool IsEof { get; }
XamlType Type { get; }
XamlMember Member { get; }
NamespaceDeclaration Namespace { get; }
object Value { get; }
bool Read();
}
}

Просмотреть файл

@ -0,0 +1,7 @@
namespace OmniXaml
{
public abstract class MarkupExtension : IMarkupExtension
{
public abstract object ProvideValue(XamlToObjectWiringContext toObjectWiringContext);
}
}

Просмотреть файл

@ -0,0 +1,26 @@
namespace OmniXaml
{
public class NamespaceDeclaration
{
private string ns;
private string prefix;
public NamespaceDeclaration(string ns, string prefix)
{
this.ns = ns;
this.prefix = prefix;
}
public string Namespace
{
get { return ns; }
set { ns = value; }
}
public string Prefix
{
get { return prefix; }
set { prefix = value; }
}
}
}

Просмотреть файл

@ -5,7 +5,7 @@
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A6F3A1E6-3BE2-4F34-B22B-70B8DCF89A98}</ProjectGuid>
<ProjectGuid>{0D9CC1DE-84C3-40D7-9CC5-B7751E0B25D1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OmniXaml</RootNamespace>
@ -34,16 +34,82 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssignmentNode.cs" />
<Compile Include="MarkupExtensionNode.cs" />
<Compile Include="MarkupExtensionParser.cs" />
<Compile Include="Option.cs" />
<Compile Include="OptionsCollection.cs" />
<Compile Include="PositionalOption.cs" />
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\External\Glass\Glass.csproj">
<Project>{B719FF91-BC7A-4145-8597-811D504FCFEF}</Project>
<Name>Glass</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\ContentPropertyAttribute.cs" />
<Compile Include="Attributes\XmlnsDefinitionAttribute.cs" />
<Compile Include="Catalogs\AttributeBasedClrMappingCatalog.cs" />
<Compile Include="Catalogs\AttributeBasedContentPropertyCatalog.cs" />
<Compile Include="Catalogs\AttributeBasedConverterCatalog.cs" />
<Compile Include="Catalogs\ClrMappingCatalog.cs" />
<Compile Include="Catalogs\ContentPropertyCatalog.cs" />
<Compile Include="Catalogs\EnumerableBasedClrCatalog.cs" />
<Compile Include="ClrMapping.cs" />
<Compile Include="ContentPropertyProvider.cs" />
<Compile Include="DefaultTypeFactory.cs" />
<Compile Include="IContentPropertyProvider.cs" />
<Compile Include="IMarkupExtension.cs" />
<Compile Include="ITypeContext.cs" />
<Compile Include="ITypeFactory.cs" />
<Compile Include="IValueConverter.cs" />
<Compile Include="IXamlLoader.cs" />
<Compile Include="IXamlNamespaceTypeResolver.cs" />
<Compile Include="IXamlObjectWriter.cs" />
<Compile Include="IXamlPullParser.cs" />
<Compile Include="IXamlReader.cs" />
<Compile Include="MarkupExtension.cs" />
<Compile Include="NamespaceDeclaration.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\AssignmentNode.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\MarkupExtensionNode.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\MarkupExtensionParser.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\Option.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\OptionsCollection.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\PositionalOption.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\PropertyOption.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\StringNode.cs" />
<Compile Include="Parsers\Sprache\MarkupExtension\TreeNode.cs" />
<Compile Include="TypeContext.cs" />
<Compile Include="TypeContextBuilder.cs" />
<Compile Include="TypeConversion\ITypeConverter.cs" />
<Compile Include="TypeConversion\ITypeConverterProvider.cs" />
<Compile Include="TypeConversion\ITypeDescriptorContext.cs" />
<Compile Include="TypeConversion\NumberTypeConverter.cs" />
<Compile Include="TypeConversion\StringTypeConverter.cs" />
<Compile Include="TypeConversion\TypeConverterAttribute.cs" />
<Compile Include="TypeConversion\TypeConverterProvider.cs" />
<Compile Include="TypeNotFoundException.cs" />
<Compile Include="Typing\ClrAssemblyPair.cs" />
<Compile Include="Typing\FrameworkBuiltInTypeRepository.cs" />
<Compile Include="Typing\IXamlNamespaceRegistry.cs" />
<Compile Include="Typing\IXamlTypeRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyOption.cs" />
<Compile Include="StringNode.cs" />
<Compile Include="TreeNode.cs" />
<Compile Include="Typing\PrefixRegistration.cs" />
<Compile Include="Typing\XamlDirective.cs" />
<Compile Include="Typing\XamlMember.cs" />
<Compile Include="Typing\XamlName.cs" />
<Compile Include="Typing\XamlNamespace.cs" />
<Compile Include="Typing\XamlNamespaceRegistry.cs" />
<Compile Include="Typing\PropertyLocator.cs" />
<Compile Include="Typing\XamlQualifiedName.cs" />
<Compile Include="Typing\CoreTypes.cs" />
<Compile Include="Typing\XamlType.cs" />
<Compile Include="Typing\XamlTypeName.cs" />
<Compile Include="Typing\XamlTypeRepository.cs" />
<Compile Include="WiringContext.cs" />
<Compile Include="WiringContextBuilder.cs" />
<Compile Include="XamlNode.cs" />
<Compile Include="XamlNodeType.cs" />
<Compile Include="XamlReader.cs" />
<Compile Include="XamlReaderException.cs" />
<Compile Include="XamlToObjectWiringContext.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="Sprache, Version=2.0.0.45, Culture=neutral, processorArchitecture=MSIL">
@ -51,9 +117,6 @@
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Просмотреть файл

@ -1,6 +0,0 @@
namespace OmniXaml
{
public abstract class Option
{
}
}

Просмотреть файл

@ -1,4 +1,4 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
public class AssignmentNode
{

Просмотреть файл

@ -1,4 +1,4 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
public class MarkupExtensionNode : TreeNode
{

Просмотреть файл

@ -1,7 +1,7 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
using System.Linq;
using Sprache;
using global::Sprache;
public static class MarkupExtensionParser
{

Просмотреть файл

@ -0,0 +1,6 @@
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
public abstract class Option
{
}
}

Просмотреть файл

@ -1,4 +1,4 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
using System.Collections.Generic;
using System.Collections.ObjectModel;

Просмотреть файл

@ -1,4 +1,4 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
using System.Diagnostics;

Просмотреть файл

@ -1,4 +1,4 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
using System.Diagnostics;

Просмотреть файл

@ -1,4 +1,4 @@
namespace OmniXaml
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
internal class StringNode : TreeNode
{

Просмотреть файл

@ -0,0 +1,6 @@
namespace OmniXaml.Parsers.Sprache.MarkupExtension
{
public abstract class TreeNode
{
}
}

Просмотреть файл

@ -1,15 +1,16 @@
using System.Reflection;
using System.Resources;
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OmniXaml")]
[assembly: AssemblyTitle("OmniXaml.Base.Interfaces")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OmniXaml")]
[assembly: AssemblyProduct("OmniXaml.Base.Interfaces")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -27,5 +28,4 @@ using System.Runtime.CompilerServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: InternalsVisibleTo("OmniXaml.Tests")]
[assembly:InternalsVisibleTo("OmniXaml.Tests")]

Просмотреть файл

@ -1,6 +0,0 @@
namespace OmniXaml
{
public abstract class TreeNode
{
}
}

56
OmniXaml/TypeContext.cs Normal file
Просмотреть файл

@ -0,0 +1,56 @@
namespace OmniXaml
{
using System;
using Typing;
public class TypeContext : ITypeContext
{
private readonly IXamlTypeRepository typeRepository;
private readonly IXamlNamespaceRegistry nsRegistry;
private readonly ITypeFactory typeFactory;
public TypeContext(IXamlTypeRepository typeRepository, IXamlNamespaceRegistry nsRegistry, ITypeFactory typeFactory)
{
this.typeRepository = typeRepository;
this.nsRegistry = nsRegistry;
this.typeFactory = typeFactory;
}
public XamlNamespace GetXamlNamespace(string ns)
{
return nsRegistry.GetXamlNamespace(ns);
}
public string GetNamespaceForPrefix(string prefix)
{
return nsRegistry.GetNamespaceForPrefix(prefix);
}
public void RegisterPrefix(PrefixRegistration prefixRegistration)
{
nsRegistry.RegisterPrefix(prefixRegistration);
}
public void RegisterNamespace(XamlNamespace xamlNamespace)
{
nsRegistry.RegisterNamespace(xamlNamespace);
}
public XamlType Get(Type type)
{
return typeRepository.Get(type);
}
public XamlType GetByPrefix(string prefix, string typeName)
{
return typeRepository.GetByPrefix(prefix, typeName);
}
public XamlType GetWithFullAddress(XamlTypeName xamlTypeName)
{
return typeRepository.GetWithFullAddress(xamlTypeName);
}
public ITypeFactory TypeFactory => typeFactory;
}
}

Просмотреть файл

@ -0,0 +1,73 @@
namespace OmniXaml
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Typing;
public class TypeContextBuilder
{
private IXamlTypeRepository typeRepository;
private IXamlNamespaceRegistry nsRegistry;
private readonly ITypeFactory typeFactory = new DefaultTypeFactory();
private readonly ISet<ClrMapping> xamlMappings = new HashSet<ClrMapping>();
private readonly IDictionary<string,string> prefixes = new Dictionary<string, string>();
public TypeContextBuilder()
{
nsRegistry = new XamlNamespaceRegistry();
typeRepository = new XamlTypeRepository(nsRegistry);
}
public ITypeContext Build()
{
nsRegistry = new XamlNamespaceRegistry();
typeRepository = new XamlTypeRepository(nsRegistry);
RegisterPrefixes(nsRegistry);
RegisterNamespaces(nsRegistry);
return new TypeContext(typeRepository, nsRegistry, typeFactory);
}
private void RegisterPrefixes(IXamlNamespaceRegistry namespaceRegistry)
{
foreach (var prefix in prefixes)
{
namespaceRegistry.RegisterPrefix(new PrefixRegistration(prefix.Key, prefix.Value));
}
}
private void RegisterNamespaces(IXamlNamespaceRegistry namespaceRegistry)
{
foreach (var xamlMapping in xamlMappings.ToLookup(mapping => mapping.XamlNamespace))
{
var xamlNs = xamlMapping.Key;
var mappedTo = xamlMapping.Select(mapping => new ClrAssemblyPair(mapping.Assembly, mapping.ClrNamespace));
namespaceRegistry.RegisterNamespace(new XamlNamespace(xamlNs, mappedTo));
}
}
public TypeContextBuilder WithNsPrefix(string prefix, string ns)
{
prefixes.Add(prefix, ns);
return this;
}
public TypeContextBuilder AddNsForThisType(string prefix, string xamlNs, Type referenceType)
{
WithNsPrefix(prefix, xamlNs);
WithXamlNs(xamlNs, referenceType.GetTypeInfo().Assembly, referenceType.Namespace);
return this;
}
public TypeContextBuilder WithXamlNs(string xamlNs, Assembly assembly, string clrNs)
{
xamlMappings.Add(new ClrMapping(assembly, xamlNs, clrNs));
return this;
}
}
}

Просмотреть файл

@ -0,0 +1,16 @@
namespace OmniXaml.TypeConversion
{
using System;
using System.Globalization;
public interface ITypeConverter
{
object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value);
object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType);
bool CanConvertTo(ITypeDescriptorContext context, Type destinationType);
bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType);
}
}

Просмотреть файл

@ -0,0 +1,12 @@
namespace OmniXaml.TypeConversion
{
using System;
using System.Collections.Generic;
public interface ITypeConverterProvider
{
ITypeConverter GetTypeConverter(Type getType);
void AddCatalog(IDictionary<Type, ITypeConverter> typeConverters);
}
}

Просмотреть файл

@ -0,0 +1,6 @@
namespace OmniXaml.TypeConversion
{
public interface ITypeDescriptorContext
{
}
}

Просмотреть файл

@ -0,0 +1,28 @@
namespace OmniXaml.TypeConversion
{
using System;
using System.Globalization;
public class NumberTypeConverter : ITypeConverter
{
public object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
throw new NotImplementedException();
}
public object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return value.ToString();
}
public bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return true;
}
public bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
namespace OmniXaml.TypeConversion
{
using System;
using System.Globalization;
public class StringTypeConverter : ITypeConverter
{
public object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value == null)
{
return null;
}
if (value is string)
{
return value;
}
return value.ToString();
}
public object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value == null)
{
return null;
}
if (destinationType == typeof(int))
{
var str = value as string;
if (str != null)
{
int n;
if (int.TryParse(str, out n))
{
return n;
}
return null;
}
}
return value.ToString();
}
public bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string) || destinationType == typeof(int))
{
return true;
}
return false;
}
public bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
namespace OmniXaml.TypeConversion
{
using System;
public class TypeConverterAttribute : Attribute
{
public Type Converter { get; }
public TypeConverterAttribute(Type typeConverter)
{
this.Converter = typeConverter;
}
}
}

Просмотреть файл

@ -0,0 +1,44 @@
namespace OmniXaml.TypeConversion
{
using System;
using System.Collections.Generic;
public class TypeConverterProvider : ITypeConverterProvider
{
readonly IDictionary<Type, ITypeConverter> converters = new Dictionary<Type, ITypeConverter>();
public TypeConverterProvider()
{
RegisterBuiltIn();
}
private void RegisterBuiltIn()
{
Register(typeof(string), new StringTypeConverter());
Register(typeof(int), new NumberTypeConverter());
Register(typeof(long), new NumberTypeConverter());
Register(typeof(short), new NumberTypeConverter());
Register(typeof(double), new NumberTypeConverter());
Register(typeof(float), new NumberTypeConverter());
}
private void Register(Type type, ITypeConverter converter)
{
converters[type] = converter;
}
public void AddCatalog(IDictionary<Type, ITypeConverter> catalog)
{
foreach (var typeConverter in catalog)
{
converters.Add(typeConverter);
}
}
public ITypeConverter GetTypeConverter(Type getType)
{
ITypeConverter converter;
return converters.TryGetValue(getType, out converter) ? converter : null;
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
namespace OmniXaml
{
using System;
public class TypeNotFoundException : Exception
{
public TypeNotFoundException(string message) : base(message)
{
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
namespace OmniXaml.Typing
{
using System.Reflection;
public class ClrAssemblyPair
{
private readonly Assembly assembly;
private readonly string ns;
public ClrAssemblyPair(Assembly assembly, string ns)
{
this.assembly = assembly;
this.ns = ns;
}
public Assembly Assembly => assembly;
public string Namespace => ns;
}
}

Просмотреть файл

@ -0,0 +1,18 @@
namespace OmniXaml.Typing
{
using System.Collections.Generic;
public static class CoreTypes
{
private static readonly XamlDirective ItemsField = new XamlDirective("_Items", XamlType.Builder.CreateForBuiltInType(typeof(List<object>)));
private static readonly XamlDirective InitializationField = new XamlDirective("_Initialization");
private static readonly XamlDirective MarkupExtensionArgumentsField = new XamlDirective("_MarkupExtensionArguments");
private static readonly XamlDirective UnknownContentField = new XamlDirective("_UnknownContent");
public static XamlDirective Items => ItemsField;
public static XamlDirective Initialization => InitializationField;
public static XamlDirective UnknownContent => UnknownContentField;
public static XamlType String => XamlType.Builder.CreateForBuiltInType(typeof(string));
public static object MarkupExtensionArguments => MarkupExtensionArgumentsField;
}
}

Просмотреть файл

@ -0,0 +1,22 @@
namespace OmniXaml.Typing
{
using System;
public class FrameworkBuiltInTypeRepository : IXamlTypeRepository
{
public XamlType Get(Type type)
{
throw new NotImplementedException();
}
public XamlType GetByPrefix(string prefix, string typeName)
{
throw new NotImplementedException();
}
public XamlType GetWithFullAddress(XamlTypeName xamlTypeName)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,16 @@
namespace OmniXaml.Typing
{
public interface IXamlNamespaceRegistry
{
//void RegisterPrefix(PrefixRegistration prefixRegistration);
//XamlNamespace GetXamlNamespace(string ns);
//void MapNamespaceTo(XamlNamespace xamlNamespace, ClrAssemblyPair targetAssembly);
//XamlNamespace GetNamespaceForType(string typeName);
//XamlNamespace GetNamespaceForType(Type type);
//XamlNamespace GetNamespaceForType(XamlTypeName xamlTypeName);
XamlNamespace GetXamlNamespace(string ns);
string GetNamespaceForPrefix(string prefix);
void RegisterPrefix(PrefixRegistration prefixRegistration);
void RegisterNamespace(XamlNamespace xamlNamespace);
}
}

Просмотреть файл

@ -0,0 +1,11 @@
namespace OmniXaml.Typing
{
using System;
public interface IXamlTypeRepository
{
XamlType Get(Type type);
XamlType GetByPrefix(string prefix, string typeName);
XamlType GetWithFullAddress(XamlTypeName xamlTypeName);
}
}

Просмотреть файл

@ -0,0 +1,31 @@
namespace OmniXaml.Typing
{
public class PrefixRegistration
{
private readonly string prefix;
private readonly string ns;
public PrefixRegistration(string prefix, string ns)
{
this.prefix = prefix;
this.ns = ns;
}
public string Prefix
{
get
{
return prefix;
}
}
public string Ns
{
get
{
return ns;
}
}
}
}

Просмотреть файл

@ -0,0 +1,92 @@
namespace OmniXaml.Typing
{
public class PropertyLocator : XamlName
{
public readonly XamlName Owner;
private PropertyLocator(XamlName owner, string prefix, string propertyName)
: base(propertyName)
{
if (owner != null)
{
Owner = owner;
Prefix = owner.Prefix ?? string.Empty;
}
else
{
Prefix = prefix ?? string.Empty;
}
}
public override string ScopedName
{
get
{
if (!IsDotted)
{
return PropertyName;
}
return Owner.ScopedName + "." + PropertyName;
}
}
public string OwnerName
{
get
{
if (!IsDotted)
{
return string.Empty;
}
return Owner.PropertyName;
}
}
public bool IsDotted => Owner != null;
public static PropertyLocator Parse(string longName)
{
if (string.IsNullOrEmpty(longName))
{
return null;
}
string prefix;
string qualifiedName;
if (!XamlQualifiedName.Parse(longName, out prefix, out qualifiedName))
{
return null;
}
var startIndex = 0;
var part1 = string.Empty;
var length = qualifiedName.IndexOf('.');
if (length != -1)
{
part1 = qualifiedName.Substring(startIndex, length);
if (string.IsNullOrEmpty(part1))
{
return null;
}
startIndex = length + 1;
}
var part2 = startIndex == 0 ? qualifiedName : qualifiedName.Substring(startIndex);
XamlQualifiedName xamlQualifiedName = null;
if (!string.IsNullOrEmpty(part1))
{
xamlQualifiedName = new XamlQualifiedName(prefix, part1);
}
return new PropertyLocator(xamlQualifiedName, prefix, part2);
}
public static PropertyLocator Parse(string longName, string namespaceUri)
{
var xamlPropertyName = Parse(longName);
xamlPropertyName.Namespace = namespaceUri;
return xamlPropertyName;
}
}
}

Просмотреть файл

@ -0,0 +1,16 @@
namespace OmniXaml.Typing
{
public class XamlDirective : XamlMember
{
public XamlDirective(string name)
: base(name)
{
this.IsDirective = true;
}
public XamlDirective(string name, XamlType xamlType) : this(name)
{
this.Type = xamlType;
}
}
}

Просмотреть файл

@ -0,0 +1,108 @@
namespace OmniXaml.Typing
{
using System.Reflection;
public class XamlMember
{
private readonly string name;
public XamlMember(string name)
{
this.name = name;
}
private XamlMember(string name, XamlType owner, IXamlTypeRepository mother, bool isAttachable) : this(name)
{
IsAttachable = isAttachable;
DeclaringType = owner;
if (!isAttachable)
{
var property = owner.UnderlyingType.GetRuntimeProperty(name);
Type = XamlType.Builder.Create(property.PropertyType, mother);
}
else
{
var typeInfo = owner.UnderlyingType.GetTypeInfo();
var setMethod = typeInfo.GetDeclaredMethod("Get" + name);
Type = XamlType.Builder.Create(setMethod.ReturnType, mother);
}
}
public string Name => name;
public bool IsAttachable { get; set; }
public bool IsDirective { get; protected set; }
public XamlType DeclaringType { get; private set; }
public bool IsUnreachable { get; private set; }
public XamlType Type { get; set; }
public override string ToString()
{
return IsDirective ? "XamlDirective:" : "XamlMember: " + Name;
}
public static class Builder
{
public static XamlMember Create(string name, XamlType parent, IXamlTypeRepository mother)
{
return new XamlMember(name, parent, mother, false);
}
public static XamlMember CreateUnreachable(string name, XamlType declaringType)
{
return new XamlMember(name)
{
DeclaringType = declaringType,
IsUnreachable = true,
};
}
public static XamlMember CreateAttached(string name, XamlType parent, IXamlTypeRepository mother)
{
return new XamlMember(name, parent, mother, true);
}
}
protected bool Equals(XamlMember other)
{
return string.Equals(name, other.name) && IsAttachable.Equals(other.IsAttachable) && IsDirective.Equals(other.IsDirective) &&
Equals(DeclaringType, other.DeclaringType) && IsUnreachable.Equals(other.IsUnreachable) && Equals(Type, other.Type);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != this.GetType())
{
return false;
}
return Equals((XamlMember)obj);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = (name != null ? name.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ IsAttachable.GetHashCode();
hashCode = (hashCode * 397) ^ IsDirective.GetHashCode();
hashCode = (hashCode * 397) ^ (DeclaringType != null ? DeclaringType.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ IsUnreachable.GetHashCode();
hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
return hashCode;
}
}
}
}

Просмотреть файл

@ -0,0 +1,95 @@
namespace OmniXaml.Typing
{
public abstract class XamlName
{
public const char PlusSign = '+';
public const char UnderScore = '_';
public const char Dot = '.';
protected XamlName()
: this(string.Empty)
{
}
public XamlName(string propertyName)
{
PropertyName = propertyName;
}
public XamlName(string prefix, string propertyName)
{
PropertyName = propertyName;
this.Prefix = prefix ?? string.Empty;
}
public string PropertyName
{
get; protected set;
}
public abstract string ScopedName { get; }
public string Prefix { get; protected set; }
public string Namespace { get; protected set; }
public static bool ContainsDot(string name)
{
return name.Contains(".");
}
public static bool IsValidXamlName(string name)
{
if (name.Length == 0 || !IsValidNameStartChar(name[0]))
{
return false;
}
for (var index = 1; index < name.Length; ++index)
{
if (!IsValidNameChar(name[index]))
{
return false;
}
}
return true;
}
public static bool IsValidNameStartChar(char ch)
{
if (!char.IsLetter(ch))
{
return ch == 95;
}
return true;
}
public static bool IsValidNameChar(char ch)
{
if (IsValidNameStartChar(ch) || char.IsDigit(ch))
{
return true;
}
return false;
}
public static bool IsValidQualifiedNameChar(char ch)
{
if (ch != 46)
{
return IsValidNameChar(ch);
}
return true;
}
public static bool IsValidQualifiedNameCharPlus(char ch)
{
if (!IsValidQualifiedNameChar(ch))
{
return ch == 43;
}
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,56 @@
namespace OmniXaml.Typing
{
using System;
using System.Collections.Generic;
using System.Linq;
public class XamlNamespace
{
private readonly string xamlNamespaceUri;
private readonly IXamlTypeRepository typeRepository;
private readonly HashSet<ClrAssemblyPair> mappings = new HashSet<ClrAssemblyPair>();
public XamlNamespace(string xamlNamespaceUri)
{
this.xamlNamespaceUri = xamlNamespaceUri;
}
public XamlNamespace(string xamlNamespaceUri, IEnumerable<ClrAssemblyPair> clrAssemblyPair) : this(xamlNamespaceUri)
{
this.mappings = new HashSet<ClrAssemblyPair>(clrAssemblyPair);
}
public string NamespaceUri => xamlNamespaceUri;
public XamlType GetXamlType(string typeName)
{
var firstType = (from clrAssemblyPair in mappings
let clrNs = clrAssemblyPair.Namespace
select clrAssemblyPair.Assembly.GetType(clrNs + "." + typeName)).FirstOrDefault(
type => type != null);
if (firstType == null)
{
return null;
}
return XamlType.Builder.Create(firstType, typeRepository);
}
public void AddMapping(ClrAssemblyPair clrAssemblyPair)
{
mappings.Add(clrAssemblyPair);
}
public Type Get(string name)
{
var types = from mapping in mappings
let t = mapping.Assembly.GetType(mapping.Namespace + "." + name)
where t != null
select t;
return types.FirstOrDefault();
}
}
}

Просмотреть файл

@ -0,0 +1,39 @@
namespace OmniXaml.Typing
{
using System.Collections.Generic;
using System.Linq;
public class XamlNamespaceRegistry : IXamlNamespaceRegistry
{
private readonly IDictionary<string, string> registeredPrefixes = new Dictionary<string, string>();
private readonly ISet<XamlNamespace> namespaces = new HashSet<XamlNamespace>();
public IEnumerable<string> RegisteredPrefixes => registeredPrefixes.Keys;
public void RegisterPrefix(PrefixRegistration prefixRegistration)
{
registeredPrefixes.Add(prefixRegistration.Prefix, prefixRegistration.Ns);
}
public XamlNamespace GetXamlNamespace(string ns)
{
var xamlNamespace = namespaces.FirstOrDefault(ns1 => ns1.NamespaceUri == ns);
return xamlNamespace;
}
public string GetNamespaceForPrefix(string prefix)
{
return registeredPrefixes[prefix];
}
public XamlNamespace GetXamlNamespaceByPrefix(string prefix)
{
return GetXamlNamespace(registeredPrefixes[prefix]);
}
public void RegisterNamespace(XamlNamespace xamlNamespace)
{
namespaces.Add(xamlNamespace);
}
}
}

Просмотреть файл

@ -0,0 +1,29 @@
namespace OmniXaml.Typing
{
using System;
public class XamlQualifiedName : XamlName
{
public XamlQualifiedName(string prefix, string propertyName)
: base(prefix, propertyName)
{
}
public override string ScopedName
{
get
{
if (!string.IsNullOrEmpty(Prefix))
{
return Prefix + ":" + PropertyName;
}
return PropertyName;
}
}
public static bool Parse(string longName, out string prefix, out string name)
{
throw new NotImplementedException();
}
}
}

115
OmniXaml/Typing/XamlType.cs Normal file
Просмотреть файл

@ -0,0 +1,115 @@
namespace OmniXaml.Typing
{
using System;
using System.Collections;
using System.Reflection;
public class XamlType
{
private readonly IXamlTypeRepository typeRepository;
private XamlType(Type type, IXamlTypeRepository typeRepository)
{
this.typeRepository = typeRepository;
UnderlyingType = type;
Name = type.Name;
}
private XamlType(string name)
{
Name = name;
IsUnreachable = true;
}
public bool IsUnreachable { get; private set; }
public Type UnderlyingType { get; private set; }
public string Name { get; set; }
public XamlType BaseType { get; set; }
public bool IsCollection => typeof (IList).GetTypeInfo().IsAssignableFrom(this.UnderlyingType.GetTypeInfo());
public bool IsContainer => IsCollection || IsDictionary;
public bool IsDictionary { get; set; }
protected bool Equals(XamlType other)
{
return UnderlyingType == other.UnderlyingType;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((XamlType)obj);
}
public override int GetHashCode()
{
unchecked
{
return ((UnderlyingType?.GetHashCode() ?? 0) * 397);
}
}
public XamlMember GetMember(string name)
{
if (IsUnreachable)
{
return XamlMember.Builder.CreateUnreachable(name, this);
}
return XamlMember.Builder.Create(name, this, typeRepository);
}
public XamlMember GetAttachableMember(string name)
{
return XamlMember.Builder.CreateAttached(name, this, typeRepository);
}
public override string ToString()
{
return "XamlType: " + Name;
}
public static class Builder
{
public static XamlType CreateUnreachable(XamlTypeName typeName)
{
return new XamlType(typeName.Name);
}
public static XamlType Create(Type underlyingType, IXamlTypeRepository mother)
{
return new XamlType(underlyingType, mother);
}
public static XamlType CreateForBuiltInType(Type type)
{
return new XamlType(type, new FrameworkBuiltInTypeRepository());
}
}
public bool CanAssignTo(XamlType type)
{
var otherUnderlyingType = type.UnderlyingType.GetTypeInfo();
return otherUnderlyingType.IsAssignableFrom(UnderlyingType.GetTypeInfo());
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
namespace OmniXaml.Typing
{
public class XamlTypeName
{
public XamlTypeName(string xamlNamespace, string name)
{
Name = name;
Namespace = xamlNamespace;
}
public string Name
{
get; private set;
}
public string Namespace
{
get; private set;
}
}
}

Просмотреть файл

@ -0,0 +1,44 @@
namespace OmniXaml.Typing
{
using System;
public class XamlTypeRepository : IXamlTypeRepository
{
private readonly IXamlNamespaceRegistry xamlNamespaceRegistry;
public XamlTypeRepository(IXamlNamespaceRegistry xamlNamespaceRegistry)
{
this.xamlNamespaceRegistry = xamlNamespaceRegistry;
}
public XamlType Get(Type type)
{
return XamlType.Builder.Create(type, this);
}
public XamlType GetByPrefix(string prefix, string typeName)
{
var ns = xamlNamespaceRegistry.GetNamespaceForPrefix(prefix);
return GetWithFullAddress(new XamlTypeName(ns, typeName));
}
public XamlType GetWithFullAddress(XamlTypeName xamlTypeName)
{
var xamlNamespace = xamlNamespaceRegistry.GetXamlNamespace(xamlTypeName.Namespace);
if (xamlNamespace == null)
{
return XamlType.Builder.CreateUnreachable(xamlTypeName);
}
var correspondingType = xamlNamespace.Get(xamlTypeName.Name);
if (correspondingType != null)
{
return XamlType.Builder.Create(correspondingType, this);
}
return XamlType.Builder.CreateUnreachable(xamlTypeName);
}
}
}

18
OmniXaml/WiringContext.cs Normal file
Просмотреть файл

@ -0,0 +1,18 @@
namespace OmniXaml
{
using TypeConversion;
public class WiringContext
{
public WiringContext(ITypeContext typeContext, IContentPropertyProvider contentPropertyProvider, ITypeConverterProvider converterProvider)
{
TypeContext = typeContext;
ContentPropertyProvider = contentPropertyProvider;
ConverterProvider = converterProvider;
}
public ITypeContext TypeContext { get; private set; }
public IContentPropertyProvider ContentPropertyProvider { get; private set; }
public ITypeConverterProvider ConverterProvider { get; private set; }
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше