Exemple #1
0
        public static void SerializeDiff(IVirtualFile file, object target)
        {
            XmlDocument doc = XmlTool.CreateDocument(target.GetType().Name);

            ObjectDiff.SaveDiff(target, target.GetType().CreateNewInstance(), doc.DocumentElement);
            MemoryStream ms = new MemoryStream();

            doc.Save(ms);
            file.SaveBinary(ms.ToArray());
        }
        public static void CopyFileTo(this IVirtualFile srcfile, IVirtualFile dstfile, CopyFileMode mode)
        {
            if (srcfile.DiskPath != null && dstfile.DiskPath != null && IOTool.FileIsLink(srcfile.DiskPath))
            {
                IOTool.CopyFile(srcfile.DiskPath, dstfile.DiskPath, mode);
                return;
            }
            if (srcfile.DataDiskPath != null && dstfile.DataDiskPath != null)
            {
                IOTool.CopyFile(srcfile.DataDiskPath, dstfile.DataDiskPath, mode);
                return;
            }

            string text = null;

            byte[] data = null;
            try
            {
                text = srcfile.GetText();
            }
            catch (Exception)
            {
                data = srcfile.GetBinary();
            }
            if (text != null)
            {
                dstfile.SaveText(text);
            }
            else
            {
                dstfile.SaveBinary(data);
            }
            if (mode == CopyFileMode.Move)
            {
                srcfile.Remove();
            }
        }