/// <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;
        }
Example #2
0
        public void TestSerializePrimitiveToFile()
        {
            Random rand = new Random();

            SerializedStackFrame   frame = new SerializedStackFrame();
            SerializedLSLPrimitive vec   = new SerializedLSLPrimitive();
            Vector3 rvec = new Vector3((float)rand.NextDouble() * 0.000000000001f, (float)rand.NextDouble() * 10000000000000.0f, (float)rand.NextDouble() * 10000000000000.0f);

            vec.Value = rvec;

            frame.Locals        = new SerializedLSLPrimitive[] { vec };
            frame.ReturnAddress = 999;
            frame.FunctionInfo  = new FunctionInfo {
                Address = 9282, Name = "blam", NumberOfArguments = 1, NumberOfLocals = 0
            };

            using (FileStream outStream = File.OpenWrite("primitive.txt"))
            {
                ProtoBuf.Serializer.Serialize(outStream, frame);
            }
        }
Example #3
0
        public void TestManyIterationsOfVectorSerialization()
        {
            Random rand = new Random();

            for (int i = 0; i < 1000; i++)
            {
                Vector3 vec = new Vector3((float)rand.NextDouble() * 0.000000000001f, (float)rand.NextDouble() * 10000000000000.0f, (float)rand.NextDouble() * 10000000000000.0f);
                SerializedLSLPrimitive primitive = new SerializedLSLPrimitive();
                primitive.Value = vec;

                Assert.IsTrue(primitive.IsValid());

                using (MemoryStream memStream = new MemoryStream())
                {
                    ProtoBuf.Serializer.Serialize(memStream, primitive);

                    memStream.Seek(0, SeekOrigin.Begin);

                    SerializedLSLPrimitive deser = ProtoBuf.Serializer.Deserialize <SerializedLSLPrimitive>(memStream);

                    Assert.IsTrue(deser.IsValid());
                }
            }
        }
        public void TestSerializePrimitiveToFile()
        {
            Random rand = new Random();

            SerializedStackFrame frame = new SerializedStackFrame();
            SerializedLSLPrimitive vec = new SerializedLSLPrimitive();
            Vector3 rvec = new Vector3((float)rand.NextDouble() * 0.000000000001f, (float)rand.NextDouble() * 10000000000000.0f, (float)rand.NextDouble() * 10000000000000.0f);
            vec.Value = rvec;

            frame.Locals = new SerializedLSLPrimitive[] { vec };
            frame.ReturnAddress = 999;
            frame.FunctionInfo = new FunctionInfo { Address = 9282, Name = "blam", NumberOfArguments = 1, NumberOfLocals = 0 };

            using (FileStream outStream = File.OpenWrite("primitive.txt"))
            {
                ProtoBuf.Serializer.Serialize(outStream, frame);
            }
            
        }
        public void TestManyIterationsOfVectorSerialization()
        {
            Random rand = new Random();

            for (int i = 0; i < 1000; i++)
            {
                Vector3 vec = new Vector3((float)rand.NextDouble() * 0.000000000001f, (float)rand.NextDouble() * 10000000000000.0f, (float)rand.NextDouble() * 10000000000000.0f);
                SerializedLSLPrimitive primitive = new SerializedLSLPrimitive();
                primitive.Value = vec;

                Assert.IsTrue(primitive.IsValid());

                using (MemoryStream memStream = new MemoryStream())
                {
                    ProtoBuf.Serializer.Serialize(memStream, primitive);

                    memStream.Seek(0, SeekOrigin.Begin);

                    SerializedLSLPrimitive deser = ProtoBuf.Serializer.Deserialize<SerializedLSLPrimitive>(memStream);

                    Assert.IsTrue(deser.IsValid());
                }
            }
        }