本文整理汇总了C#中PHP.Core.PhpArray.Prepend方法的典型用法代码示例。如果您正苦于以下问题:C# PhpArray.Prepend方法的具体用法?C# PhpArray.Prepend怎么用?C# PhpArray.Prepend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP.Core.PhpArray
的用法示例。
在下文中一共展示了PhpArray.Prepend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reverse
public static PhpArray Reverse(PhpArray array, bool preserveKeys)
{
if (array == null)
{
PhpException.ArgumentNull("array");
return null;
}
PhpArray result = new PhpArray();
if (preserveKeys)
{
// changes only the order of elements:
foreach (KeyValuePair<IntStringKey, object> entry in array)
result.Prepend(entry.Key, entry.Value);
}
else
{
// changes the order of elements and reindexes integer keys:
int i = array.IntegerCount;
foreach (KeyValuePair<IntStringKey, object> entry in array)
{
if (entry.Key.IsString)
result.Prepend(entry.Key.String, entry.Value);
else
result.Prepend(--i, entry.Value);
}
}
// if called by PHP languge then all items in the result should be inplace deeply copied:
result.InplaceCopyOnReturn = true;
return result;
}
示例2: GetUserTrace
/// <summary>
/// Returns array containing current stack state. Each item is an array representing one stack frame.
/// </summary>
/// <returns>The stack trace.</returns>
/// <remarks>
/// The resulting array contains the following items (their keys are stated):
/// <list type="bullet">
/// <item><c>"file"</c> - a source file where the function/method has been called</item>
/// <item><c>"line"</c> - a line in a source code where the function/method has been called</item>
/// <item><c>"column"</c> - a column in a source code where the function/method has been called</item>
/// <item><c>"function"</c> - a name of the function/method</item>
/// <item><c>"class"</c> - a name of a class where the method is declared (if any)</item>
/// <item><c>"type"</c> - either "::" for static methods or "->" for instance methods</item>
/// </list>
/// Unsupported items:
/// <list type="bullet">
/// <item><c>"args"</c> - routine arguments</item>
/// <item><c>"object"</c> - target instance of the method invocation</item>
/// </list>
/// </remarks>
public PhpArray GetUserTrace()
{
int i = GetFrameCount() - 1;
PhpArray result = new PhpArray();
if (i >= 1)
{
PhpStackFrame info_frame = GetFrame(i--);
while (i >= 0)
{
PhpStackFrame frame = GetFrame(i);
PhpArray item = new PhpArray();
// debug info may be unknown in the case of transient code:
if (info_frame.Line > 0)
{
item["line"] = info_frame.Line;
item["column"] = info_frame.Column;
}
item["file"] = info_frame.File;
item["function"] = frame.Name;
if (frame.IsMethod)
{
item["class"] = frame.DeclaringTypeName;
item["type"] = frame.Operator;
}
result.Prepend(i, item);
if (frame.HasDebugInfo)
info_frame = frame;
i--;
}
}
return result;
}