CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
UseNetDataContractAttribute.cs
Go to the documentation of this file.
1#if !NETFX_CORE && !NETSTANDARD2_0 && !NET5_0
2//-----------------------------------------------------------------------
3// <copyright file="UseNetDataContractAttribute.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>Specify that WCF should serialize objects in a .NET</summary>
8//-----------------------------------------------------------------------
9using System;
10using System.ServiceModel.Channels;
11using System.ServiceModel.Description;
12
14{
21 public class UseNetDataContractAttribute : Attribute, IOperationBehavior
22 {
23#region IOperationBehavior Members
24
30 public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
31 {
32 }
33
40 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
41 {
42 ReplaceDataContractSerializerOperationBehavior(description);
43 }
44
51 public void ApplyDispatchBehavior(OperationDescription description, System.ServiceModel.Dispatcher.DispatchOperation dispatch)
52 {
53 ReplaceDataContractSerializerOperationBehavior(description);
54 }
55
60 public void Validate(OperationDescription description)
61 {
62 }
63
64#endregion
65
66 private static void ReplaceDataContractSerializerOperationBehavior(OperationDescription description)
67 {
68 DataContractSerializerOperationBehavior dcsOperationBehavior = description.Behaviors.Find<DataContractSerializerOperationBehavior>();
69
70 if (dcsOperationBehavior != null)
71 {
72 description.Behaviors.Remove(dcsOperationBehavior);
73 description.Behaviors.Add(new NetDataContractOperationBehavior(description));
74 }
75 }
76 }
77}
78#endif
Override the DataContract serialization behavior to use the NetDataContractSerializer.
Specify that WCF should serialize objects in a .NET specific manner to as to preserve complex object ...
void Validate(OperationDescription description)
Not implemented.
void ApplyDispatchBehavior(OperationDescription description, System.ServiceModel.Dispatcher.DispatchOperation dispatch)
Apply the dispatch behavior by requiring the use of the NetDataContractSerializer.
void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
Not implemented.
void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
Apply the client behavior by requiring the use of the NetDataContractSerializer.