本文整理汇总了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;
}
示例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())));
}
示例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;
}