示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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;
        }