-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUserFilterObject.cs
84 lines (71 loc) · 2.08 KB
/
UserFilterObject.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace yald
{
[Serializable]
public class UserFilterObject
{
private FilterList Filters;
private string FilterName;
private bool LinkWithAndState;
public static bool SaveFilters(List<UserFilterObject> Filters, string Filename)
{
IFormatter BinFormat = new BinaryFormatter();
Stream FileObj = null;
try
{
FileObj = new FileStream(Filename, FileMode.Create, FileAccess.Write);
BinFormat.Serialize(FileObj, Filters);
FileObj.Close();
}
catch (Exception)
{ return false; }
return true;
}
public static List<UserFilterObject> LoadFilters(string Filename)
{
IFormatter BinFormat = new BinaryFormatter();
Stream FileObj = null;
List<UserFilterObject> Filters;
try
{
FileObj = new FileStream(Filename, FileMode.Open, FileAccess.Read);
Filters = (List<UserFilterObject>)BinFormat.Deserialize(FileObj);
FileObj.Close();
}
catch
{
return null;
}
return Filters;
}
public UserFilterObject()
{
}
public UserFilterObject(FilterList List, string Name, bool LinkWithAnd)
{
Filters = List;
FilterName = Name;
LinkWithAndState = LinkWithAnd;
Filters.LinkWithAnd = LinkWithAnd;
}
public FilterList FilterObject
{
get { return Filters; }
set { Filters = value; }
}
public string Name
{
get { return FilterName; }
set { FilterName = value; }
}
public override string ToString()
{
return FilterName;
}
}
}