enhancements to ProjectFolder and ProjectFile parenting
This commit is contained in:
parent
c72f7cca05
commit
c66dc34ef4
@ -0,0 +1,28 @@
|
||||
//
|
||||
// IProjectItemContainer.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2019 Mike Becker
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
namespace UniversalEditor.ObjectModels.Project
|
||||
{
|
||||
public interface IProjectItemContainer : IProjectFileContainer
|
||||
{
|
||||
ProjectFolder.ProjectFolderCollection Folders { get; }
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
: System.Collections.ObjectModel.Collection<ProjectFile>
|
||||
{
|
||||
private IProjectFileContainer _parent = null;
|
||||
public ProjectFileCollection(ProjectFolder parent = null)
|
||||
public ProjectFileCollection(IProjectFileContainer parent = null)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
@ -5,32 +5,36 @@ using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Project
|
||||
{
|
||||
public class ProjectFileSystem
|
||||
public class ProjectFileSystem : IProjectItemContainer
|
||||
{
|
||||
private ProjectFolder.ProjectFolderCollection mvarFolders = new ProjectFolder.ProjectFolderCollection();
|
||||
/// <summary>
|
||||
/// The collection of folders in this project.
|
||||
/// </summary>
|
||||
public ProjectFolder.ProjectFolderCollection Folders { get { return mvarFolders; } }
|
||||
public ProjectFolder.ProjectFolderCollection Folders { get; private set; } = null;
|
||||
|
||||
private ProjectFile.ProjectFileCollection mvarFiles = new ProjectFile.ProjectFileCollection();
|
||||
/// <summary>
|
||||
/// The collection of files in this project.
|
||||
/// </summary>
|
||||
public ProjectFile.ProjectFileCollection Files { get { return mvarFiles; } }
|
||||
public ProjectFile.ProjectFileCollection Files { get; private set; } = null;
|
||||
|
||||
public ProjectFileSystem()
|
||||
{
|
||||
Files = new ProjectFile.ProjectFileCollection(this);
|
||||
Folders = new ProjectFolder.ProjectFolderCollection(this);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
mvarFolders.Clear();
|
||||
mvarFiles.Clear();
|
||||
Folders.Clear();
|
||||
Files.Clear();
|
||||
}
|
||||
public void CopyTo(ProjectFileSystem clone)
|
||||
{
|
||||
foreach (ProjectFile file in mvarFiles)
|
||||
foreach (ProjectFile file in Files)
|
||||
{
|
||||
clone.Files.Add(file.Clone() as ProjectFile);
|
||||
}
|
||||
foreach (ProjectFolder folder in mvarFolders)
|
||||
foreach (ProjectFolder folder in Folders)
|
||||
{
|
||||
clone.Folders.Add(folder.Clone() as ProjectFolder);
|
||||
}
|
||||
|
||||
@ -5,13 +5,13 @@ using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Project
|
||||
{
|
||||
public class ProjectFolder : IProjectFileContainer, ICloneable
|
||||
public class ProjectFolder : IProjectItemContainer, ICloneable
|
||||
{
|
||||
public class ProjectFolderCollection
|
||||
: System.Collections.ObjectModel.Collection<ProjectFolder>
|
||||
{
|
||||
private ProjectFolder _parent = null;
|
||||
public ProjectFolderCollection(ProjectFolder parent = null)
|
||||
private IProjectItemContainer _parent = null;
|
||||
public ProjectFolderCollection(IProjectItemContainer parent = null)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
@ -77,8 +77,8 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
private string mvarName = String.Empty;
|
||||
public string Name { get { return mvarName; } set { mvarName = value; } }
|
||||
|
||||
private ProjectFolder mvarParent = null;
|
||||
public ProjectFolder Parent { get { return mvarParent; } private set { mvarParent = value; } }
|
||||
private IProjectItemContainer mvarParent = null;
|
||||
public IProjectItemContainer Parent { get { return mvarParent; } private set { mvarParent = value; } }
|
||||
|
||||
private ProjectFolder.ProjectFolderCollection mvarFolders = null;
|
||||
public ProjectFolder.ProjectFolderCollection Folders { get { return mvarFolders; } }
|
||||
|
||||
@ -193,6 +193,7 @@
|
||||
<Compile Include="ObjectModels\Database\DatabaseRecord.cs" />
|
||||
<Compile Include="ObjectModels\Database\DatabaseTable.cs" />
|
||||
<Compile Include="ObjectModels\Database\DatabaseObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Project\IProjectItemContainer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user