00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using System.Runtime.Serialization;
00005
00006 namespace DXGfxLib.Serialization
00007 {
00008 public class SkyDomeSurrogate : ISerializationSurrogate
00009 {
00016 public void GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
00017 {
00018 if (obj == null)
00019 {
00020 throw new NullReferenceException("No scene object to serialize, this is wrong!");
00021 }
00022
00023 SkyDome dome = obj as SkyDome;
00024
00025 if (dome == null)
00026 {
00027 throw new ArgumentException("The Object passed through obj argument is not a scene object, this is wrong!");
00028 }
00029
00030 info.AddValue("FileName", dome.fileName, typeof(string));
00031 }
00032
00041 public Object SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
00042 {
00043 if (obj == null)
00044 {
00045 throw new NullReferenceException("No scene object to serialize, this is wrong!");
00046 }
00047
00048 SkyDome dome = obj as SkyDome;
00049
00050 if (dome == null)
00051 {
00052 throw new ArgumentException("The Object passed through obj argument is not a terrain object, this is wrong!");
00053 }
00054
00055 dome.fileName = (string)info.GetValue("FileName", typeof(string));
00056
00057 return null;
00058 }
00059 }
00060 }