Mercurial > silverbladetech
annotate SilverlightExampleApp/SilverlightExampleApp.Web/Services/SilverlightFaultBehavior.cs @ 62:810116cd6b8e
ErrorWindow working
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Sun, 22 Apr 2012 09:01:20 +0100 |
parents | 502f5f365649 |
children |
rev | line source |
---|---|
49
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
1 // This is an auto-generated file to enable WCF faults to reach Silverlight clients. |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
2 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
3 using System; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
4 using System.Collections.Generic; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
5 using System.Collections.ObjectModel; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
6 using System.Linq; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
7 using System.Runtime.Serialization; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
8 using System.Net; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
9 using System.ServiceModel; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
10 using System.ServiceModel.Channels; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
11 using System.ServiceModel.Description; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
12 using System.ServiceModel.Dispatcher; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
13 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
14 namespace SilverlightExampleApp.Web.Services |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
15 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
16 public class SilverlightFaultBehavior : Attribute, IServiceBehavior |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
17 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
18 private class SilverlightFaultEndpointBehavior : IEndpointBehavior |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
19 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
20 public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
21 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
22 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
23 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
24 public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
25 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
26 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
27 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
28 public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
29 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
30 endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new SilverlightFaultMessageInspector()); |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
31 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
32 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
33 public void Validate(ServiceEndpoint endpoint) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
34 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
35 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
36 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
37 private class SilverlightFaultMessageInspector : IDispatchMessageInspector |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
38 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
39 public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
40 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
41 return null; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
42 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
43 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
44 public void BeforeSendReply(ref Message reply, object correlationState) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
45 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
46 if ((reply != null) && reply.IsFault) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
47 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
48 HttpResponseMessageProperty property = new HttpResponseMessageProperty(); |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
49 property.StatusCode = HttpStatusCode.OK; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
50 reply.Properties[HttpResponseMessageProperty.Name] = property; |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
51 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
52 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
53 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
54 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
55 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
56 public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
57 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
58 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
59 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
60 public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
61 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
62 foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
63 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
64 endpoint.Behaviors.Add(new SilverlightFaultEndpointBehavior()); |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
65 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
66 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
67 |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
68 public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
69 { |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
70 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
71 } |
502f5f365649
Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
72 } |