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


C# PhpArray.Prepend方法代码示例

本文整理汇总了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;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:33,代码来源:Arrays.cs

示例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;
		}
开发者ID:hansdude,项目名称:Phalanger,代码行数:60,代码来源:StackTrace.cs


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