Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add a ResourceMove() and a ResourceCopy() method to DataFile

  • Loading branch information...
commit b77801e5e363b57fd96b55c9c892d48d0662e884 1 parent eff7b03
@maul-esel authored
View
2  ChameleonCoder.Abstract/Files/IDataFile.cs
@@ -45,6 +45,8 @@ public interface IDataFile : IAppComponent
void ResourceDelete(IResource resource);
void ResourceInsert(IResource resource, IResource parent);
+ void ResourceMove(IResource resource, IResource newParent);
+ IResource ResourceCopy(IResource resource, IResource newParent);
void ResourceSetCreatedDate(IResource resource);
void ResourceSetCreatedDate(IResource resource, DateTime time);
View
22 ChameleonCoder.Core/Files/DataFile.cs
@@ -454,6 +454,28 @@ public void ResourceInsert(IResource resource, IResource parent)
AddPrivateResourceData(resource, element);
}
+ public void ResourceMove(IResource resource, IResource newParent)
+ {
+ if (resource != null)
+ {
+ DeleteResourceElement(resource); // remove old XML element
+ RemovePrivateResourceData(resource); // remove all references to the resource
+
+ ResourceInsert(resource, newParent); // add new XML element and add references
+ }
+ }
+
+ public IResource ResourceCopy(IResource resource, IResource newParent)
+ {
+ if (resource != null)
+ {
+ IResource newResource = App.ResourceTypeMan.CreateInstanceOf(App.ResourceTypeMan.GetKey(resource.GetType()), resource.Attributes.Clone(), newParent, this);
+ ResourceInsert(newResource, newParent);
+ return newResource;
+ }
+ throw new ArgumentNullException("resource");
+ }
+
private void DeleteResourceElement(IResource resource)
{
XmlElement element = mappings[resource.Attributes];
Please sign in to comment.
Something went wrong with that request. Please try again.