public override IEnumerator <IValue> GetEnumerator()
        {
            var comType = _instance.GetType();

            System.Collections.IEnumerator comEnumerator;

            try
            {
                comEnumerator = (System.Collections.IEnumerator)comType.InvokeMember("[DispId=-4]",
                                                                                     BindingFlags.InvokeMethod,
                                                                                     null,
                                                                                     _instance,
                                                                                     new object[0]);
            }
            catch (TargetInvocationException e)
            {
                uint hr = (uint)System.Runtime.InteropServices.Marshal.GetHRForException(e.InnerException);
                if (hr == E_DISP_MEMBERNOTFOUND)
                {
                    throw RuntimeException.IteratorIsNotDefined();
                }
                else
                {
                    throw;
                }
            }

            while (comEnumerator.MoveNext())
            {
                yield return(CreateIValue(comEnumerator.Current));
            }
        }
        public IEnumerator GetEnumerator()
        {
            if (!(_context is IEnumerable <IValue>))
            {
                throw RuntimeException.IteratorIsNotDefined();
            }

            var enumer = (IEnumerable <IValue>)_context;

            foreach (var iValue in enumer)
            {
                yield return(CustomMarshaller.ConvertToDynamicCLRObject(iValue));
            }
        }
        public override IEnumerator <IValue> GetEnumerator()
        {
            if (!_isCollection)
            {
                throw RuntimeException.IteratorIsNotDefined();
            }

            var comEnumerator = ((IEnumerable)Instance).GetEnumerator();

            while (comEnumerator.MoveNext())
            {
                yield return(CreateIValue(comEnumerator.Current));
            }
        }
Exemple #4
0
        public override IEnumerator <IValue> GetEnumerator()
        {
            System.Collections.IEnumerator comEnumerator;

            try
            {
                comEnumerator = (System.Collections.IEnumerator)_instanceType.InvokeMember("GetEnumerator",
                                                                                           BindingFlags.InvokeMethod,
                                                                                           null,
                                                                                           _instance,
                                                                                           new object[0]);
            }
            catch (MissingMethodException)
            {
                throw RuntimeException.IteratorIsNotDefined();
            }

            while (comEnumerator.MoveNext())
            {
                yield return(CreateIValue(comEnumerator.Current));
            }
        }