本文整理汇总了C#中Cursor.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Cursor.Add方法的具体用法?C# Cursor.Add怎么用?C# Cursor.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cursor
的用法示例。
在下文中一共展示了Cursor.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddOneByCursor
public static void AddOneByCursor(Database db, Cursor cursor)
{
DatabaseEntry key, data;
KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
// Add a record to db via cursor.
key = new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes("key"));
data = new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes("data"));
pair = new KeyValuePair<DatabaseEntry,DatabaseEntry>(key, data);
cursor.Add(pair);
// Confirm that the record has been put to the database.
Assert.IsTrue(db.Exists(key));
}
示例2: MoveCursorToCurrentRec
/*
* Move the cursor to current existing record. The returning
* value should be true.
*/
public void MoveCursorToCurrentRec(Cursor dbc,
LockingInfo lck)
{
// Add a record to the database.
KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
pair = new KeyValuePair<DatabaseEntry,DatabaseEntry>(
new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes("key")),
new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes("key")));
dbc.Add(pair);
if (lck == null)
dbc.Refresh();
else
dbc.Refresh(lck);
Assert.IsNotNull(dbc.Current.Key);
}
示例3: MoveCursorToCurrentRec
/*
* Move the cursor to current existing record. The returning
* value should be true.
*/
public void MoveCursorToCurrentRec(Cursor dbc,
uint kOffset, uint kLen,
uint dOffset, uint dLen, LockingInfo lck)
{
DatabaseEntry key, data;
// Add a record to the database.
KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
key = new DatabaseEntry(
ASCIIEncoding.ASCII.GetBytes("key"));
data = new DatabaseEntry(
ASCIIEncoding.ASCII.GetBytes("data"));
pair = new KeyValuePair<DatabaseEntry,
DatabaseEntry>(key, data);
dbc.Add(pair);
if (lck == null)
Assert.IsTrue(dbc.Refresh());
else
Assert.IsTrue(dbc.Refresh(lck));
Assert.AreEqual(key.Data, dbc.Current.Key.Data);
Assert.AreEqual(data.Data, dbc.Current.Value.Data);
key = new DatabaseEntry(kOffset, kLen);
data = new DatabaseEntry(dOffset, dLen);
if (lck == null)
Assert.IsTrue(dbc.Refresh(key, data));
else
Assert.IsTrue(dbc.Refresh(key, data, lck));
CheckPartial(dbc.Current.Key, kOffset, kLen,
dbc.Current.Value, dOffset, dLen);
}
示例4: CheckEnd
/// <summary>Ensure that the header has exactly one END keyword in
/// the appropriate location.</summary>
internal void CheckEnd()
{
// Ensure we have an END card only at the end of the header.
cursor = GetCursor();
HeaderCard card;
while(cursor.MoveNext())
{
card = (HeaderCard)((DictionaryEntry)cursor.Current).Value;
if(!card.KeyValuePair && card.Key.Equals("END"))
{
cursor.Remove();
}
}
try
{
cursor.Add(new HeaderCard("END", null, null));
}
catch(HeaderCardException)
{
}
}
示例5: FillForColumn
/// <summary> Update the header to reflect the details of a given column.</summary>
internal void FillForColumn(Header h, int col, Cursor cursor)
{
String tform;
// .99.1 changes: new method for condition check
if (IsVarCol(col))
{
if (IsLongVary(col))
{
tform = "1Q";
}
else
{
tform = "1P";
}
}
else
{
tform = "" + sizes[col];
}
if (bases[col] == typeof(int))
{
tform += "J";
}
//else if (bases[col] == typeof(short) || bases[col] == typeof(char))
else if (bases[col] == typeof(short))// || bases[col] == typeof(char))
{
tform += "I";
}
else if (bases[col] == typeof(byte))
{
tform += "B";
}
else if (bases[col] == typeof(float))
{
tform += "E";
}
else if (bases[col] == typeof(double))
{
tform += "D";
}
else if (bases[col] == typeof(long))
{
tform += "K";
}
else if (bases[col] == typeof(bool))
{
tform += "L";
}
else if (bases[col] == typeof(char) || bases[col] == typeof(String))
{
tform += "A";
}
else
{
throw new FitsException("Invalid column data class:" + bases[col]);
}
String key = "TFORM" + (col + 1);
cursor.Add(key, new HeaderCard(key, tform, null));
// .99.1 changes: new method for condition check
if (dimens[col].Length > 0 && ((!IsVarCol(col))))
{
System.Text.StringBuilder tdim = new System.Text.StringBuilder();
char comma = '(';
for (int i = dimens[col].Length - 1; i >= 0; i -= 1)
{
tdim.Append(comma);
tdim.Append(dimens[col][i]);
comma = ',';
}
tdim.Append(')');
key = "TDIM" + (col + 1);
cursor.Add(key, new HeaderCard(key, new String(tdim.ToString().ToCharArray()), null));
}
}
示例6: AddColInfo
internal virtual int AddColInfo(int col, Cursor c)
{
String tform = null;
if (types[col] == typeof(String))
{
tform = "A" + lengths[col];
}
else if (types[col] == typeof(int) || types[col] == typeof(long))
{
tform = "I" + lengths[col];
}
else if (types[col] == typeof(float))
{
tform = "E" + lengths[col] + ".0";
}
else if (types[col] == typeof(double))
{
tform = "D" + lengths[col] + ".0";
}
String key;
key = "TFORM" + (col + 1);
c.Add(key, new HeaderCard(key, tform, null));
key = "TBCOL" + (col + 1);
c.Add(key, new HeaderCard(key, offsets[col] + 1, null));
return lengths[col];
}