2005-09-27 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Wed, 28 Sep 2005 02:38:09 +0000 (02:38 -0000)
committerChris Toshok <toshok@novell.com>
Wed, 28 Sep 2005 02:38:09 +0000 (02:38 -0000)
* Microsoft.Web.Services/JavaScriptObjectDeserializer.cs: new
file.

* Microsoft.Web.Services/JavaScriptConverter.cs: new file.

* Microsoft.Web.Services.Converters/DateTimeConverter.cs: new
file.

svn path=/trunk/mcs/; revision=50911

mcs/class/Microsoft.Web.Atlas/ChangeLog
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services.Converters/DateTimeConverter.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services/JavaScriptConverter.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services/JavaScriptObjectDeserializer.cs [new file with mode: 0644]

index 5b0d6baac902a6555ff17d873475038b6412110a..549d1dd8d02a60d430ee6d9189678b2955588009 100644 (file)
@@ -1,3 +1,13 @@
+2005-09-27  Chris Toshok  <toshok@ximian.com>
+
+       * Microsoft.Web.Services/JavaScriptObjectDeserializer.cs: new
+       file.
+
+       * Microsoft.Web.Services/JavaScriptConverter.cs: new file.
+
+       * Microsoft.Web.Services.Converters/DateTimeConverter.cs: new
+       file.
+       
 2005-09-27  Chris Toshok  <toshok@ximian.com>
 
        * Microsoft.Web/ScriptEvent.cs (RenderActions): remove the
diff --git a/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services.Converters/DateTimeConverter.cs b/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services.Converters/DateTimeConverter.cs
new file mode 100644 (file)
index 0000000..855a696
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// Microsoft.Web.Services.Converters.DateTimeConverter
+//
+// Author:
+//   Chris Toshok (toshok@ximian.com)
+//
+//
+// Copyright (C) 2005 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Web;
+using Microsoft.Web.Services;
+
+namespace Microsoft.Web.Services.Converters
+{
+       public class DateTimeConverter : JavaScriptConverter
+       {
+               public DateTimeConverter ()
+               {
+               }
+
+               public override object Deserialize (string s, Type t)
+               {
+                       return JavaScriptObjectDeserializer.Deserialize (s, t);
+               }
+
+               protected override string GetClientTypeName (Type serverType)
+               {
+                       return "Date";
+               }
+
+               protected override void Initialize ()
+               {
+               }
+
+               public override string Serialize (object o)
+               {
+                       if (o == null || o.GetType () != typeof (DateTime))
+                               throw new ArgumentException ("Value does not fall within the expected range.");
+
+                       DateTime dt = (DateTime)o;
+
+                       return String.Format ("new Date({0},{1},{2},{3},{4},{5})",
+                                             dt.Year, dt.Month - 1, dt.Day, dt.Hour, dt.Minute, dt.Second);
+               }
+
+               public string JavaScript {
+                       get {
+                               return null;
+                       }
+
+               }
+
+               Type[] supportedTypes;
+               protected override Type[] SupportedTypes {
+                       get {
+                               if (supportedTypes == null) {
+                                       supportedTypes = new Type[1];
+                                       supportedTypes[0] = typeof (DateTime);
+                               }
+
+                               return supportedTypes;
+                       }
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services/JavaScriptConverter.cs b/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services/JavaScriptConverter.cs
new file mode 100644 (file)
index 0000000..476ac42
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// Microsoft.Web.Services.JavaScriptConverter
+//
+// Author:
+//   Chris Toshok (toshok@ximian.com)
+//
+//
+// Copyright (C) 2005 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Web;
+
+namespace Microsoft.Web.Services
+{
+       public abstract class JavaScriptConverter
+       {
+               protected JavaScriptConverter ()
+               {
+               }
+
+               public virtual object Deserialize (string s, Type t)
+               {
+                       return null;
+               }
+
+               public object Deserialize (string s)
+               {
+                       return Deserialize (s, null);
+               }
+
+               protected virtual string GetClientTypeName (Type serverType)
+               {
+                       return null;
+               }
+
+               internal static JavaScriptConverter GetConverter (Type t)
+               {
+                       return null;
+               }
+
+               public static string GetConverterScript (Type t)
+               {
+                       return null;
+               }
+
+               protected virtual void Initialize ()
+               {
+               }
+
+               protected void RegisterJavaScript (string javascript)
+               {
+               }
+
+               public virtual string Serialize (object o)
+               {
+                       return null;
+               }
+
+               public string JavaScript {
+                       get {
+                               return null;
+                       }
+
+               }
+
+               protected virtual Type[] SupportedTypes {
+                       get {
+                               return null;
+                       }
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services/JavaScriptObjectDeserializer.cs b/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.Services/JavaScriptObjectDeserializer.cs
new file mode 100644 (file)
index 0000000..a8295ff
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Microsoft.Web.Services.JavaScriptObjectDeserializer
+//
+// Author:
+//   Chris Toshok (toshok@ximian.com)
+//
+//
+// Copyright (C) 2005 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Web;
+
+namespace Microsoft.Web.Services
+{
+       public class JavaScriptObjectDeserializer
+       {
+               public static object Deserialize (string input, Type t)
+               {
+                       return null;
+               }
+
+               public static object Deserialize (string input)
+               {
+                       return null;
+               }
+
+               public static bool IsClientInstantiatableType (Type t)
+               {
+                       return false;
+               }
+       }
+}
+
+#endif