Add Parent property to get parent folder of a File, if available
This commit is contained in:
parent
3140766480
commit
1007b6f6f0
@ -76,6 +76,28 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
{
|
||||
return (this[Name] != null);
|
||||
}
|
||||
|
||||
private Folder mvarParent = null;
|
||||
public FileCollection(Folder parent = null)
|
||||
{
|
||||
mvarParent = parent;
|
||||
}
|
||||
|
||||
protected override void InsertItem(int index, File item)
|
||||
{
|
||||
base.InsertItem(index, item);
|
||||
item.Parent = mvarParent;
|
||||
}
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
this[index].Parent = null;
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
protected override void SetItem(int index, File item)
|
||||
{
|
||||
item.Parent = mvarParent;
|
||||
base.SetItem(index, item);
|
||||
}
|
||||
}
|
||||
|
||||
private FileAttributes mvarAttributes = FileAttributes.None;
|
||||
@ -142,6 +164,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
{
|
||||
clone.Properties.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
clone.Parent = mvarParent;
|
||||
return clone;
|
||||
}
|
||||
|
||||
@ -244,6 +267,9 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
/// </summary>
|
||||
public FileSource Source { get { return mvarSource; } set { mvarSource = value; } }
|
||||
|
||||
private Folder mvarParent = null;
|
||||
public Folder Parent { get { return mvarParent; } internal set { mvarParent = value; } }
|
||||
|
||||
// The amount of working set to allocate to each block.
|
||||
public const int BLOCK_FRACTION = 4;
|
||||
|
||||
|
||||
@ -77,6 +77,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
public Folder()
|
||||
{
|
||||
mvarFolders = new FolderCollection(this);
|
||||
mvarFiles = new File.FileCollection(this);
|
||||
}
|
||||
|
||||
private FolderCollection _parentCollection = null;
|
||||
@ -90,7 +91,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
private FolderCollection mvarFolders = null;
|
||||
public FolderCollection Folders { get { return mvarFolders; } }
|
||||
|
||||
private File.FileCollection mvarFiles = new File.FileCollection();
|
||||
private File.FileCollection mvarFiles = null;
|
||||
public File.FileCollection Files { get { return mvarFiles; } }
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user