1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
// License: BSD/LGPL
// Copyright (C) 2011-2018 Thomas d'Otreppe
using System;
using System.Collections;
namespace WirelessPanda
{
public abstract class WirelessDevice
{
#region Dictionary stuff
/// <summary>
/// Keep track of the last position for the column
/// </summary>
private int _lastPosition = 0;
/// <summary>
/// Dictionary containing all values
/// </summary>
protected Hashtable _fieldsDictionary = new Hashtable();
/// <summary>
/// Order of the columns
/// </summary>
protected Hashtable _fieldsOrder = new Hashtable();
/// <summary>
/// Sets a value in the dictionary
/// </summary>
/// <param name="key">Key</param>
/// <param name="value">Value</param>
protected void setDictValue(string key, object value)
{
if (this._fieldsDictionary.ContainsKey(key))
{
this._fieldsDictionary.Remove(key);
}
else
{
// Save the position for the column (useful when creating the dataset)
this._fieldsOrder.Add(this._lastPosition++, key);
}
this._fieldsDictionary.Add(key, value);
}
/// <summary>
/// Return a value in the dictionary
/// </summary>
/// <param name="key">Key</param>
/// <returns>Object value</returns>
/// <exception cref="MissingFieldException"></exception>
protected object getDictValue(string key)
{
if (this._fieldsDictionary.ContainsKey(key))
{
return this._fieldsDictionary[key];
}
throw new MissingFieldException("Value for <" + key + "> is not set or does not exist");
}
/// <summary>
/// Returns a copy of the dictionary
/// </summary>
internal Hashtable FieldsDictionary
{
get
{
return this._fieldsDictionary as Hashtable;
}
}
/// <summary>
/// Returns a copy of the column order
/// </summary>
internal Hashtable FieldsOrder
{
get
{
return this._fieldsOrder as Hashtable;
}
}
#endregion
#region Properties
public string BSSID
{
get
{
return (string)this.getDictValue("BSSID");
}
set
{
this.setDictValue("BSSID", value);
if (value != null)
{
// Special case, not associated
if (value.Trim() == "(not associated)")
{
this.setDictValue("BSSID", string.Empty);
}
else
{
this.setDictValue("BSSID", value.Trim());
}
}
}
}
public DateTime FirstTimeSeen
{
get
{
return (DateTime)this.getDictValue("First Time Seen");
}
set
{
this.setDictValue("First Time Seen", value);
}
}
public DateTime LastTimeSeen
{
get
{
return (DateTime)this.getDictValue("Last Time Seen");
}
set
{
this.setDictValue("Last Time Seen", value);
}
}
public int Channel
{
get
{
return (int)this.getDictValue("Channel");
}
set
{
this.setDictValue("Channel", value);
}
}
public ulong TotalFrames
{
get
{
return (ulong)this.getDictValue("Total Frames");
}
set
{
this.setDictValue("Total Frames", value);
}
}
public Coordinates Location
{
get
{
return (Coordinates)this.getDictValue("Location");
}
set
{
this.setDictValue("Location", value);
}
}
public int Power
{
get
{
return (int)this.getDictValue("Power");
}
set
{
this.setDictValue("Power", value);
}
}
#endregion
}
}
|