/// <summary> /// Process the permissions by the IEdmModel. /// </summary> /// <param name="model">The Edm Model.</param> public void Process(IEdmModel model) { IDictionary <UriPath, IList <ApiPermissionType> > processed = new Dictionary <UriPath, IList <ApiPermissionType> >(new UriPathEqualityComparer()); PathParserSettings settings = new PathParserSettings { EnableCaseInsensitive = true }; foreach (var permission in ApiPermissions) { // Do Uri parser & save the invalid Uri into dictionary UriPath path; try { path = PathParser.ParsePath(permission.Key, model, settings); } catch (Exception innerEx) { UriParserError[permission.Key] = innerEx; path = null; } if (path == null) { continue; } if (processed.TryGetValue(path, out IList <ApiPermissionType> value)) { MergePermissions(value, permission.Value); MergedRequests.Add(permission.Key); } else { processed[path] = permission.Value; } } int index = 0; // for each property, navigation property segment foreach (var item in processed) { index++; PathSegment lastSegment = item.Key.LastSegment; if (lastSegment.Kind == SegmentKind.Property || lastSegment.Kind == SegmentKind.Navigation) { // only process the property TryFindPreviousPath(item, processed); } } ApiPermissionsProcessed = processed; }
public void ProcessByEdmModel(IEdmModel model, PathParserSettings settings) { RequestPath = null; try { RequestPath = PathParser.ParsePath(RequestUri, model, settings); } catch (Exception innerEx) { PaserError = innerEx.Message; RequestPath = null; } }