JavaScriptObject.cs
上传用户:szgaoree
上传日期:2009-01-05
资源大小:74k
文件大小:2k
- /*
- * MS 06-04-03 return the correct .Value
- *
- *
- */
- using System;
- using System.Collections;
- using System.Collections.Specialized;
- namespace AjaxPro
- {
- /// <summary>
- /// Represents a JavaScript ECMA object.
- /// </summary>
- public class JavaScriptObject : IJavaScriptObject
- {
- private HybridDictionary list = new HybridDictionary();
- private StringCollection keys = new StringCollection();
- /// <summary>
- /// Initializes a new JavaScript object instance.
- /// </summary>
- public JavaScriptObject() : base()
- {
- }
- /// <summary>
- /// Returns the string representation of the object.
- /// </summary>
- public string Value
- {
- get
- {
- return JavaScriptSerializer.Serialize(list);
- }
- }
- #region IDictionary Members
- /// <summary>
- /// Returns the object defined for the name of the property.
- /// </summary>
- public object this[string key]
- {
- get
- {
- return list[key];
- }
- }
- /// <summary>
- /// Verify if the property does exist in the object.
- /// </summary>
- /// <param name="key">The name of the property.</param>
- /// <returns>Returns true if the property is defined.</returns>
- public bool Contains(string key)
- {
- return list.Contains(key);
- }
- /// <summary>
- /// Adds a new property to the object.
- /// </summary>
- /// <param name="key">The name of the property.</param>
- /// <param name="value">The value of the property.</param>
- public void Add(string key, object value)
- {
- list.Add(key, value);
- keys.Add(key);
- }
- /// <summary>
- /// Returns all keys that are used internal for the name of properties.
- /// </summary>
- public string[] Keys
- {
- get
- {
- string[] _keys = new string[keys.Count];
- keys.CopyTo(_keys, 0);
- return _keys;
- }
- }
- public bool IsFixedSize
- {
- get
- {
- return false;
- }
- }
- #endregion
- }
- }