المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How can I copy a multidimensional List



C# Programming
01-22-2010, 12:22 AM
How can I copy a multidimensional List ?

public class DSensingDataCollection
{
private string _DAreaID;
private string _DModel1;
private string _DModel2;
private string _DModel3;
private string _DDeviceID;
private string _DDeviceType;
private bool _DIsNow;
private int _DResult;
private int _DSeq;
private int _DSensorCount;
private List _DSensingData;

public string DAreaID
{
get { return _DAreaID; }
set { _DAreaID = value; }
}

public string DModel1
{
get { return _DModel1; }
set { _DModel1 = value; }
}

public string DModel2
{
get { return _DModel2; }
set { _DModel2 = value; }
}

public string DModel3
{
get { return _DModel3; }
set { _DModel3 = value; }
}

public string DDeviceID
{
get { return _DDeviceID; }
set { _DDeviceID = value; }
}

public string DDeviceType
{
get { return _DDeviceType; }
set { _DDeviceType = value; }
}

public bool DIsNow
{
get { return _DIsNow; }
set { _DIsNow = value; }
}

public int DResult
{
get { return _DResult; }
set { _DResult = value; }
}

public int DSeq
{
get { return _DSeq; }
set { _DSeq = value; }
}

public int DSensorCount
{
get { return _DSensorCount; }
set { _DSensorCount = value; }
}

public List DSensingData
{
get { return _DSensingData; }
set { _DSensingData = value; }
}

public DSensingDataCollection()
{
this.DAreaID = "";
this.DModel1 = "";
this.DModel2 = "";
this.DModel3 = "";
this.DDeviceID = "";
this.DDeviceType = "";
this.DIsNow = true;
this.DResult = 0;
this.DSeq = 0;
this.DSensorCount = 0;
this.DSensingData = new List();
}
}

public class DSensingData
{
private string _DSensorTypeID;
private string _DMinValue;
private string _DMaxValue;
private int _DSlot;
private float _DValue;
private float _DDelta;

public string DSensorTypeID
{
get { return _DSensorTypeID; }
set { _DSensorTypeID = value; }
}

public string DMinValue
{
get { return _DMinValue; }
set { _DMinValue = value; }
}

public string DMaxValue
{
get { return _DMaxValue; }
set { _DMaxValue = value; }
}

public int DSlot
{
get { return _DSlot; }
set { _DSlot = value; }
}

public float DValue
{
get { return _DValue; }
set { this._DValue = value; }
}

public float DDelta
{
get { return _DDelta; }
set { this._DDelta = value; }
}

public DSensingData()
{
this._DSensorTypeID = "";
this._DMinValue = "";
this._DMaxValue = "";
this._DSlot = 0;
this._DValue = 0;
this._DDelta = 0;
}

public DSensingData(string _DSensorTypeID, string _DMinValue, string _DMaxValue, int _DSlot, float _DValue, float _DDelta)
{
this._DSensorTypeID = _DSensorTypeID;
this._DMinValue = _DMinValue;
this._DMaxValue = _DMaxValue;
this._DSlot = _DSlot;
this._DValue = _DValue;
this._DDelta = _DDelta;
}
}


public class DDeviceData
{
private string _DeviceID;
private DBufferData _DBufferData;

public string DeviceID
{
get { return _DeviceID; }
set { _DeviceID = value; }
}

public DBufferData DBufferData
{
get { return _DBufferData; }
set { _DBufferData = value; }
}

public DDeviceData()
{
this._DeviceID = "";
this._DBufferData = new DBufferData();
}

public DDeviceData(string param)
{
this._DBufferData = new DBufferData();

if (uHeader.gDevice.ContainsKey(param) == false)
{
this._DBufferData = new DBufferData();
uHeader.gDevice.Add(param, this._DBufferData);
}
else
{
IDictionaryEnumerator items = uHeader.gDevice.GetEnumerator();

while (items.MoveNext())
{
if (items.Key.ToString().Equals(param))
{
this._DBufferData = (DBufferData)items.Value;
}
}


this.DBufferData.DSensingDataCol3.Clear();
-- First and second array to array


this.DBufferData.DSensingDataCol2.Clear();
-- 0 the first array to array


this._DBufferData.DSensingDataCol1.Clear();
}

DSensingDataCollection input1 = new DSensingDataCollection();
input1.DAreaID = "1234";
input1.DDeviceID = "1234";
input1.DDeviceType = "edv";
input1.DIsNow = true;
input1.DModel1 = "fm001";
input1.DModel2 = "fm002";
input1.DModel3 = "fm003";
input1.DResult = 0;
input1.DSensorCount = 8;
input1.DSeq = 3;

input1.DSensingData.AddRange(new DSensingData[]{
new DSensingData("edv","34.1", "45.1", 0, 12.9f, 10.8f)});

this.DBufferData.DSensingDataCol1.Add(input1);

DSensingDataCollection input2 = new DSensingDataCollection();
input2.DAreaID = "2234";
input2.DDeviceID = "2234";
input2.DDeviceType = "edv";
input2.DIsNow = true;
input2.DModel1 = "fm001";
input2.DModel2 = "fm002";
input2.DModel3 = "fm003";
input2.DResult = 0;
input2.DSensorCount = 8;
input2.DSeq = 3;

input2.DSensingData.AddRange(new DSensingData[]{
new DSensingData("edv","11.1", "12.1", 0, 3.5f, 4.2f)});

this.DBufferData.DSensingDataCol1.Add(input2);
}
}

public class DBufferData
{
private List _DSensingDataCol1;
private List _DSensingDataCol2;
private List _DSensingDataCol3;

public List DSensingDataCol1
{
get { return _DSensingDataCol1; }
set { _DSensingDataCol1 = value; }
}

public List DSensingDataCol2
{
get { return _DSensingDataCol2; }
set { _DSensingDataCol2 = value; }
}

public List DSensingDataCol3
{
get { return _DSensingDataCol3; }
set { _DSensingDataCol3 = value; }
}

public DBufferData()
{
this._DSensingDataCol1 = new List();
this._DSensingDataCol2 = new List();
this._DSensingDataCol3 = new List();
}
}

class Program
{
static void Main(string[] args)
{
string deviceid = "53410101";

DDeviceData ar = new DDeviceData(deviceid);


DDeviceData br = new DDeviceData(deviceid);
}
}