Exemplo n.º 1
0
        public static Stack <object> ToPrimitiveStack(SerializedLSLPrimitive[] serializedLSLPrimitive)
        {
            if (serializedLSLPrimitive == null)
            {
                return(new Stack <object>());
            }

            //push the primitives back onto the stack in reverse order
            Stack <object> primStack = new Stack <object>(serializedLSLPrimitive.Length);

            for (int i = serializedLSLPrimitive.Length - 1; i >= 0; i--)
            {
                SerializedLSLPrimitive obj = serializedLSLPrimitive[i];

                if (!(obj.Value is SerializedLSLList))
                {
                    /*if (validate)
                     * {
                     *  if (!obj.IsValid())
                     *  {
                     *      throw new SerializationException(
                     *          String.Format(
                     *              "ToPrimitiveStack: Unable to deserialize LSLPrimitive to object: Type: {0} Value: {1}",
                     *              obj != null && obj.Value != null ? obj.Value.GetType().FullName : "null", obj.Value));
                     *  }
                     * }*/

                    primStack.Push(obj.Value);
                }
                else
                {
                    SerializedLSLList list = (SerializedLSLList)obj.Value;
                    primStack.Push(list.ToList());
                }
            }

            return(primStack);
        }
Exemplo n.º 2
0
        public static object[] ToPrimitiveList(SerializedLSLPrimitive[] serPrimList)
        {
            if (serPrimList == null)
            {
                return(new object[0]);
            }

            object[] primitiveList = new object[serPrimList.Length];

            for (int i = 0; i < serPrimList.Length; i++)
            {
                SerializedLSLPrimitive obj = serPrimList[i];

                if (!(obj.Value is SerializedLSLList))
                {
                    /*if (validate)
                     * {
                     *  if (!obj.IsValid())
                     *  {
                     *      throw new SerializationException(
                     *          String.Format(
                     *              "ToPrimitiveList: Unable to deserialize LSLPrimitive to object: Type: {0} Value: {1}",
                     *              obj != null && obj.Value != null ? obj.Value.GetType().FullName : "null", obj));
                     *  }
                     * }*/

                    primitiveList[i] = obj.Value;
                }
                else
                {
                    SerializedLSLList list = (SerializedLSLList)obj.Value;
                    primitiveList[i] = list.ToList();
                }
            }

            return(primitiveList);
        }