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


C# IEnumerator.GetType方法代码示例

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


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

示例1: ToState

        /// <summary>
        /// Convert an iterator to an IteratorState.
        /// </summary>
        /// <param name="iterator">The iterator instance.</param>
        /// <returns>An equivalent IteratorState instance that can be serialized.</returns>
        /// <exception cref="ArgumentNullException">iterator is null</exception>
        /// <exception cref="ArgumentOutOfRangeException">iterator is not a compiler-generated iterator state machine.</exception>
        public IteratorState ToState(IEnumerator iterator)
        {
            if (iterator == null)
                throw new ArgumentNullException(nameof(iterator));

            IteratorTypeInfo ti = GetIteratorTypeInfo(iterator.GetType());

            if (ti == null)
                throw new ArgumentOutOfRangeException(nameof(iterator), "not an iterator state machine type");

            var state = new IteratorState
            {
                DeclaringTypeName = NameUtility.GetSimpleAssemblyQualifiedName(ti.Type.DeclaringType),
                MethodName = ti.MethodName,
                State = (int) ti.State.GetValue(iterator),
                Current = ti.Current.GetValue(iterator)
            };

            if (ti.This != null)
                state.This = ti.This.GetValue(iterator);

            foreach (KeyValuePair<string, FieldInfo> a in ti.Arguments)
                state.Arguments.Add(a.Key, a.Value.GetValue(iterator));

            foreach (KeyValuePair<string, FieldInfo> v in ti.Variables)
                state.Variables.Add(v.Key, v.Value.GetValue(iterator));

            return state;
        }
开发者ID:Inverness,项目名称:Coroutines,代码行数:36,代码来源:IteratorStateConverter.cs

示例2: EnumeratorDataReader

		/// <summary>
		/// Инициализирующий конструктор.
		/// </summary>
		/// <param name="enumer">Перечислитель.</param>
		/// <param name="persistentValues">Значения столбцов, постоянные для каждой строки.</param>
		/// <param name="columnNames">Имена значений столбцов.</param>
		public EnumeratorDataReader(IEnumerator enumer, ParamsDic persistentValues, IEnumerable<string> columnNames)
		{
			if(enumer == null)
				throw new ArgumentNullException("enumer");
			_en = enumer;
			Type t = enumer.GetType();
			if(t.IsGenericType)
				t = t.GetGenericArguments()[0];
			else
				t = typeof(object);
			if(columnNames == null)
			{
				if(persistentValues != null)
					foreach(string s in persistentValues.Params)
						_columns.Add(new ValuesPair<string, object>(s, persistentValues[s]));
				foreach(PropertyInfo pi in t.GetProperties())
					_columns.Add(new ValuesPair<string, object>(pi.Name, ReflectionHelper.CreateCallLambdaFunc(pi.GetGetMethod())));
			}
			else
				foreach(string s in columnNames)
					if(persistentValues != null && persistentValues.ContainsKey(s))
						_columns.Add(new ValuesPair<string, object>(s, persistentValues[s]));
					else
						_columns.Add(new ValuesPair<string, object>(s,
							ReflectionHelper.CreateCallLambdaFunc(t.GetProperty(s).GetGetMethod())));
		}
开发者ID:GoldMax,项目名称:Pulsar.NET,代码行数:32,代码来源:EnumeratorDataReader.cs

示例3: CoroutineData

            public CoroutineData(IEnumerator routine, object args)
            {
                this.enumerator = routine;
                this.args = args;

                Match match = Regex.Match (routine.GetType().Name, "<(.+)>");
                this.name = match.Groups[1].Value;
            }
开发者ID:mstevenson,项目名称:UnityManagerWrangler,代码行数:8,代码来源:ManagerWrangler.cs


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