Esempio n. 1
0
        /// <summary>
        /// Saves the project state to a memento.
        /// </summary>
        /// <returns>Memento containing the project state.</returns>
        public ProjectMemento CreateMemento()
        {
            var memento = new ProjectMemento();

            foreach (var item in Items)
            {
                memento.Items.Add(item.RelativePath);
            }

            if (MainItem != null)
            {
                memento.MainItem = MainItem.RelativePath;
            }

            memento.Platform = Platform.Name;
            return(memento);
        }
Esempio n. 2
0
        /// <summary>
        /// Restores the project state from the specified memento.
        /// </summary>
        /// <param name="memento">The memento to restore.</param>
        public void SetMemento(ProjectMemento memento)
        {
            Items.Clear();
            MainItem = null;
            foreach (var i in memento.Items)
            {
                var item = new ProjectItem();
                item.Project      = this;
                item.RelativePath = i;
                if (!File.Exists(item.Path))
                {
                    File.WriteAllText(item.Path, string.Empty);
                }
                Items.Add(item);

                if (i == memento.MainItem)
                {
                    MainItem = item;
                }
            }

            SetPlatformByName(memento.Platform);
        }
Esempio n. 3
0
        /// <summary>
        /// Restores the project state from the specified memento.
        /// </summary>
        /// <param name="memento">The memento to restore.</param>
        public void SetMemento(ProjectMemento memento)
        {
            Items.Clear();
            MainItem = null;
            foreach (var i in memento.Items)
            {
                var item = new ProjectItem();
                item.Project = this;
                item.RelativePath = i;
                if (!File.Exists(item.Path))
                {
                    File.WriteAllText(item.Path, string.Empty);
                }
                Items.Add(item);

                if (i == memento.MainItem)
                { MainItem = item; }
            }

            SetPlatformByName(memento.Platform);
        }
Esempio n. 4
0
        /// <summary>
        /// Saves the project state to a memento.
        /// </summary>
        /// <returns>Memento containing the project state.</returns>
        public ProjectMemento CreateMemento()
        {
            var memento = new ProjectMemento();
            foreach (var item in Items)
            {
                memento.Items.Add(item.RelativePath);
            }

            if (MainItem != null)
            { memento.MainItem = MainItem.RelativePath; }

            memento.Platform = Platform.Name;
            return memento;
        }