You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
@@ -0,0 +1,27 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Private.DataContractSerialization", "src\System.Private.DataContractSerialization.csproj", "{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{9618597D-FDAE-42CB-B368-80DB80EA1E37}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.nuget\packages.Windows_NT.config = .nuget\packages.Windows_NT.config
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
9
external/corefx/src/System.Private.DataContractSerialization/dir.props
vendored
Normal file
9
external/corefx/src/System.Private.DataContractSerialization/dir.props
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.1.3.0</AssemblyVersion>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsNETCoreAppRef>false</IsNETCoreAppRef>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
9
external/corefx/src/System.Private.DataContractSerialization/src/Configurations.props
vendored
Normal file
9
external/corefx/src/System.Private.DataContractSerialization/src/Configurations.props
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netcoreapp;
|
||||
uap;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
1191
external/corefx/src/System.Private.DataContractSerialization/src/Resources/Strings.resx
vendored
Normal file
1191
external/corefx/src/System.Private.DataContractSerialization/src/Resources/Strings.resx
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Library Name="*System.Private.DataContractSerialization*">
|
||||
<Assembly Name="System.Private.DataContractSerialization">
|
||||
<Namespace Name="System.Runtime.Serialization">
|
||||
<Type Name="DataContractSerializer">
|
||||
<Method Name=".ctor">
|
||||
<TypeParameter Name="type" DataContractSerializer="Public"/>
|
||||
<TypeEnumerableParameter Name="knownTypes" DataContractSerializer="Public"/>
|
||||
</Method>
|
||||
</Type>
|
||||
<Type Name="KeyValuePairAdapter`2" Dynamic="Required All" />
|
||||
</Namespace>
|
||||
<Namespace Name="System.Runtime.Serialization.Json">
|
||||
<Type Name="DataContractJsonSerializer">
|
||||
<Method Name=".ctor">
|
||||
<TypeParameter Name="type" DataContractJsonSerializer="Public"/>
|
||||
<TypeEnumerableParameter Name="knownTypes" DataContractJsonSerializer="Public"/>
|
||||
</Method>
|
||||
</Type>
|
||||
</Namespace>
|
||||
</Assembly>
|
||||
</Library>
|
||||
</Directives>
|
||||
@@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyName>System.Private.DataContractSerialization</AssemblyName>
|
||||
<RootNamespace>System.Private.DataContractSerialization</RootNamespace>
|
||||
<NoWarn>$(NoWarn);1634;1691;649</NoWarn>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ProjectGuid>{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}</ProjectGuid>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION</DefineConstants>
|
||||
<DefineConstants Condition="'$(TargetGroup)'=='uap101aot'">$(DefineConstants);NET_NATIVE</DefineConstants>
|
||||
<!-- We do not want to block reflection for this assembly -->
|
||||
<BlockReflectionAttribute Condition="'$(TargetGroup)'=='uap101aot'">false</BlockReflectionAttribute>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
|
||||
<PropertyGroup>
|
||||
<RuntimeSerializationSources>System\Runtime\Serialization</RuntimeSerializationSources>
|
||||
<JsonSources>System\Runtime\Serialization\Json</JsonSources>
|
||||
<XmlSources>System\Xml</XmlSources>
|
||||
<TextSources>System\Text</TextSources>
|
||||
<NetNative>$(DefineConstants.Contains('NET_NATIVE'))</NetNative>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(CommonPath)\System\HResults.cs">
|
||||
<Link>Common\System\HResults.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\NotImplemented.cs">
|
||||
<Link>Common\System\NotImplemented.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(RuntimeSerializationSources)\Attributes.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\CodeGenerator.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\ClassDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\CollectionDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DateTimeOffsetAdapter.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DiagnosticUtility.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DictionaryGlobals.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataContractResolver.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataContractSerializer.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataContractSerializerSettings.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataMember.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\EnumDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\ExtensionDataObject.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\ExtensionDataReader.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\Globals.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\GenericParameterDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\HybridObjectCache.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\InvalidDataContract.cs" Condition="$(NetNative)" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\ObjectToIdCache.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\ObjectReferenceStack.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\PrimitiveDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\SchemaExporter.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\ScopedKnownTypes.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlFormatGeneratorStatics.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlFormatReaderGenerator.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlFormatWriterGenerator.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializer.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerContext.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerWriteContext.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerReadContext.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlReaderDelegator.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlSerializableReader.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlSerializableWriter.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlWriterDelegator.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\SerializationMode.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\SpecialTypeDataContract.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\TypeCode.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\KnownTypeDataContractResolver.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerReadContextComplex.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerWriteContextComplex.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\BitFlagsGenerator.cs" Condition="!$(NetNative)" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataContractSurrogateCaller.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\DataContractSerializerExtensions.cs" />
|
||||
<Compile Include="$(RuntimeSerializationSources)\XmlSerializableServices.cs" />
|
||||
<Compile Include="$(XmlSources)\ArrayHelper.cs" />
|
||||
<Compile Include="$(XmlSources)\BytesWithOffset.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlDictionaryAsyncCheckWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\IStreamProvider.cs" />
|
||||
<Compile Include="$(XmlSources)\IXmlDictionary.cs" />
|
||||
<Compile Include="$(XmlSources)\PrefixHandle.cs" />
|
||||
<Compile Include="$(XmlSources)\StringHandle.cs" />
|
||||
<Compile Include="$(XmlSources)\UniqueId.cs" />
|
||||
<Compile Include="$(XmlSources)\ValueHandle.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBaseReader.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBaseWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBinaryNodeType.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBinaryReader.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBinaryReaderSession.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBinaryWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBinaryWriterSession.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlBufferReader.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlConverter.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlDictionary.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlDictionaryWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlDictionaryReader.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlDictionaryReaderQuotas.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlDictionaryString.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlExceptionHelper.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlNodeWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlStreamNodeWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlUTF8TextReader.cs" />
|
||||
<Compile Include="$(XmlSources)\XmlUTF8TextWriter.cs" />
|
||||
<Compile Include="$(XmlSources)\EncodingStreamWrapper.cs" />
|
||||
<Compile Include="$(TextSources)\Base64Encoding.cs" />
|
||||
<Compile Include="$(TextSources)\SurrogateChar.cs" />
|
||||
<Compile Include="$(TextSources)\BinHexEncoding.cs" />
|
||||
<Compile Include="$(JsonSources)\DataContractJsonSerializer.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonByteArrayDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonClassDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonCollectionDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonEnumDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonFormatWriterGenerator.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonFormatReaderGenerator.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonObjectDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonQNameDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonReaderDelegator.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonWriterDelegator.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonStringDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonUriDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonXmlDataContract.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonGlobals.cs" />
|
||||
<Compile Include="$(JsonSources)\XmlObjectSerializerReadContextComplexJson.cs" />
|
||||
<Compile Include="$(JsonSources)\XmlObjectSerializerWriteContextComplexJson.cs" />
|
||||
<Compile Include="$(JsonSources)\DateTimeFormat.cs" />
|
||||
<Compile Include="$(JsonSources)\EmitTypeInformation.cs" />
|
||||
<Compile Include="$(JsonSources)\DataContractJsonSerializerSettings.cs" />
|
||||
<Compile Include="$(JsonSources)\XmlJsonReader.cs" />
|
||||
<Compile Include="$(JsonSources)\XmlJsonWriter.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonReaderWriterFactory.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonNodeType.cs" />
|
||||
<Compile Include="$(JsonSources)\IXmlJsonReaderInitializer.cs" />
|
||||
<Compile Include="$(JsonSources)\IXmlJsonWriterInitializer.cs" />
|
||||
<Compile Include="$(JsonSources)\ByteArrayHelperWithString.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonEncodingStreamWrapper.cs" />
|
||||
<Compile Include="$(JsonSources)\JsonFormatGeneratorStatics.cs" Condition="!$(NetNative)" />
|
||||
<Compile Include="System\Runtime\Serialization\AccessorBuilder.cs" />
|
||||
<Compile Include="$(CommonPath)\System\CodeDom\CodeTypeReference.cs" />
|
||||
<Compile Include="$(CommonPath)\System\CodeDom\CodeTypeReferenceCollection.cs" />
|
||||
<Compile Include="$(CommonPath)\System\CodeDom\CodeObject.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\DataContractSet.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\ExportOptions.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\IExtensibleDataObject.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\Json\ReflectionJsonFormatReader.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\Json\ReflectionJsonFormatWriter.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\ReflectionReader.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\ReflectionClassWriter.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\ReflectionXmlFormatReader.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\ReflectionXmlFormatWriter.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\SchemaHelper.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\SerializationOption.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\XPathQueryGenerator.cs" />
|
||||
<Compile Include="System\Runtime\Serialization\XsdDataContractExporter.cs" />
|
||||
<Compile Include="System\Xml\IFragmentCapableXmlDictionaryWriter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)'=='uap101aot'">
|
||||
<TargetingPackReference Include="System.Private.CoreLib.Augments" />
|
||||
<EmbeddedResource Include="$(MsBuildThisFileDirectory)Resources\$(AssemblyName).rd.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.CodeDom" />
|
||||
<Reference Include="System.Collections" />
|
||||
<Reference Include="System.Collections.Concurrent" />
|
||||
<Reference Include="System.Collections.NonGeneric" />
|
||||
<Reference Include="System.Collections.Specialized" />
|
||||
<Reference Include="System.Diagnostics.Debug" />
|
||||
<Reference Include="System.Diagnostics.Tools" />
|
||||
<Reference Include="System.Linq" />
|
||||
<Reference Include="System.Reflection.Emit.ILGeneration" />
|
||||
<Reference Include="System.Reflection.Emit.Lightweight" />
|
||||
<Reference Include="System.Reflection.Primitives" />
|
||||
<Reference Include="System.Resources.ResourceManager" />
|
||||
<Reference Include="System.Runtime" />
|
||||
<Reference Include="System.Runtime.Extensions" />
|
||||
<Reference Include="System.Runtime.Serialization.Formatters" />
|
||||
<Reference Include="System.Runtime.Serialization.Primitives" />
|
||||
<Reference Include="System.Text.Encoding.Extensions" />
|
||||
<Reference Include="System.Text.RegularExpressions" />
|
||||
<Reference Include="System.Threading" />
|
||||
<Reference Include="System.Threading.Tasks" />
|
||||
<Reference Include="System.Xml.ReaderWriter" />
|
||||
<Reference Include="System.Xml.XDocument" />
|
||||
<Reference Include="System.Xml.XmlSerializer" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,185 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
internal static class FastInvokerBuilder
|
||||
{
|
||||
public delegate void Setter(ref object obj, object value);
|
||||
public delegate object Getter(object obj);
|
||||
|
||||
private delegate void StructSetDelegate<T, TArg>(ref T obj, TArg value);
|
||||
private delegate TResult StructGetDelegate<T, out TResult>(ref T obj);
|
||||
|
||||
private static MethodInfo s_createGetterInternal = typeof(FastInvokerBuilder).GetMethod(nameof(CreateGetterInternal), BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
private static MethodInfo s_createSetterInternal = typeof(FastInvokerBuilder).GetMethod(nameof(CreateSetterInternal), BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
private static MethodInfo s_make = typeof(FastInvokerBuilder).GetMethod(nameof(Make), BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
|
||||
public static Func<object> GetMakeNewInstanceFunc(Type type)
|
||||
{
|
||||
Func<object> make = s_make.MakeGenericMethod(type).CreateDelegate<Func<object>>();
|
||||
return make;
|
||||
}
|
||||
|
||||
public static Getter CreateGetter(MemberInfo memberInfo)
|
||||
{
|
||||
if (memberInfo is PropertyInfo)
|
||||
{
|
||||
var propInfo = (PropertyInfo)memberInfo;
|
||||
var createGetterGeneric = s_createGetterInternal.MakeGenericMethod(propInfo.DeclaringType, propInfo.PropertyType).CreateDelegate<Func<PropertyInfo, Getter>>();
|
||||
Getter accessor = createGetterGeneric(propInfo);
|
||||
return accessor;
|
||||
}
|
||||
else if (memberInfo is FieldInfo)
|
||||
{
|
||||
return (obj) =>
|
||||
{
|
||||
FieldInfo fieldInfo = (FieldInfo)memberInfo;
|
||||
var value = fieldInfo.GetValue(obj);
|
||||
return value;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.InvalidMember, DataContract.GetClrTypeFullName(memberInfo.DeclaringType), memberInfo.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
public static Setter CreateSetter(MemberInfo memberInfo)
|
||||
{
|
||||
if (memberInfo is PropertyInfo)
|
||||
{
|
||||
PropertyInfo propInfo = (PropertyInfo)memberInfo;
|
||||
if (propInfo.CanWrite)
|
||||
{
|
||||
var buildSetAccessorGeneric = s_createSetterInternal.MakeGenericMethod(propInfo.DeclaringType, propInfo.PropertyType).CreateDelegate<Func<PropertyInfo, Setter>>();
|
||||
Setter accessor = buildSetAccessorGeneric(propInfo);
|
||||
return accessor;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.NoSetMethodForProperty, propInfo.DeclaringType, propInfo.Name)));
|
||||
}
|
||||
}
|
||||
else if (memberInfo is FieldInfo)
|
||||
{
|
||||
FieldInfo fieldInfo = (FieldInfo)memberInfo;
|
||||
return (ref object obj, object val) =>
|
||||
{
|
||||
fieldInfo.SetValue(obj, val);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.InvalidMember, DataContract.GetClrTypeFullName(memberInfo.DeclaringType), memberInfo.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
private static object Make<T>() where T : new()
|
||||
{
|
||||
var t = new T();
|
||||
return t;
|
||||
}
|
||||
|
||||
private static Getter CreateGetterInternal<DeclaringType, PropertyType>(PropertyInfo propInfo)
|
||||
{
|
||||
if (typeof(DeclaringType).GetTypeInfo().IsGenericType && typeof(DeclaringType).GetGenericTypeDefinition() == typeof(KeyValue<,>))
|
||||
{
|
||||
if (propInfo.Name == "Key")
|
||||
{
|
||||
return (obj) =>
|
||||
{
|
||||
return ((IKeyValue)obj).Key;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return (obj) =>
|
||||
{
|
||||
return ((IKeyValue)obj).Value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(DeclaringType).GetTypeInfo().IsValueType)
|
||||
{
|
||||
var getMethod = propInfo.GetMethod.CreateDelegate<StructGetDelegate<DeclaringType, PropertyType>>();
|
||||
|
||||
return (obj) =>
|
||||
{
|
||||
var unboxed = (DeclaringType)obj;
|
||||
return getMethod(ref unboxed);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var getMethod = propInfo.GetMethod.CreateDelegate<Func<DeclaringType, PropertyType>>();
|
||||
|
||||
return (obj) =>
|
||||
{
|
||||
return getMethod((DeclaringType)obj);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static Setter CreateSetterInternal<DeclaringType, PropertyType>(PropertyInfo propInfo)
|
||||
{
|
||||
if(typeof(DeclaringType).GetTypeInfo().IsGenericType && typeof(DeclaringType).GetGenericTypeDefinition() == typeof(KeyValue<,>))
|
||||
{
|
||||
if(propInfo.Name == "Key")
|
||||
{
|
||||
return (ref object obj, object val) =>
|
||||
{
|
||||
((IKeyValue)obj).Key = val;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ref object obj, object val) =>
|
||||
{
|
||||
((IKeyValue)obj).Value = val;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(DeclaringType).GetTypeInfo().IsValueType)
|
||||
{
|
||||
var setMethod = propInfo.SetMethod.CreateDelegate<StructSetDelegate<DeclaringType, PropertyType>>();
|
||||
|
||||
return (ref object obj, object val) =>
|
||||
{
|
||||
var unboxed = (DeclaringType)obj;
|
||||
setMethod(ref unboxed, (PropertyType)val);
|
||||
obj = unboxed;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var setMethod = propInfo.SetMethod.CreateDelegate<Action<DeclaringType, PropertyType>>();
|
||||
|
||||
return (ref object obj, object val) =>
|
||||
{
|
||||
setMethod((DeclaringType)obj, (PropertyType)val);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class CreateDelegateExtension
|
||||
{
|
||||
// a generic extension for CreateDelegate
|
||||
public static T CreateDelegate<T>(this MethodInfo method) where T : class
|
||||
{
|
||||
return method.CreateDelegate(typeof(T)) as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
internal class Attributes
|
||||
{
|
||||
private static XmlDictionaryString[] s_serializationLocalNames;
|
||||
|
||||
private static XmlDictionaryString[] s_schemaInstanceLocalNames;
|
||||
|
||||
static Attributes()
|
||||
{
|
||||
s_serializationLocalNames = new XmlDictionaryString[]
|
||||
{
|
||||
DictionaryGlobals.IdLocalName,
|
||||
DictionaryGlobals.ArraySizeLocalName,
|
||||
DictionaryGlobals.RefLocalName,
|
||||
DictionaryGlobals.ClrTypeLocalName,
|
||||
DictionaryGlobals.ClrAssemblyLocalName,
|
||||
};
|
||||
|
||||
s_schemaInstanceLocalNames = new XmlDictionaryString[]
|
||||
{
|
||||
DictionaryGlobals.XsiNilLocalName,
|
||||
DictionaryGlobals.XsiTypeLocalName
|
||||
};
|
||||
}
|
||||
|
||||
internal string Id;
|
||||
internal string Ref;
|
||||
internal string XsiTypeName;
|
||||
internal string XsiTypeNamespace;
|
||||
internal string XsiTypePrefix;
|
||||
internal bool XsiNil;
|
||||
internal string ClrAssembly;
|
||||
internal string ClrType;
|
||||
internal int ArraySZSize;
|
||||
internal string FactoryTypeName;
|
||||
internal string FactoryTypeNamespace;
|
||||
internal string FactoryTypePrefix;
|
||||
internal bool UnrecognizedAttributesFound;
|
||||
|
||||
internal void Read(XmlReaderDelegator reader)
|
||||
{
|
||||
Reset();
|
||||
|
||||
while (reader.MoveToNextAttribute())
|
||||
{
|
||||
switch (reader.IndexOfLocalName(s_serializationLocalNames, DictionaryGlobals.SerializationNamespace))
|
||||
{
|
||||
case 0:
|
||||
ReadId(reader);
|
||||
break;
|
||||
case 1:
|
||||
ReadArraySize(reader);
|
||||
break;
|
||||
case 2:
|
||||
ReadRef(reader);
|
||||
break;
|
||||
case 3:
|
||||
ClrType = reader.Value;
|
||||
break;
|
||||
case 4:
|
||||
ClrAssembly = reader.Value;
|
||||
break;
|
||||
case 5:
|
||||
ReadFactoryType(reader);
|
||||
break;
|
||||
default:
|
||||
switch (reader.IndexOfLocalName(s_schemaInstanceLocalNames, DictionaryGlobals.SchemaInstanceNamespace))
|
||||
{
|
||||
case 0:
|
||||
ReadXsiNil(reader);
|
||||
break;
|
||||
case 1:
|
||||
ReadXsiType(reader);
|
||||
break;
|
||||
default:
|
||||
if (!reader.IsNamespaceUri(DictionaryGlobals.XmlnsNamespace))
|
||||
UnrecognizedAttributesFound = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
reader.MoveToElement();
|
||||
}
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Id = Globals.NewObjectId;
|
||||
Ref = Globals.NewObjectId;
|
||||
XsiTypeName = null;
|
||||
XsiTypeNamespace = null;
|
||||
XsiTypePrefix = null;
|
||||
XsiNil = false;
|
||||
ClrAssembly = null;
|
||||
ClrType = null;
|
||||
ArraySZSize = -1;
|
||||
FactoryTypeName = null;
|
||||
FactoryTypeNamespace = null;
|
||||
FactoryTypePrefix = null;
|
||||
UnrecognizedAttributesFound = false;
|
||||
}
|
||||
|
||||
private void ReadId(XmlReaderDelegator reader)
|
||||
{
|
||||
Id = reader.ReadContentAsString();
|
||||
if (string.IsNullOrEmpty(Id))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidXsIdDefinition, Id)));
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadRef(XmlReaderDelegator reader)
|
||||
{
|
||||
Ref = reader.ReadContentAsString();
|
||||
if (string.IsNullOrEmpty(Ref))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidXsRefDefinition, Ref)));
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadXsiNil(XmlReaderDelegator reader)
|
||||
{
|
||||
XsiNil = reader.ReadContentAsBoolean();
|
||||
}
|
||||
|
||||
private void ReadArraySize(XmlReaderDelegator reader)
|
||||
{
|
||||
ArraySZSize = reader.ReadContentAsInt();
|
||||
if (ArraySZSize < 0)
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidSizeDefinition, ArraySZSize)));
|
||||
}
|
||||
|
||||
private void ReadXsiType(XmlReaderDelegator reader)
|
||||
{
|
||||
string xsiTypeString = reader.Value;
|
||||
if (xsiTypeString != null && xsiTypeString.Length > 0)
|
||||
XmlObjectSerializerReadContext.ParseQualifiedName(xsiTypeString, reader, out XsiTypeName, out XsiTypeNamespace, out XsiTypePrefix);
|
||||
}
|
||||
|
||||
private void ReadFactoryType(XmlReaderDelegator reader)
|
||||
{
|
||||
string factoryTypeString = reader.Value;
|
||||
if (factoryTypeString != null && factoryTypeString.Length > 0)
|
||||
XmlObjectSerializerReadContext.ParseQualifiedName(factoryTypeString, reader, out FactoryTypeName, out FactoryTypeNamespace, out FactoryTypePrefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Security;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
internal class BitFlagsGenerator
|
||||
{
|
||||
private int _bitCount;
|
||||
private CodeGenerator _ilg;
|
||||
private LocalBuilder[] _locals;
|
||||
|
||||
public BitFlagsGenerator(int bitCount, CodeGenerator ilg, string localName)
|
||||
{
|
||||
_ilg = ilg;
|
||||
_bitCount = bitCount;
|
||||
int localCount = (bitCount + 7) / 8;
|
||||
_locals = new LocalBuilder[localCount];
|
||||
for (int i = 0; i < _locals.Length; i++)
|
||||
{
|
||||
_locals[i] = ilg.DeclareLocal(typeof(byte), localName + i, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBitSet(byte[] bytes, int bitIndex)
|
||||
{
|
||||
int byteIndex = GetByteIndex(bitIndex);
|
||||
byte bitValue = GetBitValue(bitIndex);
|
||||
return (bytes[byteIndex] & bitValue) == bitValue;
|
||||
}
|
||||
|
||||
public static void SetBit(byte[] bytes, int bitIndex)
|
||||
{
|
||||
int byteIndex = GetByteIndex(bitIndex);
|
||||
byte bitValue = GetBitValue(bitIndex);
|
||||
bytes[byteIndex] |= bitValue;
|
||||
}
|
||||
|
||||
public int GetBitCount()
|
||||
{
|
||||
return _bitCount;
|
||||
}
|
||||
|
||||
public LocalBuilder GetLocal(int i)
|
||||
{
|
||||
return _locals[i];
|
||||
}
|
||||
|
||||
public int GetLocalCount()
|
||||
{
|
||||
return _locals.Length;
|
||||
}
|
||||
|
||||
public void Load(int bitIndex)
|
||||
{
|
||||
LocalBuilder local = _locals[GetByteIndex(bitIndex)];
|
||||
byte bitValue = GetBitValue(bitIndex);
|
||||
_ilg.Load(local);
|
||||
_ilg.Load(bitValue);
|
||||
_ilg.And();
|
||||
_ilg.Load(bitValue);
|
||||
_ilg.Ceq();
|
||||
}
|
||||
|
||||
public void LoadArray()
|
||||
{
|
||||
LocalBuilder localArray = _ilg.DeclareLocal(Globals.TypeOfByteArray, "localArray");
|
||||
_ilg.NewArray(typeof(byte), _locals.Length);
|
||||
_ilg.Store(localArray);
|
||||
for (int i = 0; i < _locals.Length; i++)
|
||||
{
|
||||
_ilg.StoreArrayElement(localArray, i, _locals[i]);
|
||||
}
|
||||
_ilg.Load(localArray);
|
||||
}
|
||||
|
||||
public void Store(int bitIndex, bool value)
|
||||
{
|
||||
LocalBuilder local = _locals[GetByteIndex(bitIndex)];
|
||||
byte bitValue = GetBitValue(bitIndex);
|
||||
if (value)
|
||||
{
|
||||
_ilg.Load(local);
|
||||
_ilg.Load(bitValue);
|
||||
_ilg.Or();
|
||||
_ilg.Stloc(local);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ilg.Load(local);
|
||||
_ilg.Load(bitValue);
|
||||
_ilg.Not();
|
||||
_ilg.And();
|
||||
_ilg.Stloc(local);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte GetBitValue(int bitIndex)
|
||||
{
|
||||
return (byte)(1 << (bitIndex & 7));
|
||||
}
|
||||
|
||||
private static int GetByteIndex(int bitIndex)
|
||||
{
|
||||
return bitIndex >> 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class CollectionDataContractAttribute : Attribute
|
||||
{
|
||||
private string _name;
|
||||
private string _ns;
|
||||
private string _itemName;
|
||||
private string _keyName;
|
||||
private string _valueName;
|
||||
private bool _isReference;
|
||||
private bool _isNameSetExplicitly;
|
||||
private bool _isNamespaceSetExplicitly;
|
||||
private bool _isReferenceSetExplicitly;
|
||||
private bool _isItemNameSetExplicitly;
|
||||
private bool _isKeyNameSetExplicitly;
|
||||
private bool _isValueNameSetExplicitly;
|
||||
|
||||
public CollectionDataContractAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public string Namespace
|
||||
{
|
||||
get { return _ns; }
|
||||
set
|
||||
{
|
||||
_ns = value;
|
||||
_isNamespaceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNamespaceSetExplicitly
|
||||
{
|
||||
get { return _isNamespaceSetExplicitly; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
_isNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNameSetExplicitly
|
||||
{
|
||||
get { return _isNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public string ItemName
|
||||
{
|
||||
get { return _itemName; }
|
||||
set
|
||||
{
|
||||
_itemName = value;
|
||||
_isItemNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsItemNameSetExplicitly
|
||||
{
|
||||
get { return _isItemNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public string KeyName
|
||||
{
|
||||
get { return _keyName; }
|
||||
set
|
||||
{
|
||||
_keyName = value;
|
||||
_isKeyNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReference
|
||||
{
|
||||
get { return _isReference; }
|
||||
set
|
||||
{
|
||||
_isReference = value;
|
||||
_isReferenceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReferenceSetExplicitly
|
||||
{
|
||||
get { return _isReferenceSetExplicitly; }
|
||||
}
|
||||
|
||||
public bool IsKeyNameSetExplicitly
|
||||
{
|
||||
get { return _isKeyNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public string ValueName
|
||||
{
|
||||
get { return _valueName; }
|
||||
set
|
||||
{
|
||||
_valueName = value;
|
||||
_isValueNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsValueNameSetExplicitly
|
||||
{
|
||||
get { return _isValueNameSetExplicitly; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module, Inherited = false, AllowMultiple = true)]
|
||||
public sealed class ContractNamespaceAttribute : Attribute
|
||||
{
|
||||
private string _clrNamespace;
|
||||
private string _contractNamespace;
|
||||
|
||||
public ContractNamespaceAttribute(string contractNamespace)
|
||||
{
|
||||
_contractNamespace = contractNamespace;
|
||||
}
|
||||
|
||||
public string ClrNamespace
|
||||
{
|
||||
get { return _clrNamespace; }
|
||||
set { _clrNamespace = value; }
|
||||
}
|
||||
|
||||
public string ContractNamespace
|
||||
{
|
||||
get { return _contractNamespace; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1e3ef7e2698265c8509ca37af00ed0cdc28ee70c
|
||||
@@ -0,0 +1,66 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class DataContractAttribute : Attribute
|
||||
{
|
||||
private string _name;
|
||||
private string _ns;
|
||||
private bool _isNameSetExplicitly;
|
||||
private bool _isNamespaceSetExplicitly;
|
||||
private bool _isReference;
|
||||
private bool _isReferenceSetExplicitly;
|
||||
|
||||
public DataContractAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsReference
|
||||
{
|
||||
get { return _isReference; }
|
||||
set
|
||||
{
|
||||
_isReference = value;
|
||||
_isReferenceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReferenceSetExplicitly
|
||||
{
|
||||
get { return _isReferenceSetExplicitly; }
|
||||
}
|
||||
|
||||
public string Namespace
|
||||
{
|
||||
get { return _ns; }
|
||||
set
|
||||
{
|
||||
_ns = value;
|
||||
_isNamespaceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNamespaceSetExplicitly
|
||||
{
|
||||
get { return _isNamespaceSetExplicitly; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
_isNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNameSetExplicitly
|
||||
{
|
||||
get { return _isNameSetExplicitly; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Xml;
|
||||
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
public abstract class DataContractResolver
|
||||
{
|
||||
public abstract bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace);
|
||||
public abstract Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.CodeDom;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
public static class DataContractSerializerExtensions
|
||||
{
|
||||
public static ISerializationSurrogateProvider GetSerializationSurrogateProvider(this DataContractSerializer serializer)
|
||||
{
|
||||
SurrogateProviderAdapter adapter = serializer.DataContractSurrogate as SurrogateProviderAdapter;
|
||||
return (adapter == null) ? null : adapter.Provider;
|
||||
}
|
||||
|
||||
public static void SetSerializationSurrogateProvider(this DataContractSerializer serializer, ISerializationSurrogateProvider provider)
|
||||
{
|
||||
// allocate every time, expectation is that this won't happen enough to warrant maintaining a CondtionalWeakTable.
|
||||
IDataContractSurrogate adapter = new SurrogateProviderAdapter(provider);
|
||||
|
||||
// DCS doesn't expose a setter, access the field directly as a workaround
|
||||
typeof(DataContractSerializer)
|
||||
.GetField("dataContractSurrogate", BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
.SetValue(serializer, adapter);
|
||||
}
|
||||
|
||||
private class SurrogateProviderAdapter : IDataContractSurrogate
|
||||
{
|
||||
private ISerializationSurrogateProvider _provider;
|
||||
public SurrogateProviderAdapter(ISerializationSurrogateProvider provider)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
public ISerializationSurrogateProvider Provider { get { return _provider; } }
|
||||
public object GetCustomDataToExport(Type clrType, Type dataContractType)
|
||||
{
|
||||
throw NotImplemented.ByDesign;
|
||||
}
|
||||
|
||||
public object GetCustomDataToExport(MemberInfo memberInfo, Type dataContractType)
|
||||
{
|
||||
throw NotImplemented.ByDesign;
|
||||
}
|
||||
|
||||
public Type GetDataContractType(Type type)
|
||||
{
|
||||
return _provider.GetSurrogateType(type);
|
||||
}
|
||||
|
||||
public object GetDeserializedObject(object obj, Type targetType)
|
||||
{
|
||||
return _provider.GetDeserializedObject(obj, targetType);
|
||||
}
|
||||
|
||||
public void GetKnownCustomDataTypes(Collection<Type> customDataTypes)
|
||||
{
|
||||
throw NotImplemented.ByDesign;
|
||||
}
|
||||
|
||||
public object GetObjectToSerialize(object obj, Type targetType)
|
||||
{
|
||||
return _provider.GetObjectToSerialize(obj, targetType);
|
||||
}
|
||||
|
||||
public Type GetReferencedTypeOnImport(string typeName, string typeNamespace, object customData)
|
||||
{
|
||||
throw NotImplemented.ByDesign;
|
||||
}
|
||||
|
||||
public CodeTypeDeclaration ProcessImportedType(CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit)
|
||||
{
|
||||
throw NotImplemented.ByDesign;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
public static class DataContractSerializerExtensions
|
||||
{
|
||||
public static ISerializationSurrogateProvider GetSerializationSurrogateProvider(this DataContractSerializer serializer)
|
||||
{
|
||||
return serializer.SerializationSurrogateProvider;
|
||||
}
|
||||
|
||||
public static void SetSerializationSurrogateProvider(this DataContractSerializer serializer, ISerializationSurrogateProvider provider)
|
||||
{
|
||||
serializer.SerializationSurrogateProvider = provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user