コード例 #1
0
        //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 is null)
            {
                throw new InvalidOperationException("No Model instance has been assigned to the ProtoOperationBehavior");
            }
            return(XmlProtoSerializer.TryCreate(_model, type) ?? base.CreateSerializer(type, name, ns, knownTypes));
        }
コード例 #2
0
        public static void Init(out XmlProtoSerializer xpsEvent, out XmlProtoSerializer xpsUpdate, out XmlProtoSerializer xpsCommand)
        {
            Serializer.PrepareSerializer<Event>();
            Serializer.PrepareSerializer<Update>();
            Serializer.PrepareSerializer<Command>();

            xpsEvent = new XmlProtoSerializer(RuntimeTypeModel.Default, typeof(Event));
            xpsUpdate = new XmlProtoSerializer(RuntimeTypeModel.Default, typeof(Update));
            xpsCommand = new XmlProtoSerializer(RuntimeTypeModel.Default, typeof(Command));
        }
コード例 #3
0
ファイル: Issue307.cs プロジェクト: GeorchW/protobuf-net
        public void TestRoundTripWrappedEnum()
        {
            var ser = new XmlProtoSerializer(RuntimeTypeModel.Default, typeof(FooWrapper));
            var ms = new MemoryStream();
            ser.WriteObject(ms, new FooWrapper { Foo = Foo.B });
            ms.Position = 0;
            var clone = (FooWrapper)ser.ReadObject(ms);

            Assert.AreEqual(Foo.B, clone.Foo);
        }
コード例 #4
0
        //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, System.Xml.XmlDictionaryString name, System.Xml.XmlDictionaryString ns, IList <Type> knownTypes)
        {
            return(XmlProtoSerializer.TryCreate(model, type) ?? base.CreateSerializer(type, name, ns, knownTypes));
        }