EaseFilter Demo Project
FilterRuleSection.cs
Go to the documentation of this file.
1 //
3 // (C) Copyright 2012 EaseFilter Technologies Inc.
4 // All Rights Reserved
5 //
6 // This software is part of a licensed software product and may
7 // only be used or copied in accordance with the terms of that license.
8 //
10 
11 using System;
12 using System.Collections.Generic;
13 using System.Linq;
14 using System.Text;
15 using System.Configuration;
16 
17 namespace EaseFilter.CommonObjects
18 {
19  public class FilterRuleSection : ConfigurationSection
20  {
21  [ConfigurationProperty("", IsRequired = true, IsDefaultCollection = true)]
22  public FilterRuleCollection Instances
23  {
24  get { return (FilterRuleCollection)this[""]; }
25  set { this[""] = value; }
26  }
27  }
28 
29  public class FilterRuleCollection : ConfigurationElementCollection
30  {
31  public FilterRule this[int index]
32  {
33  get { return (FilterRule)BaseGet(index); }
34  set
35  {
36  if (BaseGet(index) != null)
37  {
38  BaseRemoveAt(index);
39  }
40  BaseAdd(index, value);
41  }
42  }
43 
44  public void Add(FilterRule filterRule)
45  {
46  BaseAdd(filterRule);
47  }
48 
49  public void Clear()
50  {
51  BaseClear();
52  }
53 
54  public void Remove(FilterRule filterRule)
55  {
56  BaseRemove(filterRule.IncludeFileFilterMask);
57  }
58 
59  public void RemoveAt(int index)
60  {
61  BaseRemoveAt(index);
62  }
63 
64  public void Remove(string name)
65  {
66  BaseRemove(name);
67  }
68 
69  protected override ConfigurationElement CreateNewElement()
70  {
71  return new FilterRule();
72  }
73 
74  protected override object GetElementKey(ConfigurationElement element)
75  {
76  //set to whatever Element Property you want to use for a key
77  return ((FilterRule)element).IncludeFileFilterMask;
78  }
79  }
80 
81  public class FilterRule : ConfigurationElement
82  {
83  //A filter rule must have a unique include file filter mask,
84  //A filter rule can have multiple exclude file filter masks.
85  //Make sure to set IsKey=true for property exposed as the GetElementKey above
86  [ConfigurationProperty("includeFileFilterMask", IsKey = true, IsRequired = true)]
87  public string IncludeFileFilterMask
88  {
89  get { return (string)base["includeFileFilterMask"]; }
90  set { base["includeFileFilterMask"] = value; }
91  }
92 
93  [ConfigurationProperty("excludeFileFilterMasks", IsRequired = false)]
94  public string ExcludeFileFilterMasks
95  {
96  get { return (string)base["excludeFileFilterMasks"]; }
97  set { base["excludeFileFilterMasks"] = value; }
98  }
99 
100  [ConfigurationProperty("includeProcessNames", IsRequired = false)]
101  public string IncludeProcessNames
102  {
103  get { return (string)base["includeProcessNames"]; }
104  set { base["includeProcessNames"] = value; }
105  }
106 
107  [ConfigurationProperty("excludeProcessNames", IsRequired = false)]
108  public string ExcludeProcessNames
109  {
110  get { return (string)base["excludeProcessNames"]; }
111  set { base["excludeProcessNames"] = value; }
112  }
113 
114  [ConfigurationProperty("includeUserNames", IsRequired = false)]
115  public string IncludeUserNames
116  {
117  get { return (string)base["includeUserNames"]; }
118  set { base["includeUserNames"] = value; }
119  }
120 
121  [ConfigurationProperty("excludeUserNames", IsRequired = false)]
122  public string ExcludeUserNames
123  {
124  get { return (string)base["excludeUserNames"]; }
125  set { base["excludeUserNames"] = value; }
126  }
127 
128  [ConfigurationProperty("includeProcessIds", IsKey = true, IsRequired = true)]
129  public string IncludeProcessIds
130  {
131  get { return (string)base["includeProcessIds"]; }
132  set { base["includeProcessIds"] = value; }
133  }
134 
135  [ConfigurationProperty("excludeProcessIds", IsRequired = false)]
136  public string ExcludeProcessIds
137  {
138  get { return (string)base["excludeProcessIds"]; }
139  set { base["excludeProcessIds"] = value; }
140  }
141 
142  [ConfigurationProperty("hiddenFileFilterMasks", IsRequired = false)]
143  public string HiddenFileFilterMasks
144  {
145  get { return (string)base["hiddenFileFilterMasks"]; }
146  set { base["hiddenFileFilterMasks"] = value; }
147  }
148 
149 
150  [ConfigurationProperty("encryptionPassPhrase", IsRequired = false)]
151  public string EncryptionPassPhrase
152  {
153  get
154  {
155  string key = (string)base["encryptionPassPhrase"];
156  if (Utils.IsBase64String(key))
157  {
158  key = FilterAPI.AESEncryptDecryptStr(key, FilterAPI.EncryptType.Decryption);
159  }
160 
161  return key;
162  }
163  set
164  {
165  string key = value.Trim();
166 
167  if (key.Length > 0)
168  {
169  key = FilterAPI.AESEncryptDecryptStr(key, FilterAPI.EncryptType.Encryption);
170  }
171 
172  base["encryptionPassPhrase"] = key;
173  }
174  }
175 
176  [ConfigurationProperty("accessFlag", IsRequired = true)]
177  public uint AccessFlag
178  {
179  get { return (uint)base["accessFlag"]; }
180  set { base["accessFlag"] = value; }
181  }
182 
186  [ConfigurationProperty("eventType", IsRequired = false)]
187  public uint EventType
188  {
189  get { return (uint)base["eventType"]; }
190  set { base["eventType"] = value; }
191  }
192 
196  [ConfigurationProperty("monitorIO", IsRequired = false)]
197  public uint MonitorIO
198  {
199  get { return (uint)base["monitorIO"]; }
200  set { base["monitorIO"] = value; }
201  }
202 
206  [ConfigurationProperty("controlIO", IsRequired = false)]
207  public uint ControlIO
208  {
209  get { return (uint)base["controlIO"]; }
210  set { base["controlIO"] = value; }
211  }
212  }
213 
214 
215 }
unsigned char key[]
override ConfigurationElement CreateNewElement()
static bool IsBase64String(string s)
Definition: Utils.cs:237
override object GetElementKey(ConfigurationElement element)
enum _AccessFlag AccessFlag

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com