Ejemplo n.º 1
0
        /// <summary>
        ///反序列化MultiMaterialList
        /// </summary>
        /// <param name="dictionary">对象类型</param>
        /// <param name="type">对象类型</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>反序列化出的对象</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            MultiMaterialList multiMaterialList = new MultiMaterialList();

            object materialList;

            if (dictionary.TryGetValue("materials", out materialList))
            {
                ArrayList materials = (ArrayList)materialList;

                for (int i = 0; i < materials.Count; i++)
                {
                    multiMaterialList.Materials.Add(JSONSerializerExecute.Deserialize <Material>(materials[i]));
                }
            }

            object deltaMaterialList;

            if (dictionary.TryGetValue("deltaMaterials", out deltaMaterialList))
            {
                multiMaterialList.DeltaMaterials = JSONSerializerExecute.Deserialize <DeltaMaterialList>(deltaMaterialList);
            }

            return(multiMaterialList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 序列化MultiMaterial
        /// </summary>
        /// <param name="obj">MultiMaterial对象</param>
        /// <param name="serializer">序列化器</param>
        /// <returns>属性集合</returns>
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            MultiMaterialList multiMaterialList = (MultiMaterialList)obj;

            Material[] materials = new Material[multiMaterialList.Materials.Count];

            for (int i = 0; i < materials.Length; i++)
            {
                materials[i] = multiMaterialList.Materials[i];
            }

            dictionary.Add("materials", materials);

            dictionary.Add("deltaMaterials", multiMaterialList.DeltaMaterials);

            return(dictionary);
        }
Ejemplo n.º 3
0
		/// <summary>
		///反序列化MultiMaterialList
		/// </summary>
		/// <param name="dictionary">对象类型</param>
		/// <param name="type">对象类型</param>
		/// <param name="serializer">JS序列化器</param>
		/// <returns>反序列化出的对象</returns>
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			MultiMaterialList multiMaterialList = new MultiMaterialList();

			object materialList;

			if (dictionary.TryGetValue("materials", out materialList))
			{
				ArrayList materials = (ArrayList)materialList;

				for (int i = 0; i < materials.Count; i++)
					multiMaterialList.Materials.Add(JSONSerializerExecute.Deserialize<Material>(materials[i]));
			}

			object deltaMaterialList;

			if (dictionary.TryGetValue("deltaMaterials", out deltaMaterialList))
				multiMaterialList.DeltaMaterials = JSONSerializerExecute.Deserialize<DeltaMaterialList>(deltaMaterialList);

			return multiMaterialList;
		}
Ejemplo n.º 4
0
        protected override string SaveClientState()
        {
            MultiMaterialList multiMaterialList = new MultiMaterialList();
            multiMaterialList.Materials = this.materials;
            multiMaterialList.DeltaMaterials = this.deltaMaterials;

            return JSONSerializerExecute.Serialize(multiMaterialList);
        }