コード例 #1
0
    public void LoadState(ISerializerStorage storage, ISerializerStream stream)
    {
        // Enforce required settings for scene state loading
        stream.DeepSerialize       = true;
        stream.TypeResolver        = this;
        stream.DependencyContainer = Container;
        storage.Load(stream);

        // STEP 1: Load the viewmodels
        var viewModels = stream.DeserializeObjectArray <ViewModel>("ViewModels");

        foreach (var viewModel in viewModels)
        {
            VoidMethod(viewModel);
            // Do something here maybe?
        }

        // STEP 2: LOAD THE VIEWS
        stream.TypeResolver = this;
        // Clear the reference objects because the view-models will share the same identifier with views.
        stream.ReferenceObjects.Clear();
        var views = stream.DeserializeObjectArray <ViewBase>("Views").ToArray();

        foreach (var view in views)
        {
            VoidMethod(view);
            // Do something here maybe?
        }
    }
コード例 #2
0
    /// <summary>
    /// Load's a set of view-models from a storage medium based on a stream.
    /// </summary>
    /// <param name="storage">This is for loading the stream from a persistant medium. e.g. File, String..etc</param>
    /// <param name="stream">The type of stream to serialize as. eg. Json,Xml,Binary</param>
    public void Load(ISerializerStorage storage, ISerializerStream stream)
    {
        stream.DependencyContainer = Container;
        storage.Load(stream);
        //stream.TypeResolver = new ViewStateResolver(this);
        // ReSharper disable once UnusedVariable
        var vms = stream.DeserializeObjectArray <ViewModel>("ViewModels").ToArray();

        foreach (var vm in vms)
        {
            this[vm.Identifier] = vm;
        }
    }