1 //-----------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //-----------------------------------------------------------------------------
4 
5 namespace System.ServiceModel.Dispatcher
6 {
7     using System;
8     using System.ServiceModel;
9     using System.Collections.Generic;
10     using System.ServiceModel.Description;
11     using System.Runtime.Serialization;
12 
13     public class FaultContractInfo
14     {
15         string action;
16         Type detail;
17         string elementName;
18         string ns;
19         IList<Type> knownTypes;
20         DataContractSerializer serializer;
21 
FaultContractInfo(string action, Type detail)22         public FaultContractInfo(string action, Type detail)
23             : this(action, detail, null, null, null)
24         {
25         }
FaultContractInfo(string action, Type detail, XmlName elementName, string ns, IList<Type> knownTypes)26         internal FaultContractInfo(string action, Type detail, XmlName elementName, string ns, IList<Type> knownTypes)
27         {
28             if (action == null)
29             {
30                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("action");
31             }
32             if (detail == null)
33             {
34                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("detail");
35             }
36 
37             this.action = action;
38             this.detail = detail;
39             if (elementName != null)
40                 this.elementName = elementName.EncodedName;
41             this.ns = ns;
42             this.knownTypes = knownTypes;
43         }
44 
45         public string Action { get { return this.action; } }
46 
47         public Type Detail { get { return this.detail; } }
48 
49         internal string ElementName { get { return this.elementName; } }
50 
51         internal string ElementNamespace { get { return this.ns; } }
52 
53         internal IList<Type> KnownTypes { get { return this.knownTypes; } }
54 
55         internal DataContractSerializer Serializer
56         {
57             get
58             {
59                 if (this.serializer == null)
60                 {
61                     if (this.elementName == null)
62                     {
63                         this.serializer = DataContractSerializerDefaults.CreateSerializer(this.detail, this.knownTypes, int.MaxValue /* maxItemsInObjectGraph */);
64                     }
65                     else
66                     {
67                         this.serializer = DataContractSerializerDefaults.CreateSerializer(this.detail, this.knownTypes, this.elementName, this.ns == null ? string.Empty : this.ns, int.MaxValue /* maxItemsInObjectGraph */);
68                     }
69                 }
70                 return this.serializer;
71             }
72         }
73     }
74 }
75 
76