private static PermissionScopeData GetScopeData(IEdmRecordExpression scopeRecord)
        {
            var scopeProperty = scopeRecord.FindProperty("Scope")?.Value as IEdmStringConstantExpression;
            var restrictedPropertiesProperty = scopeRecord.FindProperty("RestrictedProperties")?.Value as IEdmStringConstantExpression;

            return(new PermissionScopeData()
            {
                Scope = scopeProperty?.Value, RestrictedProperties = restrictedPropertiesProperty?.Value
            });
        }
        private static PermissionData GetPermissionData(IEdmRecordExpression permissionRecord)
        {
            var schemeProperty = permissionRecord.FindProperty("SchemeName")?.Value as IEdmStringConstantExpression;
            var scopesProperty = permissionRecord.FindProperty("Scopes")?.Value as IEdmCollectionExpression;

            var scopes = scopesProperty?.Elements.Select(s => GetScopeData(s as IEdmRecordExpression)) ?? Enumerable.Empty <PermissionScopeData>();

            return(new PermissionData()
            {
                SchemeName = schemeProperty?.Value, Scopes = scopes.ToList()
            });
        }
예제 #3
0
        /// <summary>
        /// Init the <see cref="ResourceExampleValue"/>
        /// </summary>
        /// <param name="record">The input record.</param>
        public override void Initialize(IEdmRecordExpression record)
        {
            // Load ExampleValue
            base.Initialize(record);

            // Value of PrimitiveExampleValue
            IEdmPropertyConstructor property = record.FindProperty("Value");

            if (property != null)
            {
                Value = property.Value.Convert() as ODataResourceValue;
            }
        }
        /// <summary>
        /// Init the <see cref="PrimitiveExampleValue"/>
        /// </summary>
        /// <param name="record">The input record.</param>
        public override void Initialize(IEdmRecordExpression record)
        {
            Utils.CheckArgumentNull(record, nameof(record));

            /* Should we throw exception if the input record is not a primitive example value?
             * Leave the below codes for further decision.
             * if (record.DeclaredType == null || record.DeclaredType.FullName() != "Org.OData.Core.V1.PrimitiveExampleValue")
             * {
             *  throw new OpenApiException();
             * }
             */

            // Load ExampleValue
            base.Initialize(record);

            // Value of PrimitiveExampleValue
            IEdmPropertyConstructor property = record.FindProperty("Value");

            if (property != null)
            {
                Value = property.Value.Convert() as ODataPrimitiveValue;
            }
        }
        private static IEnumerable <IScopesEvaluator> ExtractPermissionsFromRecord(IEdmRecordExpression record)
        {
            var permissionsProperty = record?.FindProperty("Permissions");

            return(ExtractPermissionsFromProperty(permissionsProperty));
        }