mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] TEngineServer
[+] TEngineServer
This commit is contained in:
52
Assets/GameScripts/ThirdParty/Protobuf-net/ServiceModel/ProtoOperationBehavior.cs
vendored
Normal file
52
Assets/GameScripts/ThirdParty/Protobuf-net/ServiceModel/ProtoOperationBehavior.cs
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
#if FEAT_SERVICEMODEL && PLAT_XMLSERIALIZER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Xml;
|
||||
using ProtoBuf.Meta;
|
||||
|
||||
namespace ProtoBuf.ServiceModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a WCF operation behaviour that can perform protobuf serialization
|
||||
/// </summary>
|
||||
public sealed class ProtoOperationBehavior : DataContractSerializerOperationBehavior
|
||||
{
|
||||
private TypeModel model;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ProtoOperationBehavior instance
|
||||
/// </summary>
|
||||
public ProtoOperationBehavior(OperationDescription operation) : base(operation)
|
||||
{
|
||||
#if !NO_RUNTIME
|
||||
model = RuntimeTypeModel.Default;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The type-model that should be used with this behaviour
|
||||
/// </summary>
|
||||
public TypeModel Model
|
||||
{
|
||||
get { return model; }
|
||||
set
|
||||
{
|
||||
model = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
}
|
||||
|
||||
//public ProtoOperationBehavior(OperationDescription operation, DataContractFormatAttribute dataContractFormat) : base(operation, dataContractFormat) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a protobuf serializer if possible (falling back to the default WCF serializer)
|
||||
/// </summary>
|
||||
public override XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns, IList<Type> knownTypes)
|
||||
{
|
||||
if (model == null) throw new InvalidOperationException("No Model instance has been assigned to the ProtoOperationBehavior");
|
||||
return XmlProtoSerializer.TryCreate(model, type) ?? base.CreateSerializer(type, name, ns, knownTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user