本文整理汇总了C#中Record.Edit方法的典型用法代码示例。如果您正苦于以下问题:C# Record.Edit方法的具体用法?C# Record.Edit怎么用?C# Record.Edit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.Edit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string tableName = "test";
Database DB = new Database();
DB.CreateDatabaseFolder();
List<Types.Type> types = new List<Types.Type>() { Types.Type.VARCHAR, Types.Type.VARCHAR,
Types.Type.BOOLEAN, Types.Type.INTEGER };
DB.CreateTable(tableName, types, new List<string>() { "varchar", "boolean", "integer" });
Record record = new Record(types);
for (int i = 0; i < 10000; i++)
{
record.Edit(RandomString(25), 0);
record.Edit(RandomString(10), 1);
record.Edit(Convert.ToBoolean(rnd.Next() % 2), 2);
DB.AddRecord(tableName, record);
sw.Start();
DB.Search(tableName, i*2);
sw.Stop();
Console.WriteLine("Elapsed={0}", sw.Elapsed);
}
}
示例2: StrToRecord
public static Record StrToRecord(string s, List<Type> types)
{
try
{
Record record = new Record(types);
for (int i = 0; i < types.Count; i++)
{
if (types[i] == Type.BOOLEAN)
{
bool? value = StrToBoolean(s.Substring(0, 1));
if (value.HasValue)
{
record.Edit(value.Value, i);
s = s.Remove(0, 1);
}
}
else if (types[i] == Type.VARCHAR)
{
string value = StrToVarchar(s.Substring(0, strSize));
record.Edit(value, i);
s = s.Remove(0, strSize);
}
else if (types[i] == Type.INTEGER)
{
int? value = StrToInteger(s.Substring(0, intSize));
if (value.HasValue)
{
record.Edit(value.Value, i);
s = s.Remove(0, intSize);
}
}
}
return record;
}
catch (Exception ex)
{
Logger.Write(ex);
return null;
}
}
示例3: TestBooleanRecordToString
public void TestBooleanRecordToString()
{
List<Types.Type> types = new List<Types.Type>() { Types.Type.BOOLEAN };
Record record = new Record(types);
record.Edit(true, 0);
string result = Types.RecordToStr(record);
Assert.AreEqual("1", result);
}
示例4: TestCorrectStringToRecord
public void TestCorrectStringToRecord()
{
List<Types.Type> types = new List<Types.Type>() { Types.Type.VARCHAR, Types.Type.INTEGER, Types.Type.BOOLEAN };
string s = "ich liebe Wien!";
int i = int.MinValue;
bool b = true;
Record record = new Record(types);
record.Edit(s, 0);
record.Edit(i, 1);
record.Edit(b, 2);
StringBuilder sb = new StringBuilder(s);
sb.Append(' ', 100 - s.Length);
s = sb.ToString();
string actual = s + i.ToString() + "1";
Assert.AreEqual(record, Types.StrToRecord(actual, types));
}
示例5: TestDeleteFictionalRecord
public void TestDeleteFictionalRecord()
{
List<Types.Type> types = new List<Types.Type> { Types.Type.VARCHAR, Types.Type.BOOLEAN, Types.Type.INTEGER };
Record record1 = new Record(types);
Record record2 = new Record(types);
record2.Edit("testing purpose", 0);
record2.Edit(true, 1);
record2.Edit(12, 2);
DB.AddRecord("test", record2);
bool value = DB.DeleteRecord("test", record1.data[0].ToString());
Assert.AreEqual(false, value);
}
示例6: TestSearchingSomeRecordData
public void TestSearchingSomeRecordData()
{
List<Types.Type> types = new List<Types.Type> { Types.Type.VARCHAR, Types.Type.BOOLEAN, Types.Type.INTEGER };
Record record1 = new Record(types);
Record record2 = new Record(types);
record2.Edit("testing purpose", 0);
record2.Edit(true, 1);
record2.Edit(12, 2);
DB.AddRecord("test", record1);
DB.AddRecord("test", record2);
List<Record> result = DB.Search("test", record2.data[0].ToString());
Assert.AreEqual(record2, result[0]);
}
示例7: TestImportToCSV
public void TestImportToCSV()
{
List<Types.Type> types = new List<Types.Type> { Types.Type.VARCHAR, Types.Type.BOOLEAN, Types.Type.INTEGER };
Record record1 = new Record(types);
Record record2 = new Record(types);
record1.Edit("first record", 0);
record1.Edit(false, 1);
record1.Edit(123, 2);
record2.Edit("testing purpose", 0);
record2.Edit(true, 1);
record2.Edit(12, 2);
DB.AddRecord("test", record1);
DB.AddRecord("test", record2);
bool value = DB.Import("test");
Assert.AreEqual(true, value);
}
示例8: TestIntegerRecordToString
public void TestIntegerRecordToString()
{
List<Types.Type> types = new List<Types.Type>() { Types.Type.INTEGER };
Record record = new Record(types);
record.Edit(123, 0);
string result = Types.RecordToStr(record);
Assert.AreEqual("123 ", result);
}
示例9: TestVarcharRecordToString
public void TestVarcharRecordToString()
{
List<Types.Type> types = new List<Types.Type>() { Types.Type.VARCHAR };
string s = "Ich liene Wien!";
Record record = new Record(types);
record.Edit(s, 0);
string result = Types.RecordToStr(record);
StringBuilder sb = new StringBuilder(s);
sb.Append(' ', 100 - s.Length);
s = sb.ToString();
Assert.AreEqual(s, result);
}