2 // Author: Atsushi Enomoto <atsushi@ximian.com>
4 // Copyright (C) 2010 Novell, Inc (http://www.novell.com)
6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the
8 // "Software"), to deal in the Software without restriction, including
9 // without limitation the rights to use, copy, modify, merge, publish,
10 // distribute, sublicense, and/or sell copies of the Software, and to
11 // permit persons to whom the Software is furnished to do so, subject to
12 // the following conditions:
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 using System.ComponentModel;
28 using System.Configuration;
29 using System.ServiceModel.Configuration;
31 using System.Xml.Linq;
33 namespace System.ServiceModel.Discovery.Configuration
35 public sealed class EndpointDiscoveryElement : BehaviorExtensionElement
37 static ConfigurationPropertyCollection properties;
38 static ConfigurationProperty types, enabled, extensions, scopes;
40 static EndpointDiscoveryElement ()
42 types = new ConfigurationProperty ("types", typeof (ContractTypeNameElementCollection), null, null, null, ConfigurationPropertyOptions.None);
43 enabled = new ConfigurationProperty ("enabled", typeof (bool), null, null, null, ConfigurationPropertyOptions.None);
44 extensions = new ConfigurationProperty ("extensions", typeof (XmlElementElementCollection), null, null, null, ConfigurationPropertyOptions.None);
45 scopes = new ConfigurationProperty ("scopes", typeof (ScopeElementCollection), null, null, null, ConfigurationPropertyOptions.None);
46 properties = new ConfigurationPropertyCollection ();
47 properties.Add (types);
48 properties.Add (enabled);
49 properties.Add (extensions);
50 properties.Add (scopes);
53 public EndpointDiscoveryElement ()
57 public override Type BehaviorType {
58 get { return typeof (EndpointDiscoveryBehavior); }
61 [ConfigurationProperty ("types")]
62 public ContractTypeNameElementCollection ContractTypeNames {
63 get { return (ContractTypeNameElementCollection) base [types]; }
66 [ConfigurationPropertyAttribute("enabled", DefaultValue = true)]
68 get { return (bool) base [enabled]; }
69 set { base [enabled] = value; }
72 [ConfigurationPropertyAttribute("extensions")]
73 public XmlElementElementCollection Extensions {
74 get { return (XmlElementElementCollection) base [extensions]; }
77 [ConfigurationPropertyAttribute("scopes")]
78 public ScopeElementCollection Scopes {
79 get { return (ScopeElementCollection) base [scopes]; }
82 protected override ConfigurationPropertyCollection Properties {
83 get { return properties; }
86 protected internal override object CreateBehavior ()
88 var ret = new EndpointDiscoveryBehavior () { Enabled = this.Enabled };
89 foreach (ContractTypeNameElement ctn in ContractTypeNames)
90 ret.ContractTypeNames.Add (new XmlQualifiedName (ctn.Name, ctn.Namespace));
91 foreach (XmlElementElement xee in Extensions)
92 ret.Extensions.Add (XElement.Load (new XmlNodeReader (xee.XmlElement)));
93 foreach (ScopeElement se in Scopes)
94 ret.Scopes.Add (se.Scope);