~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/core/Policy/.svn/text-base/FileTypeFilter.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
 |
3
 
 | Copyright (c) 2007 Novell, Inc.
4
 
 | All Rights Reserved.
5
 
 |
6
 
 | This program is free software; you can redistribute it and/or
7
 
 | modify it under the terms of version 2 of the GNU General Public License as
8
 
 | published by the Free Software Foundation.
9
 
 |
10
 
 | This program is distributed in the hope that it will be useful,
11
 
 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 | GNU General Public License for more details.
14
 
 |
15
 
 | You should have received a copy of the GNU General Public License
16
 
 | along with this program; if not, contact Novell, Inc.
17
 
 |
18
 
 | To contact Novell about this file by physical or electronic mail,
19
 
 | you may find current contact information at www.novell.com 
20
 
 |
21
 
 | Author: Mike Lasky <mlasky@novell.com> 
22
 
 |***************************************************************************/
23
 
 
24
 
using System;
25
 
using System.Collections;
26
 
using System.IO;
27
 
 
28
 
using Simias;
29
 
using Simias.Storage;
30
 
 
31
 
namespace Simias.Policy
32
 
{
33
 
        /// <summary>
34
 
        /// List used to specify a filter list to the policy.
35
 
        /// </summary>
36
 
        public struct FileTypeEntry
37
 
        {
38
 
                #region Class Members
39
 
 
40
 
                /// <summary>
41
 
                /// File extension to add as filter.
42
 
                /// </summary>
43
 
                private string fileName;
44
 
 
45
 
                /// <summary>
46
 
                /// If true then file extension will be allowed to pass through the filter
47
 
                /// If false then file will be disallowed to pass through the filter.
48
 
                /// </summary>
49
 
                private bool allowed;
50
 
 
51
 
                /// <summary>
52
 
                /// If true then filter comparision will be case-insensitive.
53
 
                /// </summary>
54
 
                private bool ignoreCase;
55
 
                #endregion
56
 
 
57
 
                #region Properties
58
 
                /// <summary>
59
 
                /// Gets the filter extension name.
60
 
                /// </summary>
61
 
                public string Name
62
 
                {
63
 
                        get { return fileName; }
64
 
                }
65
 
 
66
 
                /// <summary>
67
 
                /// Gets whether filter extension is allowed or disallowed through the filter.
68
 
                /// </summary>
69
 
                public bool Allowed
70
 
                {
71
 
                        get { return allowed; }
72
 
                }
73
 
 
74
 
                /// <summary>
75
 
                /// Gets whether the filter comparision will be case-insensitive.
76
 
                /// </summary>
77
 
                public bool IgnoreCase
78
 
                {
79
 
                        get { return ignoreCase; }
80
 
                }
81
 
                #endregion
82
 
 
83
 
                #region Constructor
84
 
                /// <summary>
85
 
                /// Initializes an instance of the object.
86
 
                /// </summary>
87
 
                /// <param name="fileName">Filename to use as a filter. Can be a regular expression.</param>
88
 
                /// <param name="allowed">If true then all files that have extensions that match the 
89
 
                /// fileNameExtension parameter will be allowed to pass through the filter.</param>
90
 
                public FileTypeEntry( string fileName, bool allowed ) :
91
 
                        this ( fileName, allowed, false )
92
 
                {
93
 
                }
94
 
 
95
 
                /// <summary>
96
 
                /// Initializes an instance of the object.
97
 
                /// </summary>
98
 
                /// <param name="fileName">Filename to use as a filter. Can be a regular expression.</param>
99
 
                /// <param name="allowed">If true then all files that have extensions that match the 
100
 
                /// fileNameExtension parameter will be allowed to pass through the filter.</param>
101
 
                /// <param name="ignoreCase">If true filter comparision will be case-insensitive.</param>
102
 
                public FileTypeEntry( string fileName, bool allowed, bool ignoreCase )
103
 
                {
104
 
                        this.fileName = fileName;
105
 
                        this.allowed = allowed;
106
 
                        this.ignoreCase = ignoreCase;
107
 
                }
108
 
                #endregion
109
 
        }
110
 
 
111
 
        /// <summary>
112
 
        /// Implements the file type filter policy.
113
 
        /// </summary>
114
 
        public class FileTypeFilter
115
 
        {
116
 
                #region Class Members
117
 
                
118
 
                /// <summary>
119
 
                /// Used to log messages.
120
 
                /// </summary>
121
 
                static private readonly ISimiasLog log = SimiasLogManager.GetLogger( typeof( Store ) );
122
 
 
123
 
                /// <summary>
124
 
                /// Well known name for the file type filter policy.
125
 
                /// </summary>
126
 
                static public string FileTypeFilterPolicyID = "e69ff680-3f75-412e-a929-1b0247ed4041";
127
 
 
128
 
                /// <summary>
129
 
                /// Well known name for the file type filter policy description.
130
 
                /// </summary>
131
 
                static public string FileTypeFilterShortDescription = "File type filter";
132
 
 
133
 
                /// <summary>
134
 
                /// Policy object that contains the aggregate policy for the domain and member only.
135
 
                /// </summary>
136
 
                private Policy memberPolicy;
137
 
 
138
 
                /// <summary>
139
 
                /// Policy object that contains the aggregate policy including the collection limits.
140
 
                /// </summary>
141
 
                private Policy collectionPolicy = null;
142
 
                #endregion
143
 
 
144
 
                #region Properties
145
 
                /// <summary>
146
 
                /// Gets the file type filter list.
147
 
                /// </summary>
148
 
                public FileTypeEntry[] FilterList
149
 
                {
150
 
                        get { return GetPatterns( ( collectionPolicy != null ) ? collectionPolicy : memberPolicy  ); }
151
 
                }
152
 
                #endregion
153
 
 
154
 
                #region Constructor
155
 
                /// <summary>
156
 
                /// Initializes a new instance of an object.
157
 
                /// </summary>
158
 
                /// <param name="member">Member that this file type filter is associated with.</param>
159
 
                private FileTypeFilter( Member member )
160
 
                {
161
 
                        PolicyManager pm = new PolicyManager();
162
 
                        this.memberPolicy = pm.GetAggregatePolicy( FileTypeFilterPolicyID, member, true );
163
 
                }
164
 
 
165
 
                /// <summary>
166
 
                /// Initializes a new instance of an object.
167
 
                /// </summary>
168
 
                /// <param name="collection">Collection that this disk space quota is associated with.</param>
169
 
                private FileTypeFilter( Collection collection )
170
 
                {
171
 
                        PolicyManager pm = new PolicyManager();
172
 
                        Member member = collection.Owner;
173
 
                        this.memberPolicy = pm.GetAggregatePolicy( FileTypeFilterPolicyID, member, true );
174
 
                        this.collectionPolicy = pm.GetAggregatePolicy( FileTypeFilterPolicyID, member, collection, true );
175
 
                }
176
 
                #endregion
177
 
 
178
 
                #region Factory Methods
179
 
                /// <summary>
180
 
                /// Creates a system wide file filter policy.
181
 
                /// </summary>
182
 
                /// <param name="domainID">Domain that the filter will be associated with.</param>
183
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
184
 
                static public void Create( string domainID, FileTypeEntry[] patterns )
185
 
                {
186
 
                        // Need a policy manager.
187
 
                        PolicyManager pm = new PolicyManager();
188
 
                        
189
 
                        // See if the policy already exists.
190
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, domainID );
191
 
                        if ( patterns.Length > 0 )
192
 
                        {
193
 
                                if ( policy == null )
194
 
                                {
195
 
                                        // The policy does not exist, create a new one and add the rules.
196
 
                                        policy = new Policy( FileTypeFilterPolicyID, FileTypeFilterShortDescription );
197
 
                                }
198
 
                                else
199
 
                                {
200
 
                                        // The policy already exists, delete the old rules.
201
 
                                        foreach ( Rule r in policy.Rules )
202
 
                                        {
203
 
                                                policy.DeleteRule( r );
204
 
                                        }
205
 
                                }
206
 
 
207
 
                                // Add the new rules and save the policy.
208
 
                                foreach( FileTypeEntry fte in patterns )
209
 
                                {
210
 
                                        policy.AddRule( new Rule( fte.Name, fte.IgnoreCase ? Rule.Operation.RegExp_IgnoreCase : Rule.Operation.RegExp, fte.Allowed ? Rule.Result.Allow : Rule.Result.Deny ) );
211
 
                                }
212
 
 
213
 
                                pm.CommitPolicy( policy, domainID );
214
 
                        }
215
 
                        else if ( policy != null )
216
 
                        {
217
 
                                // An empty array is the same thing as deleting the policy.
218
 
                                pm.DeletePolicy( policy );
219
 
                        }
220
 
                }
221
 
 
222
 
                /// <summary>
223
 
                /// Creates a file type filter policy for the specified member.
224
 
                /// </summary>
225
 
                /// <param name="member">Member that the filter will be associated with.</param>
226
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
227
 
                static public void Create( Member member, FileTypeEntry[] patterns )
228
 
                {
229
 
                        // Need a policy manager.
230
 
                        PolicyManager pm = new PolicyManager();
231
 
                        
232
 
                        // See if the policy already exists.
233
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, member );
234
 
                        if ( patterns.Length > 0 )
235
 
                        {
236
 
                                if ( policy == null )
237
 
                                {
238
 
                                        // The policy does not exist, create a new one and add the rules.
239
 
                                        policy = new Policy( FileTypeFilterPolicyID, FileTypeFilterShortDescription );
240
 
                                }
241
 
                                else
242
 
                                {
243
 
                                        // The policy already exists, delete the old rules.
244
 
                                        foreach ( Rule r in policy.Rules )
245
 
                                        {
246
 
                                                policy.DeleteRule( r );
247
 
                                        }
248
 
                                }
249
 
 
250
 
                                // Add the new rules and save the policy.
251
 
                                foreach( FileTypeEntry fte in patterns )
252
 
                                {
253
 
                                        policy.AddRule( new Rule( fte.Name, fte.IgnoreCase ? Rule.Operation.RegExp_IgnoreCase : Rule.Operation.RegExp, fte.Allowed ? Rule.Result.Allow : Rule.Result.Deny ) );
254
 
                                }
255
 
 
256
 
                                pm.CommitPolicy( policy, member );
257
 
                        }
258
 
                        else if ( policy != null )
259
 
                        {
260
 
                                // An empty array is the same thing as deleting the policy.
261
 
                                pm.DeletePolicy( policy );
262
 
                        }
263
 
                }
264
 
 
265
 
                /// <summary>
266
 
                /// Creates a file type filter policy for the specified collection.
267
 
                /// </summary>
268
 
                /// <param name="collection">Collection that the filter will be associated with.</param>
269
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
270
 
                static public void Create( Collection collection, FileTypeEntry[] patterns )
271
 
                {
272
 
                        // Need a policy manager.
273
 
                        PolicyManager pm = new PolicyManager();
274
 
                        
275
 
                        // See if the policy already exists.
276
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, collection );
277
 
                        if ( patterns.Length > 0 )
278
 
                        {
279
 
                                if ( policy == null )
280
 
                                {
281
 
                                        // The policy does not exist, create a new one and add the rules.
282
 
                                        policy = new Policy( FileTypeFilterPolicyID, FileTypeFilterShortDescription );
283
 
                                }
284
 
                                else
285
 
                                {
286
 
                                        // The policy already exists, delete the old rules.
287
 
                                        foreach ( Rule r in policy.Rules )
288
 
                                        {
289
 
                                                policy.DeleteRule( r );
290
 
                                        }
291
 
                                }
292
 
 
293
 
                                // Add the new rules and save the policy.
294
 
                                foreach( FileTypeEntry fte in patterns )
295
 
                                {
296
 
                                        policy.AddRule( new Rule( fte.Name, fte.IgnoreCase ? Rule.Operation.RegExp_IgnoreCase : Rule.Operation.RegExp, fte.Allowed ? Rule.Result.Allow : Rule.Result.Deny ) );
297
 
                                }
298
 
 
299
 
                                pm.CommitPolicy( policy, collection );
300
 
                        }
301
 
                        else if ( policy != null )
302
 
                        {
303
 
                                // An empty array is the same thing as deleting the policy.
304
 
                                pm.DeletePolicy( policy );
305
 
                        }
306
 
                }
307
 
 
308
 
                /// <summary>
309
 
                /// Creates a file type filter policy for the current user on the current machine.
310
 
                /// </summary>
311
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
312
 
                static public void Create( FileTypeEntry[] patterns )
313
 
                {
314
 
                        // Need a policy manager.
315
 
                        PolicyManager pm = new PolicyManager();
316
 
                        
317
 
                        // See if the policy already exists.
318
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID );
319
 
                        if ( patterns.Length > 0 )
320
 
                        {
321
 
                                if ( policy == null )
322
 
                                {
323
 
                                        // The policy does not exist, create a new one and add the rules.
324
 
                                        policy = new Policy( FileTypeFilterPolicyID, FileTypeFilterShortDescription );
325
 
                                }
326
 
                                else
327
 
                                {
328
 
                                        // The policy already exists, delete the old rules.
329
 
                                        foreach ( Rule r in policy.Rules )
330
 
                                        {
331
 
                                                policy.DeleteRule( r );
332
 
                                        }
333
 
                                }
334
 
 
335
 
                                // Add the new rules and save the policy.
336
 
                                foreach( FileTypeEntry fte in patterns )
337
 
                                {
338
 
                                        policy.AddRule( new Rule( fte.Name, fte.IgnoreCase ? Rule.Operation.RegExp_IgnoreCase : Rule.Operation.RegExp, fte.Allowed ? Rule.Result.Allow : Rule.Result.Deny ) );
339
 
                                }
340
 
 
341
 
                                pm.CommitLocalMachinePolicy( policy );
342
 
                        }
343
 
                        else if ( policy != null )
344
 
                        {
345
 
                                // An empty array is the same thing as deleting the policy.
346
 
                                pm.DeletePolicy( policy );
347
 
                        }
348
 
                }
349
 
 
350
 
                /// <summary>
351
 
                /// Deletes a system wide file filter policy.
352
 
                /// </summary>
353
 
                /// <param name="domainID">Domain that the filter will be associated with.</param>
354
 
                static public void Delete( string domainID )
355
 
                {
356
 
                        // Need a policy manager.
357
 
                        PolicyManager pm = new PolicyManager();
358
 
                        
359
 
                        // See if the policy already exists.
360
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, domainID );
361
 
                        if ( policy != null )
362
 
                        {
363
 
                                // Delete the policy.
364
 
                                pm.DeletePolicy( policy );
365
 
                        }
366
 
                }
367
 
 
368
 
                /// <summary>
369
 
                /// Deletes a file type filter policy for the specified member.
370
 
                /// </summary>
371
 
                /// <param name="member">Member that the filter will be associated with.</param>
372
 
                static public void Delete( Member member )
373
 
                {
374
 
                        // Need a policy manager.
375
 
                        PolicyManager pm = new PolicyManager();
376
 
                        
377
 
                        // See if the policy already exists.
378
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, member );
379
 
                        if ( policy != null )
380
 
                        {
381
 
                                // Delete the policy.
382
 
                                pm.DeletePolicy( policy );
383
 
                        }
384
 
                }
385
 
 
386
 
                /// <summary>
387
 
                /// Deletes a file type filter policy for the specified collection.
388
 
                /// </summary>
389
 
                /// <param name="collection">Collection that the filter will be associated with.</param>
390
 
                static public void Delete( Collection collection )
391
 
                {
392
 
                        // Need a policy manager.
393
 
                        PolicyManager pm = new PolicyManager();
394
 
                        
395
 
                        // See if the policy already exists.
396
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, collection );
397
 
                        if ( policy != null )
398
 
                        {
399
 
                                // Delete the policy.
400
 
                                pm.DeletePolicy( policy );
401
 
                        }
402
 
                }
403
 
 
404
 
                /// <summary>
405
 
                /// Deletes a file type filter policy for the current user on the current machine.
406
 
                /// </summary>
407
 
                static public void Delete()
408
 
                {
409
 
                        // Need a policy manager.
410
 
                        PolicyManager pm = new PolicyManager();
411
 
                        
412
 
                        // See if the policy already exists.
413
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID );
414
 
                        if ( policy != null )
415
 
                        {
416
 
                                // Delete the policy.
417
 
                                pm.DeletePolicy( policy );
418
 
                        }
419
 
                }
420
 
 
421
 
                /// <summary>
422
 
                /// Gets the aggregate file type filter policy for the specified member.
423
 
                /// </summary>
424
 
                /// <param name="member">Member that filter is associated with.</param>
425
 
                /// <returns>A FileTypeFilter object that contains the policy for the specified member.</returns>
426
 
                static public FileTypeFilter Get( Member member )
427
 
                {
428
 
                        return new FileTypeFilter( member );
429
 
                }
430
 
 
431
 
                /// <summary>
432
 
                /// Gets the aggregate file type filter policy for the specified member and collection.
433
 
                /// </summary>
434
 
                /// <param name="member">Member that filter is associated with.</param>
435
 
                /// <param name="collection">Collection to add to the aggregate quota policy.</param>
436
 
                /// <returns>A FileTypeFilter object that contains the policy for the specified member.</returns>
437
 
                [ Obsolete( "This method is obsolete. Please use DiskSpaceQuota.Get( Collection collection ) instead.", false ) ]
438
 
                static public FileTypeFilter Get( Member member, Collection collection )
439
 
                {
440
 
                        return FileTypeFilter.Get( collection );
441
 
                }
442
 
 
443
 
                /// <summary>
444
 
                /// Gets the aggregate file type filter policy for the specified member and collection.
445
 
                /// </summary>
446
 
                /// <param name="collection">Collection to add to the aggregate quota policy.</param>
447
 
                /// <returns>A FileTypeFilter object that contains the policy for the specified member.</returns>
448
 
                static public FileTypeFilter Get( Collection collection )
449
 
                {
450
 
                        return new FileTypeFilter( collection );
451
 
                }
452
 
 
453
 
                /// <summary>
454
 
                /// Gets the file type filter patterns associated with the specified domain.
455
 
                /// </summary>
456
 
                /// <param name="domainID">Domain that the filter is associated with.</param>
457
 
                /// <returns>Array of file type filter patterns for this policy if successful. If there are no
458
 
                /// filter patterns then null is returned.</returns>
459
 
                static public FileTypeEntry[] GetPatterns( string domainID )
460
 
                {
461
 
                        PolicyManager pm = new PolicyManager();
462
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, domainID );
463
 
                        return ( policy != null ) ? GetPatterns( policy ) : null;
464
 
                }
465
 
 
466
 
                /// <summary>
467
 
                /// Gets the file type filter patterns associated with the specified member.
468
 
                /// </summary>
469
 
                /// <param name="member">Member that the filter is associated with.</param>
470
 
                /// <returns>Array of file type filter patterns for this policy if successful. If there are no
471
 
                /// filter patterns then null is returned.</returns>
472
 
                static public FileTypeEntry[] GetPatterns( Member member )
473
 
                {
474
 
                        PolicyManager pm = new PolicyManager();
475
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, member );
476
 
                        return ( policy != null ) ? GetPatterns( policy ) : null;
477
 
                }
478
 
 
479
 
                /// <summary>
480
 
                /// Gets the file type filter patterns associated with the specified collection.
481
 
                /// </summary>
482
 
                /// <param name="collection">Collection that the limit is associated with.</param>
483
 
                /// <returns>Array of file type filter patterns for this policy if successful. If there are no
484
 
                /// filter patterns then null is returned.</returns>
485
 
                static public FileTypeEntry[] GetPatterns( Collection collection )
486
 
                {
487
 
                        PolicyManager pm = new PolicyManager();
488
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID, collection );
489
 
                        return ( policy != null ) ? GetPatterns( policy ) : null;
490
 
                }
491
 
 
492
 
                /// <summary>
493
 
                /// Gets the file type filter patterns associated with the current user on the current machine.
494
 
                /// </summary>
495
 
                /// <returns>Array of file type filter patterns for this policy if successful. If there are no
496
 
                /// filter patterns then null is returned.</returns>
497
 
                static public FileTypeEntry[] GetPatterns()
498
 
                {
499
 
                        PolicyManager pm = new PolicyManager();
500
 
                        Policy policy = pm.GetPolicy( FileTypeFilterPolicyID );
501
 
                        return ( policy != null ) ? GetPatterns( policy ) : null;
502
 
                }
503
 
 
504
 
                /// <summary>
505
 
                /// Sets the file type filter associated with the specified domain.
506
 
                /// </summary>
507
 
                /// <param name="domainID">Domain that the filter is associated with.</param>
508
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
509
 
                static public void Set( string domainID, FileTypeEntry[] patterns )
510
 
                {
511
 
                        Create( domainID, patterns );
512
 
                }
513
 
 
514
 
                /// <summary>
515
 
                /// Sets the file type filter associated with the specified member.
516
 
                /// </summary>
517
 
                /// <param name="member">Member that the filter is associated with.</param>
518
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
519
 
                static public void Set( Member member, FileTypeEntry[] patterns )
520
 
                {
521
 
                        Create( member, patterns );
522
 
                }
523
 
 
524
 
                /// <summary>
525
 
                /// Sets the file type filter associated with the specified collection.
526
 
                /// </summary>
527
 
                /// <param name="collection">Collection that the filter is associated with.</param>
528
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
529
 
                static public void Set( Collection collection, FileTypeEntry[] patterns )
530
 
                {
531
 
                        Create( collection, patterns );
532
 
                }
533
 
 
534
 
                /// <summary>
535
 
                /// Sets the file type filter associated with the current user on the current machine.
536
 
                /// </summary>
537
 
                /// <param name="patterns">File type patterns that will be used to filter files.</param>
538
 
                static public void Set( FileTypeEntry[] patterns )
539
 
                {
540
 
                        Create( patterns );
541
 
                }
542
 
                #endregion
543
 
 
544
 
                #region Private Methods
545
 
                /// <summary>
546
 
                /// Gets the file type filter patterns for the specified policy.
547
 
                /// </summary>
548
 
                /// <param name="policy">Policy to retrieve the filter patterns from.</param>
549
 
                /// <returns>An array of file type filter patterns for the given policy.</returns>
550
 
                static private FileTypeEntry[] GetPatterns( Policy policy )
551
 
                {
552
 
                        // List to hold the temporary results.
553
 
                        ArrayList tempList = new ArrayList();
554
 
 
555
 
                        // Return all of the rules.
556
 
                        if ( policy != null )
557
 
                        {
558
 
                                foreach ( Rule rule in policy.Rules )
559
 
                                {
560
 
                                        FileTypeEntry fte = new FileTypeEntry( rule.Operand as string, ( rule.RuleResult == Rule.Result.Allow ) ? true : false, ( rule.RuleOperation == Rule.Operation.RegExp ) ? false : true );
561
 
                                        tempList.Add( fte );
562
 
                                }
563
 
                        }
564
 
 
565
 
                        return tempList.ToArray( typeof( FileTypeEntry ) ) as FileTypeEntry[];
566
 
                }
567
 
                #endregion
568
 
 
569
 
                #region Public Methods
570
 
                /// <summary>
571
 
                /// Returns whether the specified file is allowed to pass through the filter.
572
 
                /// </summary>
573
 
                /// <param name="fileName">Name of the file including its extension.</param>
574
 
                /// <returns>True if the file is allowed to pass through the filter. Otherwise false is returned.</returns>
575
 
                public bool Allowed( string fileName )
576
 
                {
577
 
                        bool isAllowed = true;
578
 
                        string fullPath = Path.GetFileName( fileName );
579
 
 
580
 
                        // Check the overall domain/member policy first to make sure that the file type is not excluded.
581
 
                        if ( memberPolicy != null )
582
 
                        {
583
 
                                // Apply the rule to see if there is space available.
584
 
                                isAllowed = ( memberPolicy.Apply( fullPath ) == Rule.Result.Allow );
585
 
                        }
586
 
 
587
 
                        if ( ( collectionPolicy != null ) && isAllowed )
588
 
                        {
589
 
                                // Apply the rule to see if the file type is allowed in the collection.
590
 
                                isAllowed = ( collectionPolicy.Apply( fullPath ) == Rule.Result.Allow );
591
 
                        }
592
 
                        return isAllowed;
593
 
                }
594
 
                #endregion
595
 
        }
596
 
}