Esempio n. 1
0
        //-------------------------------------------//

        /// <summary>
        /// On the stream to the configuration file being established.
        /// </summary>
        private void OnLoad(ByteBuffer stream)
        {
            if (stream == null)
            {
                State = AssetState.Broken;

                Log.Debug("Loading configuration failed '" + _path + "'.");
            }
            else
            {
                // parse the node from the stream
                Node  = NodeSerialization.Parse(stream);
                State = AssetState.Loaded;

                stream.Flush();

                Log.Info("Loaded configuration '" + _path + "'.");
            }

            _onLoad.ArgA = this;
            _onLoad.Run();
            _lock.Release();
        }
Esempio n. 2
0
        /// <summary>
        /// On the stream to the configuration file being established.
        /// </summary>
        private void OnSave(ByteBuffer stream)
        {
            if (stream == null)
            {
                State = AssetState.Broken;
                Log.Debug("Saving configuration failed '" + _path + "'.");
            }
            else
            {
                if (NodeSerialization.Serialize(Node, stream))
                {
                    Log.Info("Saved configuration '" + _path + "'.");
                }
                else
                {
                    Log.Warning("Saving configuration at '" + _path + "' failed. The node serialization didn't work.");
                }

                State = AssetState.Loaded;

                stream.Flush();
            }
            _lock.Release();
        }
Esempio n. 3
0
 /// <summary>
 /// Get a json representation of the node.
 /// </summary>
 public string ToJson()
 {
     return(NodeSerialization.SerializeJson(this));
 }