Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dsObject"></param>
        /// <param name="context"></param>
        /// <param name="dsi"></param>
        /// <param name="arrayType"></param>
        /// <returns></returns>
        private object ConvertDSArrayToCSArray(StackValue dsObject, ProtoCore.Runtime.Context context, Interpreter dsi, System.Type arrayType)
        {
            if (arrayType.IsArray)
            {
                //  processing only for the primitive types
                //  anything else will be dealt with as it was earlier
                //
                if (arrayType.UnderlyingSystemType == typeof(int[]))
                {
                    return(PrimitiveMarshler.ConvertDSArrayToCSArray <int>(this, dsObject, context, dsi));
                }
                else if (arrayType.UnderlyingSystemType == typeof(double[]))
                {
                    return(PrimitiveMarshler.ConvertDSArrayToCSArray <double>(this, dsObject, context, dsi));
                }
                else if (arrayType.UnderlyingSystemType == typeof(bool[]))
                {
                    return(PrimitiveMarshler.ConvertDSArrayToCSArray <bool>(this, dsObject, context, dsi));
                }
            }

            int         ptr   = (int)dsObject.opdata;
            HeapElement hs    = dsi.runtime.rmem.Heap.Heaplist[ptr];
            int         count = hs.VisibleSize;

            //  use arraylist instead of object[], this allows us to correctly capture
            //  the type of objects being passed
            //
            ArrayList arrList     = new ArrayList();
            var       elementType = arrayType.GetElementType();

            if (elementType == null)
            {
                elementType = typeof(object);
            }
            for (int idx = 0; idx < count; ++idx)
            {
                arrList.Add(UnMarshal(hs.Stack[idx], context, dsi, elementType));
            }

            return(arrList.ToArray(elementType));
        }
Ejemplo n.º 2
0
 public override object UnMarshal(StackValue dsObject, ProtoCore.Runtime.Context context, Interpreter dsi, Type type)
 {
     char[] array = PrimitiveMarshler.ConvertDSArrayToCSArray <char>(kCharMarshaler, dsObject, context, dsi);
     return(new string(array));
 }