ijavascriptconverter.cs

来自「AJAX开发工具包」· CS 代码 · 共 73 行

CS
73
字号
using System;
using System.Text;
using System.Collections;

namespace AjaxPro
{
	/// <summary>
	/// Represents an IJavaScriptConverter.
	/// </summary>
	public class IJavaScriptConverter
	{
		/// <summary>
		/// Initializes the converter. This method will be called when the application is starting and 
		/// any converter is loaded.
		/// </summary>
		public virtual void Initialize()
		{
		}

		/// <summary>
		/// Render the JavaScript code for prototypes or any other JavaScript method needed from this converter
		/// on the client-side.
		/// </summary>
		/// <returns>Returns JavaScript code.</returns>
		public virtual string GetClientScript()
		{
			return "";
		}

		/// <summary>
		/// Converts an IJavaScriptObject into an NET object.
		/// </summary>
		/// <param name="o">The IJavaScriptObject object to convert.</param>
		/// <param name="type">The type to convert the object to.</param>
		/// <returns>Returns a .NET object.</returns>
		public virtual object Deserialize(IJavaScriptObject o, Type t)
		{
			return null;
		}

		/// <summary>
		/// Converts a .NET object into a JSON string.
		/// </summary>
		/// <param name="o">The object to convert.</param>
		/// <returns>Returns a JSON string.</returns>
		public virtual string Serialize(object o)
		{
			throw new NotImplementedException("Converter for type '" + o.GetType().FullName + "'.");
		}

		/// <summary>
		/// Returns every type that can be used with this converter to serialize an object.
		/// </summary>
		public virtual Type[] SerializableTypes
		{
			get
			{
				return null;
			}
		}

		/// <summary>
		/// Returns every type that can be used with this converter to deserialize an JSON string.
		/// </summary>
		public virtual Type[] DeserializableTypes
		{
			get
			{
				return null;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?