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


C# CallbackArguments.RawGet方法代码示例

本文整理汇总了C#中CallbackArguments.RawGet方法的典型用法代码示例。如果您正苦于以下问题:C# CallbackArguments.RawGet方法的具体用法?C# CallbackArguments.RawGet怎么用?C# CallbackArguments.RawGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CallbackArguments的用法示例。


在下文中一共展示了CallbackArguments.RawGet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildArgumentList

		/// <summary>
		/// Builds the argument list.
		/// </summary>
		/// <param name="script">The script.</param>
		/// <param name="obj">The object.</param>
		/// <param name="context">The context.</param>
		/// <param name="args">The arguments.</param>
		/// <param name="outParams">Output: A list containing the indices of all "out" parameters, or null if no out parameters are specified.</param>
		/// <returns>The arguments, appropriately converted.</returns>
		protected virtual object[] BuildArgumentList(Script script, object obj, ScriptExecutionContext context, CallbackArguments args,
			out List<int> outParams)
		{
			ParameterDescriptor[] parameters = Parameters;

			object[] pars = new object[parameters.Length];

			int j = args.IsMethodCall ? 1 : 0;

			outParams = null;

			for (int i = 0; i < pars.Length; i++)
			{
				// keep track of out and ref params
				if (parameters[i].Type.IsByRef)
				{
					if (outParams == null) outParams = new List<int>();
					outParams.Add(i);
				}

				// if an ext method, we have an obj -> fill the first param
				if (ExtensionMethodType != null && obj != null && i == 0)
				{
					pars[i] = obj;
					continue;
				}
				// else, fill types with a supported type
				else if (parameters[i].Type == typeof(Script))
				{
					pars[i] = script;
				}
				else if (parameters[i].Type == typeof(ScriptExecutionContext))
				{
					pars[i] = context;
				}
				else if (parameters[i].Type == typeof(CallbackArguments))
				{
					pars[i] = args.SkipMethodCall();
				}
				// else, ignore out params
				else if (parameters[i].IsOut)
				{
					pars[i] = null;
				}
				else if (i == parameters.Length - 1 && VarArgsArrayType != null)
				{
					List<DynValue> extraArgs = new List<DynValue>();

					while (true)
					{
						DynValue arg = args.RawGet(j, false);
						j += 1;
						if (arg != null)
							extraArgs.Add(arg);
						else
							break;
					}

					// here we have to worry we already have an array.. damn. We only support this for userdata.
					// remains to be analyzed what's the correct behavior here. For example, let's take a params object[]..
					// given a single table parameter, should it use it as an array or as an object itself ?
					if (extraArgs.Count == 1)
					{
						DynValue arg = extraArgs[0];

						if (arg.Type == DataType.UserData && arg.UserData.Object != null)
						{
							if (VarArgsArrayType.IsAssignableFrom(arg.UserData.Object.GetType()))
							{
								pars[i] = arg.UserData.Object;
								continue;
							}
						}
					}

					// ok let's create an array, and loop
					Array vararg = Array.CreateInstance(VarArgsElementType, extraArgs.Count);

					for (int ii = 0; ii < extraArgs.Count; ii++)
					{
						vararg.SetValue(ScriptToClrConversions.DynValueToObjectOfType(extraArgs[ii], VarArgsElementType,
						null, false), ii);
					}

					pars[i] = vararg;

				}
				// else, convert it
				else
				{
					var arg = args.RawGet(j, false) ?? DynValue.Void;
//.........这里部分代码省略.........
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:101,代码来源:FunctionMemberDescriptorBase.cs


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