JavaScriptConverterAttribute.cs
上传用户:szgaoree
上传日期:2009-01-05
资源大小:74k
文件大小:1k
- using System;
- namespace AjaxPro
- {
- /// <summary>
- /// Represents an attribute to mark a class to be converted by a specified IJavaScriptConverter.
- /// </summary>
- [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
- public class JavaScriptConverterAttribute : Attribute
- {
- private Type type = null;
- /// <summary>
- /// Marks a class to be converted by the specified JavaScript converter.
- /// </summary>
- /// <param name="type">The IJavaScriptConverter to use to serialize or deserialize.</param>
- public JavaScriptConverterAttribute(Type type)
- {
- if(!(typeof(IJavaScriptConverter).IsAssignableFrom(type)))
- throw new InvalidCastException();
- this.type = type;
- }
- #region Internal Methods
- internal IJavaScriptConverter Converter
- {
- get
- {
- object o = Activator.CreateInstance(type);
- return (IJavaScriptConverter)o;
- }
- }
- #endregion
- }
- }