You've already forked linux-packaging-mono
Imported Upstream version 4.4.2.4
Former-commit-id: 92904c9c5915c37244316e42ba99e7b934ed7ee2
This commit is contained in:
parent
589d484eee
commit
0b4a830db1
@@ -0,0 +1,84 @@
|
||||
// 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.
|
||||
|
||||
#if !NO_CODEDOM
|
||||
using System.CodeDom;
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
|
||||
#if !NO_CODEDOM
|
||||
public CodeTypeDeclaration ProcessImportedType(CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit)
|
||||
{
|
||||
throw NotImplemented.ByDesign;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,13 @@ LIBRARY = System.Runtime.Serialization.Xml.dll
|
||||
|
||||
KEY_FILE = ../../msfinal.pub
|
||||
SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
|
||||
LIB_REFS = System.Runtime.Serialization System.Xml
|
||||
LIB_REFS = System.Runtime.Serialization System System.Xml Facades/System.Runtime.Serialization.Primitives
|
||||
LIB_MCS_FLAGS = $(SIGN_FLAGS) /r:mscorlib
|
||||
|
||||
ifeq (2.1, $(FRAMEWORK_VERSION))
|
||||
LIB_MCS_FLAGS += /d:NO_CODEDOM
|
||||
endif
|
||||
|
||||
PLATFORM_DEBUG_FLAGS =
|
||||
|
||||
NO_TEST = yes
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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
|
||||
{
|
||||
//
|
||||
// This class enables one to throw a NotImplementedException using the following idiom:
|
||||
//
|
||||
// throw NotImplemented.ByDesign;
|
||||
//
|
||||
// Used by methods whose intended implementation is to throw a NotImplementedException (typically
|
||||
// virtual methods in public abstract classes that intended to be subclassed by third parties.)
|
||||
//
|
||||
// This makes it distinguishable both from human eyes and CCI from NYI's that truly represent undone work.
|
||||
//
|
||||
internal static class NotImplemented
|
||||
{
|
||||
internal static Exception ByDesign
|
||||
{
|
||||
get
|
||||
{
|
||||
return new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal static Exception ByDesignWithMessage(String message)
|
||||
{
|
||||
return new NotImplementedException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
TypeForwarders.cs
|
||||
AssemblyInfo.cs
|
||||
|
||||
|
||||
DataContractSerializerExtensions.cs
|
||||
NotImplemented.cs
|
||||
|
||||
@@ -36,3 +36,4 @@
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.XmlDictionaryWriter))]
|
||||
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.OnXmlDictionaryReaderClose))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.XmlDictionaryReaderQuotaTypes))]
|
||||
|
||||
Reference in New Issue
Block a user