Beispiel #1
0
        internal BinaryResource(BinarySelector <T> binarySelectorSelector)
        {
            Name             = typeof(T).RESTarTypeName() ?? throw new Exception();
            Type             = typeof(T);
            AvailableMethods = new[] { Method.GET };
            var attribute = typeof(T).GetCustomAttribute <RESTarAttribute>();

            IsInternal                = attribute is RESTarInternalAttribute;
            InterfaceType             = typeof(T).GetRESTarInterfaceType();
            ResourceKind              = ResourceKind.BinaryResource;
            (_, ConditionBindingRule) = typeof(T).GetDynamicConditionHandling(attribute);
            Description               = attribute.Description;
            BinarySelector            = binarySelectorSelector;
            Members           = typeof(T).GetDeclaredProperties();
            GETAvailableToAll = attribute.GETAvailableToAll;
            var typeName = typeof(T).FullName;

            if (typeName?.Contains('+') == true)
            {
                IsInnerResource = true;
                var location = typeName.LastIndexOf('+');
                ParentResourceName = typeName.Substring(0, location).Replace('+', '.');
                Name = typeName.Replace('+', '.');
            }
        }
Beispiel #2
0
        public static DefinableFxBinaryOperator EvaluateOperator(
            this BinarySelector operatorSelector)
        {
            var res = operatorSelector.Invoke(BinaryArgument, BinaryArgument);

            return(res);
        }
Beispiel #3
0
 public static Func <Flexpression, Flexpression, Flexpression> GetOperatorDefinitionOrNull(
     this IReadOnlyDictionary <DefinableFxBinaryOperator, Func <Flexpression, Flexpression, Flexpression> > source,
     BinarySelector operatorSelector)
 {
     return(source.TryGetValue(operatorSelector.EvaluateOperator(), out var value) ? value : null);
 }