-
Notifications
You must be signed in to change notification settings - Fork 12
/
FileSystemLinkObject.cs
53 lines (52 loc) · 1.88 KB
/
FileSystemLinkObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.IO;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
using DevExpress.Persistent.Validation;
using DevExpress.ExpressApp.DC;
namespace FileSystemData.BusinessObjects {
/// <summary>
/// This class enables you to add soft links to real files instead of saving their contents to the database. It is intended for use in Windows Forms applications only.
/// </summary>
[DefaultProperty(nameof(FileName))]
public class FileSystemLinkObject : BaseObject, IFileData, IEmptyCheckable, ISupportFullName {
#region IFileData Members
[FieldSize(260)]
[ReadOnly(true)]
public virtual string FileName { get; set; }
void IFileData.Clear() {
Size = 0;
FileName = string.Empty;
}
//Dennis: Fires when uploading a file.
void IFileData.LoadFromStream(string fileName, Stream source) {
Size = (int)source.Length;
FileName = fileName;
}
//Dennis: Fires when saving or opening a file.
void IFileData.SaveToStream(Stream destination) {
try {
if (destination == null)
FileSystemDataModule.OpenFileWithDefaultProgram(FullName);
else
FileSystemDataModule.CopyFileToStream(FullName, destination);
} catch (Exception exc) {
throw new UserFriendlyException(exc);
}
}
public virtual int Size { get; set; }
#endregion
#region IEmptyCheckable Members
public bool IsEmpty {
get { return !File.Exists(FullName); }
}
#endregion
#region ISupportFullName Members
[FieldSize(260)]
[ReadOnly(true)]
public virtual string FullName { get; set; }
#endregion
}
}