Ejemplo n.º 1
0
 public Rule AddRule(string name = "*", string parameter = null, string @class = null, string id = null) {
     Rule result;
     _rules.Insert(0, result = new Rule(this) {
         Name = name,
         Parameter = parameter,
         Class = @class,
         Id = id,
     });
     return result;
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     PropertyRule object must be created by the Rule.
 /// </summary>
 /// <param name="parent"> </param>
 /// <param name="name"> </param>
 internal StandardPropertyRule(Rule parent, string name) : base(parent, name) {
 }
Ejemplo n.º 3
0
 protected PropertyRule(Rule parent, string name) {
     ParentRule = parent;
     Name = name;
 }
Ejemplo n.º 4
0
        public VHDDriveInfo(Rule aliasRule, ProviderInfo providerInfo, PSCredential psCredential = null)
            : this(GetDriveInfo(aliasRule, providerInfo, psCredential))
        {
            // continues where the GetDriveInfo left off.

            /*
            Path = new Path {
                HostAndPort = aliasRule.HasProperty("key") ? aliasRule["key"].Value : aliasRule.Parameter,
                Container = aliasRule.HasProperty("container") ? aliasRule["container"].Value : "",
                SubPath = aliasRule.HasProperty("root") ? aliasRule["root"].Value.Replace('/', '\\').Replace("\\\\", "\\").Trim('\\') : "",
            };
            Path.Validate();
            Secret = aliasRule.HasProperty("secret") ? aliasRule["secret"].Value : psCredential != null ? psCredential.Password.ToUnsecureString() : null;
             * */
            // Path.Validate();
            // Secret = aliasRule.HasProperty("secret") ? aliasRule["secret"].Value : psCredential != null ? psCredential.Password.ToUnsecureString() : null;
        }
Ejemplo n.º 5
0
        private static PSDriveInfo GetDriveInfo(Rule aliasRule, ProviderInfo providerInfo, PSCredential psCredential)
        {
            throw new PSNotImplementedException();
            var name = aliasRule.Parameter;
            var account = aliasRule.HasProperty("key") ? aliasRule["key"].Value : name;
            var container = aliasRule.HasProperty("container") ? aliasRule["container"].Value : "";

            if(psCredential == null || (psCredential.UserName == null && psCredential.Password == null)) {
                psCredential = new PSCredential(account, aliasRule.HasProperty("secret") ? aliasRule["secret"].Value.ToSecureString() : null);
            }

            if (string.IsNullOrEmpty(container)) {
                return new PSDriveInfo(name, providerInfo, @"{0}:\{1}\".format(ProviderScheme, account), ProviderDescription, psCredential);
            }

            var root = aliasRule.HasProperty("root") ? aliasRule["root"].Value.Replace('/', '\\').Replace("\\\\", "\\").Trim('\\') : "";

            if (string.IsNullOrEmpty(root)) {
                return new PSDriveInfo(name, providerInfo, @"{0}:\{1}\{2}\".format(ProviderScheme, account, container), ProviderDescription, psCredential);
            }

            return new PSDriveInfo(name, providerInfo, @"{0}:\{1}\{2}\{3}\".format(ProviderScheme, account, container, root), ProviderDescription, psCredential);
        }
Ejemplo n.º 6
0
 internal ScriptedPropertyRule(Rule parent, string name, string scriptType, string scriptText, string sourceText)
     : base(parent, name)
 {
     ScriptType = scriptType;
     ScriptText = scriptText;
 }
Ejemplo n.º 7
0
 public void RemoveRule(Rule rule) {
     _rules.Remove(rule);
 }
        private void SetRolesToUser(Rule user, IEnumerable<string> roles)
        {
            var rolesVal = GetRolesPV(user);

                SetPropertyValues(rolesVal, roles.Select(s => s.ToLowerInvariant()).ToArray());
        }
        private void RemoveRolesFromUser(Rule user, IEnumerable<string> roles)
        {
            var rolesRule = user.GetPropertyRule("roles");
                var rolesVal = rolesRule.GetPropertyValue(string.Empty);

                var origRoles = rolesVal.Values.ToList();
                SetPropertyValues( rolesVal, origRoles.Except(roles.Select(s => s.ToLowerInvariant())).ToArray());
        }
 private PropertyValue GetRolesPV(Rule user)
 {
     var rolesRule = user.GetPropertyRule("roles");
         return rolesRule.GetPropertyValue(string.Empty);
 }