You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using Mesnac.Equips;
|
|
using Mesnac.Equips.BaseInfo;
|
|
using System.Runtime.InteropServices;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Mesnac.Equip.ConfigInfo.WriteRead.Default
|
|
{
|
|
public class Equip : BaseEquip
|
|
{
|
|
public override bool Open()
|
|
{
|
|
BlockLst = new Dictionary<string, object>();
|
|
return true;
|
|
}
|
|
|
|
private Dictionary<string, object> BlockLst = new Dictionary<string, object>();
|
|
|
|
public override bool Read(string block, int start, int len, out object[] buff)
|
|
{
|
|
buff = new object[len];
|
|
object oBlockDictionary = null;
|
|
if (BlockLst.TryGetValue(block, out oBlockDictionary))
|
|
{
|
|
if (oBlockDictionary is Dictionary<int, object>)
|
|
{
|
|
Dictionary<int, object> BlockDictionary = oBlockDictionary as Dictionary<int, object>;
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
object obj = null;
|
|
if (BlockDictionary.TryGetValue(i + start, out obj))
|
|
{
|
|
buff[i] = obj;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
public override bool Write(int block, int start, object[] buff)
|
|
{
|
|
Dictionary<int, object> BlockDictionary = new Dictionary<int, object>();
|
|
object oBlockDictionary = null;
|
|
if (BlockLst.TryGetValue(block.ToString(), out oBlockDictionary))
|
|
{
|
|
if (oBlockDictionary is Dictionary<int, object>)
|
|
{
|
|
BlockDictionary = oBlockDictionary as Dictionary<int, object>;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
BlockLst.Add(block.ToString(), BlockDictionary);
|
|
}
|
|
for (int i = 0; i < buff.Length; i++)
|
|
{
|
|
if (BlockDictionary.ContainsKey(i + start))
|
|
{
|
|
BlockDictionary[i + start] = buff[i];
|
|
}
|
|
else
|
|
{
|
|
BlockDictionary.Add(i + start, buff[i]);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
public override void Close()
|
|
{
|
|
BlockLst = new Dictionary<string, object>();
|
|
}
|
|
}
|
|
}
|