2 // WebReferenceOptions.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 Novell, Inc.
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System
.ComponentModel
;
36 using System
.Collections
.Specialized
;
37 using System
.Web
.Services
;
39 using System
.Xml
.Schema
;
40 using System
.Xml
.Serialization
;
42 namespace System
.Web
.Services
.Description
44 [XmlRoot ("webReferenceOptions", Namespace
= "http://microsoft.com/webReference/")]
45 [XmlType ("webReferenceOptions", Namespace
= "http://microsoft.com/webReference/")]
46 public class WebReferenceOptions
48 #region Static members
49 static XmlSchema schema
;
50 static XmlSerializerImplementation implementation
=
51 new WebReferenceOptionsSerializerImplementation ();
53 public const string TargetNamespace
= "http://microsoft.com/webReference/";
55 public static XmlSchema Schema
{
58 schema
= XmlSchema
.Read (typeof (ServiceDescription
).Assembly
.GetManifestResourceStream ("web-reference.xsd"), null);
64 public static WebReferenceOptions
Read (Stream stream
, ValidationEventHandler validationEventHandler
)
66 return Read (XmlReader
.Create (stream
), validationEventHandler
);
69 public static WebReferenceOptions
Read (TextReader reader
, ValidationEventHandler validationEventHandler
)
71 return Read (XmlReader
.Create (reader
), validationEventHandler
);
74 public static WebReferenceOptions
Read (XmlReader xmlReader
,
75 ValidationEventHandler validationEventHandler
)
77 XmlReaderSettings s
= new XmlReaderSettings ();
78 s
.ValidationType
= ValidationType
.Schema
;
79 s
.Schemas
.Add (Schema
);
80 if (validationEventHandler
!= null)
81 s
.ValidationEventHandler
+= validationEventHandler
;
82 using (XmlReader r
= XmlReader
.Create (xmlReader
, s
)) {
83 XmlSerializer ser
= implementation
.GetSerializer (typeof (WebReferenceOptions
));
85 return (WebReferenceOptions
) ser
.Deserialize (r
);
86 } catch (XmlSchemaValidationException ex
) {
87 throw new InvalidOperationException ("There is an error in input webReference XML", ex
);
94 #region Instance members
96 CodeGenerationOptions code_options
;
97 StringCollection importer_extensions
= new StringCollection ();
98 ServiceDescriptionImportStyle style
;
101 [XmlElement ("codeGenerationOptions")]
102 [DefaultValue (CodeGenerationOptions
.GenerateOldAsync
)]
103 public CodeGenerationOptions CodeGenerationOptions
{
104 get { return code_options; }
105 set { code_options = value; }
108 [XmlArray ("schemaImporterExtensions")]
109 [XmlArrayItem ("type")]
110 public StringCollection SchemaImporterExtensions
{
111 get { return importer_extensions; }
114 [XmlElement ("style")]
115 [DefaultValue (ServiceDescriptionImportStyle
.Client
)]
116 public ServiceDescriptionImportStyle Style
{
117 get { return style; }
118 set { style = value; }
121 [XmlElement ("verbose")]
122 public bool Verbose
{
123 get { return verbose; }
124 set { verbose = value; }