Silverlight 下创建Hashtable
来源:互联网 发布:如何连接网络投影仪 编辑:程序博客网 时间:2024/06/05 04:07
using System;using System.Collections;using System.Collections.Generic;using System.Linq;namespace SFire.Framework{ /// <summary> /// Silverlight下使用的哈希表 /// 创建者:sucsy /// 创建日期:2012-2-27 /// </summary> public class DataHashtable : IDictionary { List<HashTableItem> table = null; public DataHashtable() { this.table = new List<HashTableItem>(); } public void Add(object key, object value) { if (this.Contains(key) == false) { table.Add ( new HashTableItem() { Key = key, Value = value } ); } else { this[key] = value; } } public void Clear() { table.Clear(); } public bool Contains(object key) { foreach (HashTableItem item in this.table) { if (item.Key!=null && item.Key.Equals(key)) return true; } return false; } public IDictionaryEnumerator GetEnumerator() { return (IDictionaryEnumerator)this.table.ToArray().GetEnumerator(); } public bool IsFixedSize { get { return false; } } public bool IsReadOnly { get { return false; } } public ICollection Keys { get { return this.table.Select(item => item.Key).ToArray(); } } public void Remove(object key) { HashTableItem item = Find(key); if (item != null) this.table.Remove(item); } private HashTableItem Find(object key) { HashTableItem find = null; foreach (HashTableItem item in this.table) { if (item.Key.Equals(key)) { find = item; break; } } return find; } public ICollection Values { get { return this.table.Select(item => item.Value).ToArray(); } } public object this[object key] { get { HashTableItem item = Find(key); if (item != null) return item.Value; return null; } set { HashTableItem item = Find(key); if (item != null) item.Value = value; } } public void CopyTo(Array array, int index) { this.table.CopyTo((HashTableItem[])array, index); } public int Count { get { return this.table.Count; } } public bool IsSynchronized { get { return true; } } public object SyncRoot { get { return null; } } IEnumerator IEnumerable.GetEnumerator() { return this.table.GetEnumerator(); } } #region 哈希表项 /// <summary> /// 哈希表项 /// </summary> public class HashTableItem { /// <summary> /// 关键字 /// </summary> public object Key { get; set; } /// <summary> /// 源对象 /// </summary> public object Value { get; set; } } #endregion}
南京酷得软件
- Silverlight 下创建Hashtable
- Silverlight 下创建Hashtable
- Silverlight 下创建Hashtable
- 在Silverlight 2 Release下用vs.net2008创建Silverlight Application的一个小问题
- 创建和使用HashTable
- 如何创建Silverlight 项目
- 创建一个Silverlight Project
- SilverLight创建childwindow出错
- Silverlight动态创建Chart
- Silverlight 创建 PDF iTextSharp
- silverlight创建动态图
- Hashtable数组创建的方法
- Silverlight 下的 DataSet
- 创建一个Silverlight Carousel控件
- 怎么创建silverlight custom control
- 如何创建新Silverlight项目
- 创建Silverlight自定义启动画面
- Silverlight 2 创建自定义控件
- MySql 查询 时间段 今天、昨天、7天、近30天、本月、上一月
- MSTR安全筛选器权限配置
- Win7下为eclipse配置JDK
- Flex上传图片前浏览
- JQuery插件的写法:我的总结
- Silverlight 下创建Hashtable
- 使用Git管理GitHub上的项目
- 智能处理,探查明确到底有多难
- 孙其功陪你学之--虚拟机突然掉电或者死机后,虚拟机不能正常启动
- [AS3]flash通过ExternalInterface.call方法来获取当前URL地址
- C# 字符串全角 半角转换
- hdu 1267 下沙的沙子有几粒?
- CSS3相关效果整理
- RSA算法的一种实现方式!