|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace KhaledMohamed.Database
{
public class Read : IDisposable
{
private string location = "";
private StreamReader SR;
public int Count = 0;
private string[] items;
private Int32 curent_count = -1;
public Read(string file)
{
location = file;
}
public void Dispose()
{
location = string.Empty;
SR = null;
items = null;
Count = 0;
}
public string[] OutBase() { return items; }
public uint aCount;
public bool UseRead()
{
aCount++;
return items.Length >= aCount;
}
public bool Reader(bool useinvalid = true)
{
string[] data = null;
if (File.Exists(location))
{
try
{
using (SR = File.OpenText(location))
{
Count = int.Parse(SR.ReadLine().Split('=')[1]);
data = new string[Count];
for (int x = 0; x < Count; x++)
{
data[x] = SR.ReadLine();
}
if (Count == 0)
return false;
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
else if (useinvalid)
{
data = null;
Console.WriteLine("Invalid Reader " + location + " location");
return false;
}
items = new string[Count];
for (int x = 0; x < Count; x++)
{
items[x] = data[x];
}
return true;
}
public UInt32 ReadUInt32(UInt32 add_def)
{
curent_count += 1;
if (curent_count < Count)
{
if (items[curent_count] == null)
return add_def;
else
return UInt32.Parse(items[curent_count]);
}
else
return add_def;
}
public UInt16 ReadUInt16(UInt16 add_def)
{
curent_count += 1;
if (curent_count < Count)
{
if (items[curent_count] == null)
return add_def;
else
return UInt16.Parse(items[curent_count]);
}
else
return add_def;
}
public UInt64 ReadUInt64(UInt64 add_def)
{
curent_count += 1;
if (curent_count < Count)
{
if (items[curent_count] == null)
return add_def;
else
return UInt64.Parse(items[curent_count]);
}
else
return add_def;
}
public Byte ReadByte(Byte add_def)
{
curent_count += 1;
if (curent_count < Count)
{
if (items[curent_count] == null)
return add_def;
else
return Byte.Parse(items[curent_count]);
}
else
return add_def;
}
public String ReadString(String add_def)
{
curent_count += 1;
if (curent_count < Count)
{
if (items[curent_count] == null)
return add_def;
else
return items[curent_count];
}
else
return add_def;
}
}
}
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.io;
namespace khaledmohamed.database
{
public class read : Idisposable
{
private string location = "";
private streamreader sr;
public int count = 0;
private string[] items;
private int32 curent_count = -1;
public read(string file)
{
location = file;
}
public void dispose()
{
location = string.empty;
sr = null;
items = null;
count = 0;
}
public string[] outbase() { return items; }
public uint acount;
public bool useread()
{
acount++;
return items.length >= acount;
}
public bool reader(bool useinvalid = true)
{
string[] data = null;
if (file.exists(location))
{
try
{
using (sr = file.opentext(location))
{
count = int.parse(sr.readline().split('=')[1]);
data = new string[count];
for (int x = 0; x < count; x++)
{
data[x] = sr.readline();
}
if (count == 0)
return false;
}
}
catch (exception e)
{
console.writeline(e.tostring());
return false;
}
}
else if (useinvalid)
{
data = null;
console.writeline("invalid reader " + location + " location");
return false;
}
items = new string[count];
for (int x = 0; x < count; x++)
{
items[x] = data[x];
}
return true;
}
public uint32 readuint32(uint32 add_def)
{
curent_count += 1;
if (curent_count < count)
{
if (items[curent_count] == null)
return add_def;
else
return uint32.parse(items[curent_count]);
}
else
return add_def;
}
public uint16 readuint16(uint16 add_def)
{
curent_count += 1;
if (curent_count < count)
{
if (items[curent_count] == null)
return add_def;
else
return uint16.parse(items[curent_count]);
}
else
return add_def;
}
public uint64 readuint64(uint64 add_def)
{
curent_count += 1;
if (curent_count < count)
{
if (items[curent_count] == null)
return add_def;
else
return uint64.parse(items[curent_count]);
}
else
return add_def;
}
public byte readbyte(byte add_def)
{
curent_count += 1;
if (curent_count < count)
{
if (items[curent_count] == null)
return add_def;
else
return byte.parse(items[curent_count]);
}
else
return add_def;
}
public string readstring(string add_def)
{
curent_count += 1;
if (curent_count < count)
{
if (items[curent_count] == null)
return add_def;
else
return items[curent_count];
}
else
return add_def;
}
}
}
|
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
حل بعض مشاكل سورس ماتركس | abuhaneen | تطوير سيرفرات كونكر | 2 | 2020-02-19 09:48 AM |
مشاكل سورس ماتركس | AliNasser | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2020-02-18 06:27 PM |
حل مشاكل سورس رايزو v3 | neno2052 | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-12-04 08:20 PM |
مشاكل سورس رايزو | neno2052 | مشكلات السيرفيرات كونكر الشخصيه | 5 | 2019-10-27 03:06 AM |
مشاكل سورس Empire-War | ElSaher | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-09-29 05:05 AM |