コード例 #1
0
ファイル: SerializedLSLList.cs プロジェクト: kf6kjg/phlox-1
        /// <summary>
        /// Create a new Serializable List from the LSLList primitive type
        /// </summary>
        /// <param name="lSLList"></param>
        /// <returns></returns>
        public static SerializedLSLList FromList(Types.LSLList lSLList)
        {
            SerializedLSLList list = new SerializedLSLList();

            list.ListContents = new List <SerializedLSLPrimitive>();

            foreach (object obj in lSLList.Members)
            {
                SerializedLSLPrimitive primitive = new SerializedLSLPrimitive();
                primitive.Value = obj;
                list.ListContents.Add(primitive);
            }

            return(list);
        }
コード例 #2
0
        public static SerializedLSLPrimitive FromPrimitive(object obj)
        {
            if (!(obj is Types.LSLList))
            {
                SerializedLSLPrimitive primitive = new SerializedLSLPrimitive();
                primitive.Value = obj;

                return(primitive);
            }
            else
            {
                SerializedLSLPrimitive primitive = new SerializedLSLPrimitive();
                primitive.Value = SerializedLSLList.FromList((Types.LSLList)obj);
                return(primitive);
            }
        }
コード例 #3
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);
        }
コード例 #4
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);
        }