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


C# Scriptable.GetIds方法代码示例

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


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

示例1: DefaultObjectToSource

		internal static string DefaultObjectToSource(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
		{
			bool toplevel;
			bool iterating;
			if (cx.iterating == null)
			{
				toplevel = true;
				iterating = false;
				cx.iterating = new ObjToIntMap(31);
			}
			else
			{
				toplevel = false;
				iterating = cx.iterating.Has(thisObj);
			}
			StringBuilder result = new StringBuilder(128);
			if (toplevel)
			{
				result.Append("(");
			}
			result.Append('{');
			// Make sure cx.iterating is set to null when done
			// so we don't leak memory
			try
			{
				if (!iterating)
				{
					cx.iterating.Intern(thisObj);
					// stop recursion.
					object[] ids = thisObj.GetIds();
					for (int i = 0; i < ids.Length; i++)
					{
						object id = ids[i];
						object value;
						if (id is int)
						{
							int intId = System.Convert.ToInt32(((int)id));
							value = thisObj.Get(intId, thisObj);
							if (value == ScriptableConstants.NOT_FOUND)
							{
								continue;
							}
							// a property has been removed
							if (i > 0)
							{
								result.Append(", ");
							}
							result.Append(intId);
						}
						else
						{
							string strId = (string)id;
							value = thisObj.Get(strId, thisObj);
							if (value == ScriptableConstants.NOT_FOUND)
							{
								continue;
							}
							// a property has been removed
							if (i > 0)
							{
								result.Append(", ");
							}
							if (ScriptRuntime.IsValidIdentifierName(strId))
							{
								result.Append(strId);
							}
							else
							{
								result.Append('\'');
								result.Append(ScriptRuntime.EscapeString(strId, '\''));
								result.Append('\'');
							}
						}
						result.Append(':');
						result.Append(ScriptRuntime.Uneval(cx, scope, value));
					}
				}
			}
			finally
			{
				if (toplevel)
				{
					cx.iterating = null;
				}
			}
			result.Append('}');
			if (toplevel)
			{
				result.Append(')');
			}
			return result.ToString();
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:92,代码来源:ScriptRuntime.cs

示例2: Jo

		private static string Jo(Scriptable value, NativeJSON.StringifyState state)
		{
			if (state.stack.Search(value) != -1)
			{
				throw ScriptRuntime.TypeError0("msg.cyclic.value");
			}
			state.stack.Push(value);
			string stepback = state.indent;
			state.indent = state.indent + state.gap;
			object[] k = null;
			if (state.propertyList != null)
			{
				k = Sharpen.Collections.ToArray(state.propertyList);
			}
			else
			{
				k = value.GetIds();
			}
			IList<object> partial = new List<object>();
			foreach (object p in k)
			{
				object strP = Str(p, value, state);
				if (strP != Undefined.instance)
				{
					string member = Quote(p.ToString()) + ":";
					if (state.gap.Length > 0)
					{
						member = member + " ";
					}
					member = member + strP;
					partial.Add(member);
				}
			}
			string finalValue;
			if (partial.IsEmpty())
			{
				finalValue = "{}";
			}
			else
			{
				if (state.gap.Length == 0)
				{
					finalValue = '{' + Join(partial, ",") + '}';
				}
				else
				{
					string separator = ",\n" + state.indent;
					string properties = Join(partial, separator);
					finalValue = "{\n" + state.indent + properties + '\n' + stepback + '}';
				}
			}
			state.stack.Pop();
			state.indent = stepback;
			return finalValue;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:55,代码来源:NativeJSON.cs


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