//
// Author: Atsushi Enomoto <atsushi@ximian.com>
//
-// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2009,2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
namespace System.ServiceModel.Discovery.Version11
{
+ [XmlSchemaProvider ("GetSchema")]
public class DiscoveryMessageSequence11 : IXmlSerializable
{
public static DiscoveryMessageSequence11 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
{
- throw new NotImplementedException ();
+ return new DiscoveryMessageSequence11 (discoveryMessageSequence);
+ }
+
+ static readonly DiscoveryVersion version = DiscoveryVersion.WSDiscovery11;
+ static XmlSchema schema;
+
+ static XmlSchema Schema {
+ get {
+ if (schema == null)
+ schema = DiscoveryMessageSequence.BuildSchema (version);
+ return schema;
+ }
}
public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
{
- throw new NotImplementedException ();
+ schemaSet.Add (Schema);
+ return new XmlQualifiedName ("AppSequenceType", version.Namespace);
+ }
+
+ // for deserialization
+ DiscoveryMessageSequence11 ()
+ {
}
- internal DiscoveryMessageSequence11 ()
+ internal DiscoveryMessageSequence11 (DiscoveryMessageSequence source)
{
- throw new NotImplementedException ();
+ this.source = source;
}
+ DiscoveryMessageSequence source;
+
public XmlSchema GetSchema ()
{
- throw new NotImplementedException ();
+ return Schema;
}
public void ReadXml (XmlReader reader)
{
- throw new NotImplementedException ();
+ source = DiscoveryMessageSequence.ReadXml (reader, version);
}
public DiscoveryMessageSequence ToDiscoveryMessageSequence ()
{
- throw new NotImplementedException ();
+ if (source == null)
+ throw new InvalidOperationException ("Call ReadXml method first to fill its contents");
+ return source;
}
public void WriteXml (XmlWriter writer)
{
- throw new NotImplementedException ();
+ source.WriteXml (writer);
}
}
}
//
// Author: Atsushi Enomoto <atsushi@ximian.com>
//
-// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2009,2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
namespace System.ServiceModel.Discovery.VersionApril2005
{
+ [XmlSchemaProvider ("GetSchema")]
public class DiscoveryMessageSequenceApril2005 : IXmlSerializable
{
public static DiscoveryMessageSequenceApril2005 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
{
- throw new NotImplementedException ();
+ return new DiscoveryMessageSequenceApril2005 (discoveryMessageSequence);
+ }
+
+ static readonly DiscoveryVersion version = DiscoveryVersion.WSDiscoveryApril2005;
+ static XmlSchema schema;
+
+ static XmlSchema Schema {
+ get {
+ if (schema == null)
+ schema = DiscoveryMessageSequence.BuildSchema (version);
+ return schema;
+ }
}
public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
{
- throw new NotImplementedException ();
+ schemaSet.Add (Schema);
+ return new XmlQualifiedName ("AppSequenceType", version.Namespace);
}
- internal DiscoveryMessageSequenceApril2005 ()
+ internal DiscoveryMessageSequenceApril2005 (DiscoveryMessageSequence source)
{
- throw new NotImplementedException ();
+ this.source = source;
}
+ DiscoveryMessageSequence source;
+
public XmlSchema GetSchema ()
{
- throw new NotImplementedException ();
+ return Schema;
}
public void ReadXml (XmlReader reader)
{
- throw new NotImplementedException ();
+ source = DiscoveryMessageSequence.ReadXml (reader, version);
}
public DiscoveryMessageSequence ToDiscoveryMessageSequence ()
{
- throw new NotImplementedException ();
+ if (source == null)
+ throw new InvalidOperationException ("Call ReadXml method first to fill its contents");
+ return source;
}
public void WriteXml (XmlWriter writer)
{
- throw new NotImplementedException ();
+ source.WriteXml (writer);
}
}
}
//
// Author: Atsushi Enomoto <atsushi@ximian.com>
//
-// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2009,2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
namespace System.ServiceModel.Discovery.VersionCD1
{
+ [XmlSchemaProvider ("GetSchema")]
public class DiscoveryMessageSequenceCD1 : IXmlSerializable
{
public static DiscoveryMessageSequenceCD1 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
{
- throw new NotImplementedException ();
+ return new DiscoveryMessageSequenceCD1 (discoveryMessageSequence);
+ }
+
+ static readonly DiscoveryVersion version = DiscoveryVersion.WSDiscoveryCD1;
+ static XmlSchema schema;
+
+ static XmlSchema Schema {
+ get {
+ if (schema == null)
+ schema = DiscoveryMessageSequence.BuildSchema (version);
+ return schema;
+ }
}
public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
{
- throw new NotImplementedException ();
+ schemaSet.Add (Schema);
+ return new XmlQualifiedName ("AppSequenceType", version.Namespace);
+ }
+
+ // for deserialization
+ DiscoveryMessageSequenceCD1 ()
+ {
}
- internal DiscoveryMessageSequenceCD1 ()
+ internal DiscoveryMessageSequenceCD1 (DiscoveryMessageSequence source)
{
- throw new NotImplementedException ();
+ this.source = source;
}
+ DiscoveryMessageSequence source;
+
public XmlSchema GetSchema ()
{
- throw new NotImplementedException ();
+ return Schema;
}
public void ReadXml (XmlReader reader)
{
- throw new NotImplementedException ();
+ source = DiscoveryMessageSequence.ReadXml (reader, version);
}
public DiscoveryMessageSequence ToDiscoveryMessageSequence ()
{
- throw new NotImplementedException ();
+ if (source == null)
+ throw new InvalidOperationException ("Call ReadXml method first to fill its contents");
+ return source;
}
public void WriteXml (XmlWriter writer)
{
- throw new NotImplementedException ();
+ source.WriteXml (writer);
}
}
}
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
namespace System.ServiceModel.Discovery
{
{
return messageSequence1 == null ? messageSequence2 != null : !messageSequence1.Equals (messageSequence2);
}
+
+ internal static DiscoveryMessageSequence ReadXml (XmlReader reader, DiscoveryVersion version)
+ {
+ if (reader == null)
+ throw new ArgumentNullException ("reader");
+ if (reader.LocalName != "AppSequenceType" || reader.NamespaceURI != version.Namespace)
+ throw new ArgumentException (String.Format ("AppSequenceType element in namespace '{0}' was expected. Got '{1}' element in '{2}' namespace", version.Namespace, reader.LocalName, reader.NamespaceURI));
+
+ var instId = reader.GetAttribute ("InstanceId");
+ var seqId = reader.GetAttribute ("SequenceId");
+ var msgno = reader.GetAttribute ("MessageNumber");
+ var source = new DiscoveryMessageSequence (instId != null ? XmlConvert.ToInt64 (instId) : 0, seqId != null ? new Uri (seqId, UriKind.RelativeOrAbsolute) : null, msgno != null ? XmlConvert.ToInt64 (msgno) : 0);
+
+ reader.Skip ();
+ return source;
+ }
+
+ internal void WriteXml (XmlWriter writer)
+ {
+ writer.WriteAttributeString ("InstanceId", XmlConvert.ToString (InstanceId));
+ if (SequenceId != null)
+ writer.WriteAttributeString ("SequenceId", SequenceId.ToString ());
+ writer.WriteAttributeString ("MessageNumber", XmlConvert.ToString (MessageNumber));
+ }
+
+ internal static XmlSchema BuildSchema (DiscoveryVersion version)
+ {
+ var schema = new XmlSchema () { TargetNamespace = version.Namespace };
+ var ccr = new XmlSchemaComplexContentRestriction ();
+ ccr.Attributes.Add (new XmlSchemaAttribute () { Name = "InstanceId", SchemaTypeName = new XmlQualifiedName ("unsignedInt", XmlSchema.Namespace), Use = XmlSchemaUse.Required });
+ ccr.Attributes.Add (new XmlSchemaAttribute () { Name = "SequenceId", SchemaTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace), Use = XmlSchemaUse.Optional });
+ ccr.Attributes.Add (new XmlSchemaAttribute () { Name = "MessageNumber", SchemaTypeName = new XmlQualifiedName ("unsignedInt", XmlSchema.Namespace), Use = XmlSchemaUse.Required });
+ var ct = new XmlSchemaComplexType () { Name = "AppSequenceType", ContentModel = new XmlSchemaComplexContent () { Content = ccr } };
+ schema.Items.Add (ct);
+
+ return schema;
+ }
}
}