예제 #1
0
        private RoleEntry Clone(ICollection <string> parameters, bool performValidation, string newName = null)
        {
            RoleEntry roleEntry;

            if (this is CmdletRoleEntry)
            {
                roleEntry = new CmdletRoleEntry((CmdletRoleEntry)this, newName);
            }
            else if (this is ScriptRoleEntry)
            {
                roleEntry = new ScriptRoleEntry();
            }
            else if (this is ApplicationPermissionRoleEntry)
            {
                roleEntry = new ApplicationPermissionRoleEntry();
            }
            else if (this is WebServiceRoleEntry)
            {
                roleEntry = new WebServiceRoleEntry();
            }
            else
            {
                roleEntry = new UnknownRoleEntry();
            }
            if (string.IsNullOrWhiteSpace(newName))
            {
                roleEntry.name = this.Name;
            }
            else
            {
                roleEntry.name = newName;
            }
            roleEntry.SetParameters(parameters, performValidation);
            return(roleEntry);
        }
예제 #2
0
        public static RoleEntry Parse(string input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (input.Length < 3)
            {
                throw new FormatException(DataStrings.RoleEntryNameTooShort);
            }
            if (input[1] != ',')
            {
                throw new FormatException(DataStrings.RoleEntryStringMustBeCommaSeparated);
            }
            RoleEntry roleEntry = null;

            if (RoleEntry.roleEntryCache.TryGetValue(input, out roleEntry))
            {
                return(roleEntry);
            }
            char c = input[0];

            switch (c)
            {
            case 'a':
                roleEntry = new ApplicationPermissionRoleEntry(input);
                goto IL_A9;

            case 'b':
                break;

            case 'c':
                roleEntry = new CmdletRoleEntry(input);
                goto IL_A9;

            default:
                if (c == 's')
                {
                    roleEntry = new ScriptRoleEntry(input);
                    goto IL_A9;
                }
                if (c == 'w')
                {
                    roleEntry = new WebServiceRoleEntry(input);
                    goto IL_A9;
                }
                break;
            }
            roleEntry = new UnknownRoleEntry(input);
IL_A9:
            RoleEntry.roleEntryCache.Add(input, roleEntry);
            return(roleEntry);
        }