コード例 #1
0
ファイル: Component.cs プロジェクト: JllyGrnGiant/game_demo
        // Returns a SerializationData a Serializer can use to save the state
        // of the object to an Xml file
        public SerializationData GetSerializationData(Serializer Serializer, XmlWriter Writer)
        {
            // Create a new SerializationData
            SerializationData data = new SerializationData(Serializer, Writer);

            // Add the basic Component values
            data.AddData("Component.DrawOrder", DrawOrder);
            data.AddData("Component.ParentScreen", Parent.Name);
            data.AddData("Component.Visible", Visible);
            data.AddData("Component.Name", this.Name);

            // Tell serializer that it will need to know the type of component
            data.AddDependency(this.GetType());

            // Construct a ServiceData
            ServiceData sd = new ServiceData();

            // If this object is a service, find out what the provider type is
            // (the type used to look up the services)
            Type serviceType;
            if (Engine.Services.IsService(this, out serviceType))
            {
                // Tell serializer about provider type
                data.AddDependency(serviceType);

                // Set data to ServiceData
                sd.IsService = true;
                sd.Type = serviceType.FullName;
            }

            // Add the ServiceData to the SerializationData
            data.AddData("Component.ServiceData", sd);

            // Call the overridable function that allows components to provide data
            SaveSerializationData(data);

            return data;
        }