Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Security.Contracts.BusinessObjects;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Hive.Server.Core {
|
---|
8 | public class PermissionCollection : IEnumerable<Permission> {
|
---|
9 | public IList<Permission> perm = new List<Permission>();
|
---|
10 |
|
---|
11 | public PermissionCollection() {
|
---|
12 | }
|
---|
13 |
|
---|
14 | public IList<Permission> Permissions {
|
---|
15 | get { return perm; }
|
---|
16 | }
|
---|
17 |
|
---|
18 | /// <summary>
|
---|
19 | /// Gets the Permission identified by FQN type.
|
---|
20 | /// </summary>
|
---|
21 | /// <param name="permissionName">eg. 'HivePermissions.Jobmanagement.Create.Any'</param>
|
---|
22 | /// <returns></returns>
|
---|
23 | public Permission this[string permissionName] {
|
---|
24 | get {
|
---|
25 | foreach (Permission item in perm) {
|
---|
26 | if (item.Name == permissionName)
|
---|
27 | return item;
|
---|
28 | }
|
---|
29 | return null;
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | /// <summary>
|
---|
34 | /// Converts an enumeration to a fully qualified string.
|
---|
35 | /// </summary>
|
---|
36 | /// <param name="obj">Any enumeration type.</param>
|
---|
37 | /// <returns>Type Information in Full Qualified Notation (FQN).</returns>
|
---|
38 | public string Convert(object obj) {
|
---|
39 | string retVal = string.Empty;
|
---|
40 | Type t = obj.GetType();
|
---|
41 | string value = obj.ToString();
|
---|
42 | retVal = (t.FullName.Replace(t.Namespace + ".", "")).Replace("+", ".") + "." + value;
|
---|
43 | return retVal;
|
---|
44 | }
|
---|
45 |
|
---|
46 | public IEnumerator<Permission> GetEnumerator() {
|
---|
47 | return perm.GetEnumerator();
|
---|
48 | }
|
---|
49 |
|
---|
50 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
|
---|
51 | return perm.GetEnumerator();
|
---|
52 | }
|
---|
53 |
|
---|
54 | }
|
---|
55 |
|
---|
56 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.