Support ability to scope how global behaviors are applied to clients and services...
[castle.git] / Facilities / Wcf / Castle.Facilities.WcfIntegration / Service / WcfServiceModel.cs
blob39647e5b25108f7c8ce8f70e6fbb0e43b4fb0c87
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Facilities.WcfIntegration
17 using System;
18 using System.Collections.Generic;
20 public class WcfServiceModel : IWcfServiceModel
22 private bool hosted;
23 private ICollection<Uri> baseAddresses;
24 private ICollection<IWcfEndpoint> endpoints;
25 private ICollection<IWcfBehavior> behaviors;
27 #region IWcfServiceModel
29 public bool IsHosted
31 get { return hosted; }
34 public ICollection<Uri> BaseAddresses
36 get
38 if (baseAddresses == null)
40 baseAddresses = new List<Uri>();
42 return baseAddresses;
44 set { baseAddresses = value; }
47 public ICollection<IWcfEndpoint> Endpoints
49 get
51 if (endpoints == null)
53 endpoints = new List<IWcfEndpoint>();
55 return endpoints;
57 set { endpoints = value; }
60 public ICollection<IWcfBehavior> Behaviors
62 get
64 if (behaviors == null)
66 behaviors = new List<IWcfBehavior>();
68 return behaviors;
72 #endregion
74 public WcfServiceModel Hosted()
76 hosted = true;
77 return this;
80 public WcfServiceModel AddBaseAddresses(params Uri[] baseAddresses)
82 foreach (Uri baseAddress in baseAddresses)
84 BaseAddresses.Add(baseAddress);
86 return this;
89 public WcfServiceModel AddBaseAddresses(params string[] baseAddresses)
91 foreach (string baseAddress in baseAddresses)
93 BaseAddresses.Add(new Uri(baseAddress, UriKind.Absolute));
95 return this;
99 public WcfServiceModel AddEndpoints(params IWcfEndpoint[] endpoints)
101 foreach (IWcfEndpoint endpoint in endpoints)
103 Endpoints.Add(endpoint);
105 return this;
108 public WcfServiceModel AddBehaviors(params object[] behaviors)
110 foreach (object behavior in behaviors)
112 Behaviors.Add(WcfExplcitBehavior.CreateFrom(behavior));
114 return this;