当前位置: 首页>>代码示例>>C#>>正文


C# Cursor.Add方法代码示例

本文整理汇总了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));
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:14,代码来源:CursorTest.cs

示例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);
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:21,代码来源:CursorTest.cs

示例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);
        }
开发者ID:mcandre,项目名称:db,代码行数:36,代码来源:CursorTest.cs

示例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)
            {
            }
        }
开发者ID:rwg0,项目名称:csharpfits,代码行数:24,代码来源:Header.cs

示例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));
            }
        }
开发者ID:rwg0,项目名称:csharpfits,代码行数:78,代码来源:BinaryTable.cs

示例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];
        }
开发者ID:rwg0,项目名称:csharpfits,代码行数:27,代码来源:AsciiTable.cs


注:本文中的Cursor.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。