- Main Page
- Packages
- Classes
- Files

- File List
- File Members

# D:/guillaume/guillara/3D/DXGfx/DXGfxLib/Serialization/SceneSurrogate.cs

Go to the documentation of this file.

    00001 using System;
    00002 using System.Collections;
    00003 using System.Collections.Generic;
    00004 using System.Text;
    00005 using System.Runtime.Serialization;
    00006
    00007 namespace DXGfxLib.Serialization
    00008 {
    00009     public class SceneSurrogate : ISerializationSurrogate
    00010     {
    00017         public void GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
    00018         {
    00019             if (obj == null)
    00020             {
    00021                 throw new NullReferenceException("No scene to serialize, this is wrong!");
    00022             }
    00023
    00024             OutDoorScene scene = obj as OutDoorScene;
    00025
    00026             if (scene == null)
    00027             {
    00028                 throw new ArgumentException("The Object passed through obj argument is not an OutDoorScene, this is wrong!");
    00029             }
    00030
    00031             info.AddValue("Name", scene.name, typeof(string));
    00032             info.AddValue("SceneContent", scene.sceneContent, typeof(Hashtable));
    00033
    00034         }
    00035
    00044         public Object SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    00045         {
    00046             if (obj == null)
    00047             {
    00048                 throw new NullReferenceException("No scene to serialize, this is wrong!");
    00049             }
    00050
    00051             OutDoorScene scene = obj as OutDoorScene;
    00052
    00053             if (scene == null)
    00054             {
    00055                 throw new ArgumentException("The Object passed through obj argument is not an OutDoorScene, this is wrong!");
    00056             }
    00057
    00058             scene.name = (string)info.GetValue("Name", typeof(string));
    00059             scene.sceneContent = (Hashtable)info.GetValue("SceneContent", typeof(Hashtable));
    00060
    00061             return null;
    00062         }
    00063
    00064     }
    00065 }