Skip to content

Windows Store support #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ src/ProtocolBuffers.Test/bin/
src/ProtocolBuffers.Test/obj/
src/ProtocolBuffersLite.Test/bin/
src/ProtocolBuffersLite.Test/obj/
src/ProtocolBuffers.Serialization/bin/
src/ProtocolBuffers.Serialization/obj/
src/ProtoBench/bin/
src/ProtoBench/obj/
src/ProtoDump/bin/
Expand Down
6 changes: 3 additions & 3 deletions src/ProtocolBuffers.Serialization/AbstractWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ protected virtual void WriteField(FieldType fieldType, string field, object valu
{
WriteEnum(field, ((IEnumLite) value).Number, ((IEnumLite) value).Name);
}
else if (value is IConvertible)
else if (value is ValueType)
{
WriteEnum(field, ((IConvertible)value).ToInt32(FrameworkPortability.InvariantCulture),
((IConvertible)value).ToString(FrameworkPortability.InvariantCulture));
int intValue = Convert.ToInt32(value);
WriteEnum(field, Convert.ToInt32(value), intValue.ToString(FrameworkPortability.InvariantCulture));
}
else
{
Expand Down
9 changes: 1 addition & 8 deletions src/ProtocolBuffers.Serialization/DictionaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,7 @@ private bool GetValue<T>(ref T value)
{
try
{
if (obj is IConvertible)
{
value = (T)Convert.ChangeType(obj, typeof(T), FrameworkPortability.InvariantCulture);
}
else
{
value = (T) obj;
}
value = (T) Convert.ChangeType(obj, typeof(T), FrameworkPortability.InvariantCulture);
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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>{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Google.ProtocolBuffers.Serialization</RootNamespace>
<AssemblyName>Google.ProtocolBuffers.Serialization</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile32</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\portable-win81+wpa81\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS_RUNTIME</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\portable-win81+wpa81\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWS_RUNTIME</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\portable-win81+wpa81\Release\Google.ProtocolBuffers.Serialization.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\ProtocolBuffers\ProtocolBuffers.WinRT.PCL.csproj">
<Project>{5636c607-a1d0-4890-a810-041320618795}</Project>
<Name>ProtocolBuffers.WinRT.PCL</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<TargetPlatform Include="Windows, Version=8.1" />
<TargetPlatform Include="WindowsPhoneApp, Version=8.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ProtocolBuffers\FrameworkPortability.cs">
<Link>FrameworkPortability.cs</Link>
</Compile>
<Compile Include="AbstractReader.cs" />
<Compile Include="AbstractTextReader.cs" />
<Compile Include="AbstractTextWriter.cs" />
<Compile Include="AbstractWriter.cs" />
<Compile Include="DictionaryReader.cs" />
<Compile Include="DictionaryWriter.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Http\FormUrlEncodedReader.cs" />
<Compile Include="Http\MessageFormatFactory.cs" />
<Compile Include="Http\MessageFormatOptions.cs" />
<Compile Include="JsonFormatReader.cs" />
<Compile Include="JsonFormatWriter.cs" />
<Compile Include="JsonTextCursor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RecursionLimitExceeded.cs" />
<Compile Include="XmlFormatReader.cs" />
<Compile Include="XmlFormatWriter.cs" />
<Compile Include="XmlReaderOptions.cs" />
<Compile Include="XmlWriterOptions.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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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>{B492F9CC-F247-4F55-B91E-0359D07D21D9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Google.ProtocolBuffersLite.Serialization</RootNamespace>
<AssemblyName>Google.ProtocolBuffersLite.Serialization</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile32</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\portable-win81+wpa81\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS_RUNTIME;LITE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\portable-win81+wpa81\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWS_RUNTIME;LITE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\portable-win81+wpa81\Release\Google.ProtocolBuffersLite.Serialization.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\ProtocolBuffers\ProtocolBuffersLite.WinRT.PCL.csproj">
<Project>{82181c67-7b33-4286-a575-42b9a2815979}</Project>
<Name>ProtocolBuffersLite.WinRT.PCL</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<TargetPlatform Include="Windows, Version=8.1" />
<TargetPlatform Include="WindowsPhoneApp, Version=8.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ProtocolBuffers\FrameworkPortability.cs">
<Link>FrameworkPortability.cs</Link>
</Compile>
<Compile Include="AbstractReader.cs" />
<Compile Include="AbstractTextReader.cs" />
<Compile Include="AbstractTextWriter.cs" />
<Compile Include="AbstractWriter.cs" />
<Compile Include="DictionaryReader.cs" />
<Compile Include="DictionaryWriter.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Http\FormUrlEncodedReader.cs" />
<Compile Include="Http\MessageFormatFactory.cs" />
<Compile Include="Http\MessageFormatOptions.cs" />
<Compile Include="JsonFormatReader.cs" />
<Compile Include="JsonFormatWriter.cs" />
<Compile Include="JsonTextCursor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RecursionLimitExceeded.cs" />
<Compile Include="XmlFormatReader.cs" />
<Compile Include="XmlFormatWriter.cs" />
<Compile Include="XmlReaderOptions.cs" />
<Compile Include="XmlWriterOptions.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>
94 changes: 94 additions & 0 deletions src/ProtocolBuffers.Universal.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.WinRT.PCL", "ProtocolBuffers\ProtocolBuffers.WinRT.PCL.csproj", "{5636C607-A1D0-4890-A810-041320618795}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Serialization.WinRT.PCL", "ProtocolBuffers.Serialization\ProtocolBuffers.Serialization.WinRT.PCL.csproj", "{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffersLite.WinRT.PCL", "ProtocolBuffers\ProtocolBuffersLite.WinRT.PCL.csproj", "{82181C67-7B33-4286-A575-42B9A2815979}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffersLite.Serialization.WinRT.PCL", "ProtocolBuffers.Serialization\ProtocolBuffersLite.Serialization.WinRT.PCL.csproj", "{B492F9CC-F247-4F55-B91E-0359D07D21D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5636C607-A1D0-4890-A810-041320618795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|ARM.Build.0 = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|x64.ActiveCfg = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|x64.Build.0 = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|x86.ActiveCfg = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Debug|x86.Build.0 = Debug|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|Any CPU.Build.0 = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|ARM.ActiveCfg = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|ARM.Build.0 = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|x64.ActiveCfg = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|x64.Build.0 = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|x86.ActiveCfg = Release|Any CPU
{5636C607-A1D0-4890-A810-041320618795}.Release|x86.Build.0 = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|ARM.Build.0 = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|x64.ActiveCfg = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|x64.Build.0 = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|x86.ActiveCfg = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Debug|x86.Build.0 = Debug|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|Any CPU.Build.0 = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|ARM.ActiveCfg = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|ARM.Build.0 = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|x64.ActiveCfg = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|x64.Build.0 = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|x86.ActiveCfg = Release|Any CPU
{B7924AAF-514E-40C0-A5A6-521E1D4A8ACA}.Release|x86.Build.0 = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|ARM.ActiveCfg = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|ARM.Build.0 = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|x64.ActiveCfg = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|x64.Build.0 = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|x86.ActiveCfg = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Debug|x86.Build.0 = Debug|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|Any CPU.Build.0 = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|ARM.ActiveCfg = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|ARM.Build.0 = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|x64.ActiveCfg = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|x64.Build.0 = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|x86.ActiveCfg = Release|Any CPU
{82181C67-7B33-4286-A575-42B9A2815979}.Release|x86.Build.0 = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|ARM.Build.0 = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|x64.ActiveCfg = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|x64.Build.0 = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Debug|x86.Build.0 = Debug|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|Any CPU.Build.0 = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|ARM.ActiveCfg = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|ARM.Build.0 = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|x64.ActiveCfg = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|x64.Build.0 = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|x86.ActiveCfg = Release|Any CPU
{B492F9CC-F247-4F55-B91E-0359D07D21D9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
11 changes: 9 additions & 2 deletions src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Google.ProtocolBuffers.Collections;
using Google.ProtocolBuffers.DescriptorProtos;
Expand Down Expand Up @@ -441,11 +442,17 @@ public MessageDescriptor MessageType
private static IDictionary<FieldType, MappedType> MapFieldTypes()
{
var map = new Dictionary<FieldType, MappedType>();
foreach (FieldInfo field in typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public))
#if WINDOWS_RUNTIME
var publicFields = typeof(FieldType).GetRuntimeFields().Where(x => x.IsStatic && x.IsPublic);
#else
var publicFields = typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public);
#endif

foreach (FieldInfo field in publicFields)
{
FieldType fieldType = (FieldType) field.GetValue(null);
FieldMappingAttribute mapping =
(FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false)[0];
(FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false).First();
map[fieldType] = mapping.MappedType;
}
return Dictionaries.AsReadOnly(map);
Expand Down
10 changes: 8 additions & 2 deletions src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Google.ProtocolBuffers.Collections;

Expand Down Expand Up @@ -63,11 +64,16 @@ public FieldMappingAttribute(MappedType mappedType, WireFormat.WireType wireType
private static IDictionary<FieldType, FieldMappingAttribute> MapFieldTypes()
{
var map = new Dictionary<FieldType, FieldMappingAttribute>();
foreach (FieldInfo field in typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public))
#if WINDOWS_RUNTIME
var publicFields = typeof(FieldType).GetRuntimeFields().Where(x => x.IsStatic && x.IsPublic);
#else
var publicFields = typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public);
#endif
foreach (FieldInfo field in publicFields)
{
FieldType fieldType = (FieldType) field.GetValue(null);
FieldMappingAttribute mapping =
(FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false)[0];
(FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false).First();
map[fieldType] = mapping;
}
return Dictionaries.AsReadOnly(map);
Expand Down
Loading