Cast() 공개 메소드

public Cast ( Type type ) : Operand
type IKVM.Reflection.Type
리턴 Operand
예제 #1
0
            protected override void BeginImpl()
            {
                g.BeforeStatement();

                enumerator = g.Local();
                lbLoop     = g.il.DefineLabel();
                lbTest     = g.il.DefineLabel();

                if (typeof(IEnumerable).IsAssignableFrom(collection.Type))
                {
                    collection = collection.Cast(typeof(IEnumerable));
                }

                g.Assign(enumerator, collection.Invoke("GetEnumerator"));
                g.il.Emit(OpCodes.Br, lbTest);
                g.il.MarkLabel(lbLoop);
                element = g.Local(elementType);
                g.Assign(element, enumerator.Property("Current"), true);
            }
예제 #2
0
            protected override void BeginImpl()
            {
                G.BeforeStatement();

                _enumerator = G.Local();
                _lbLoop     = G.IL.DefineLabel();
                _lbTest     = G.IL.DefineLabel();

                if (Helpers.IsAssignableFrom(typeof(IEnumerable), _collection.GetReturnType(G.TypeMapper), _typeMapper))
                {
                    _collection = _collection.Cast(_typeMapper.MapType(typeof(IEnumerable)));
                }

                G.Assign(_enumerator, _collection.Invoke("GetEnumerator", _typeMapper));
                G.IL.Emit(OpCodes.Br, _lbTest);
                G.IL.MarkLabel(_lbLoop);
                Element = G.Local(_elementType);
                G.Assign(Element, _enumerator.Property("Current", _typeMapper), true);
            }