private static PermissionType ConvertFromPerm(string name, IList <string> scopes, IDictionary <string, HashSet <string> > restricted) { if (scopes == null || scopes.Count == 0) { return(null); } if (scopes.Count == 1 && scopes[0] == "Not supported.") { return(null); } PermissionType p = new PermissionType { SchemeName = name }; Func <string, IDictionary <string, HashSet <string> >, string> func = (sc, res) => { if (res.TryGetValue(sc, out HashSet <string> value)) { if (value.Count > 0) { return(String.Join(",", value.Select(b => "-" + b))); } } // Possible string value identifiers when specifying properties are '*', _PropertyName_, '-'_PropertyName_. // Where, '*' denotes all properties are accessible,'-'_PropertyName_ excludes that specific property and // _PropertyName_ explicitly provides access to the specific property. // The absence of 'RestrictedProperties' denotes all properties are accessible using that scope. return("*"); }; p.Scopes = scopes.Select(s => new ScopeType { Scope = s.Trim(), RestrictedProperties = func(s, restricted) }).ToList(); return(p); }
private static PermissionType ConvertFromPerm(string name, IList <string> scopes, IDictionary <string, HashSet <string> > restricted) { if (scopes == null || scopes.Count == 0) { return(null); } if (scopes.Count == 1 && scopes[0] == "Not supported.") { return(null); } PermissionType p = new PermissionType { SchemeName = name }; Func <string, IDictionary <string, HashSet <string> >, string> func = (sc, res) => { if (res.TryGetValue(sc, out HashSet <string> value)) { if (value.Count > 0) { return(String.Join(",", value)); } } return(null); }; p.Scopes = scopes.Select(s => new ScopeType { Scope = s.Trim(), RestrictedProperties = func(s, restricted) }).ToList(); return(p); }