本文整理汇总了C#中RubyArray.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# RubyArray.ToArray方法的具体用法?C# RubyArray.ToArray怎么用?C# RubyArray.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyArray
的用法示例。
在下文中一共展示了RubyArray.ToArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public static RubyArray Execute(RhoDatabase/*!*/ self, MutableString/*!*/ sqlStatement, Boolean isBatch, RubyArray args)
{
try
{
RubyArray retArr = new RubyArray();
if (isBatch)
{
self.m_db.executeBatchSQL(sqlStatement.ToString());
}
else
{
Object[] values = null;
if (args != null && args.Count > 0)
{
if (args[0] != null && args[0] is RubyArray)
values = ((RubyArray)args[0]).ToArray();
else
values = args.ToArray();
}
try
{
self.m_db.Lock();
using (IDBResult rows = self.m_db.executeSQL(sqlStatement.ToString(), values, true))
{
if (rows != null)
{
MutableString[] colNames = null;
for (; !rows.isEnd(); rows.next())
{
IDictionary<object, object> map = new Dictionary<object, object>();
Hash row = new Hash(map);
for (int nCol = 0; nCol < rows.getColCount(); nCol++)
{
if (colNames == null)
colNames = getOrigColNames(rows);
row.Add(colNames[nCol], rows.getRubyValueByIdx(nCol));
}
retArr.Add(row);
}
}
}
}
finally
{
self.m_db.Unlock();
}
}
return retArr;
}catch (Exception exc)
{
//TODO: throw ruby exception
throw exc;
}
}
示例2: AssertValueEquals
private void AssertValueEquals(RubyArray/*!*/ array, params object[]/*!*/ expected) {
Assert(ArrayUtils.ValueEquals(array.ToArray(), expected));
array.RequireNullEmptySlots();
}
示例3: RubyArray_Misc
public void RubyArray_Misc() {
RubyArray a;
a = new RubyArray(new[] { 3, 5, 2, 4, 1 });
a.InsertRange(0, new[] {10, 20});
a.RemoveRange(0, 2);
a.Sort();
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 1, 2, 3, 4, 5 }));
a.Sort((x, y) => (int)x == (int)y ? 0 : ((int)x < (int)y ? 1 : -1));
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 5, 4, 3, 2, 1 }));
a.Reverse();
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 1, 2, 3, 4, 5 }));
a.Freeze();
AssertExceptionThrown<RuntimeError>(() => a.Reverse());
AssertExceptionThrown<RuntimeError>(() => a.Sort());
}
示例4: RubyArray_Indexer
public void RubyArray_Indexer()
{
RubyArray a;
a = new RubyArray();
a.Add(0);
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 0 }));
a[1] = 1;
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 0, 1 }));
a[4] = 4;
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 0, 1, null, null, 4 }));
a[6] = 6;
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 0, 1, null, null, 4, null, 6 }));
a = new RubyArray(new object[] { null, null, 2, 3}, 2, 2);
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 2, 3 }));
a[3] = 4;
Assert(ArrayUtils.ValueEquals(a.ToArray(), new object[] { 2, 3, null, 4 }));
a = new RubyArray(new object[] { null, null, 2, 3 }, 2, 2);
Assert((int)a[0] == 2);
object x;
AssertExceptionThrown<IndexOutOfRangeException>(() => x = a[2]);
}