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


C# DynValue.ToScalar方法代码示例

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


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

示例1: SetIndex

		/// <summary>
		/// Performs an "index" "set" operation. This tries to resolve minor variations of member names.
		/// </summary>
		/// <param name="script">The script originating the request</param>
		/// <param name="obj">The object (null if a static request is done)</param>
		/// <param name="index">The index.</param>
		/// <param name="value">The value to be set</param>
		/// <param name="isDirectIndexing">If set to true, it's indexed with a name, if false it's indexed through brackets.</param>
		/// <returns></returns>
		public virtual bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing)
		{
			if (!isDirectIndexing)
			{
				IMemberDescriptor mdesc = m_Members
					.GetOrDefault(SPECIALNAME_INDEXER_SET)
					.WithAccessOrNull(MemberDescriptorAccess.CanExecute);

				if (mdesc != null)
				{
					ExecuteIndexer(mdesc, script, obj, index, value);
					return true;
				}
			}

			index = index.ToScalar();

			if (index.Type != DataType.String)
				return false;

			bool v = TrySetIndex(script, obj, index.String, value);
			if (!v) v = TrySetIndex(script, obj, UpperFirstLetter(index.String), value);
			if (!v) v = TrySetIndex(script, obj, Camelify(index.String), value);
			if (!v) v = TrySetIndex(script, obj, UpperFirstLetter(Camelify(index.String)), value);

			return v;
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:36,代码来源:DispatchingUserDataDescriptor.cs

示例2: Index

		/// <summary>
		/// Performs an "index" "get" operation. This tries to resolve minor variations of member names.
		/// </summary>
		/// <param name="script">The script originating the request</param>
		/// <param name="obj">The object (null if a static request is done)</param>
		/// <param name="index">The index.</param>
		/// <param name="isDirectIndexing">If set to true, it's indexed with a name, if false it's indexed through brackets.</param>
		/// <returns></returns>
		public virtual DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing)
		{
			if (!isDirectIndexing)
			{
				IMemberDescriptor mdesc = m_Members
					.GetOrDefault(SPECIALNAME_INDEXER_GET)
					.WithAccessOrNull(MemberDescriptorAccess.CanExecute);

				if (mdesc != null)
					return ExecuteIndexer(mdesc, script, obj, index, null);
			}

			index = index.ToScalar();

			if (index.Type != DataType.String)
				return null;

			DynValue v = TryIndex(script, obj, index.String);
			if (v == null) v = TryIndex(script, obj, UpperFirstLetter(index.String));
			if (v == null) v = TryIndex(script, obj, Camelify(index.String));
			if (v == null) v = TryIndex(script, obj, UpperFirstLetter(Camelify(index.String)));

			if (v == null && m_ExtMethodsVersion < UserData.GetExtensionMethodsChangeVersion())
			{
				m_ExtMethodsVersion = UserData.GetExtensionMethodsChangeVersion();

				v = TryIndexOnExtMethod(script, obj, index.String);
				if (v == null) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(index.String));
				if (v == null) v = TryIndexOnExtMethod(script, obj, Camelify(index.String));
				if (v == null) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(Camelify(index.String)));
			}

			return v;
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:42,代码来源:DispatchingUserDataDescriptor.cs


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