Ejemplo n.º 1
0
        public override LambdaExpression VisitAttrPath(ScimFilterParser.AttrPathContext context)
        {
            string schemaToken = GetSchema(context);

            if (!string.IsNullOrEmpty(schemaToken) && ServerConfiguration.ResourceExtensionExists(schemaToken))
            {
                return(VisitResourceExtensionAttrPath(context));
            }

            if (!string.IsNullOrEmpty(schemaToken)) // fully qualified property
            {
                string schemaIdentifierForResourceType = ServerConfiguration.GetSchemaIdentifierForResourceType(typeof(TResource));
                // swallow correct namespace but validate

                if (!string.Equals(schemaToken, schemaIdentifierForResourceType, StringComparison.OrdinalIgnoreCase))
                {
                    throw new Exception("unrecognized schema"); // TODO: (MR) make proper error
                }
            }

            string       propNameToken = context.ATTRNAME(0).GetText();
            var          argument      = Expression.Parameter(typeof(TResource));
            PropertyInfo propertyInfo  = GetPropertyInfoFromCache(typeof(TResource), propNameToken);

            return(Expression.Lambda(Expression.Property(argument, propertyInfo), argument));
        }