Пример #1
0
        /// <summary>
        /// Initialize a new instance of <see cref="ComputeQueryOption"/> based on the raw $compute value and
        /// an EdmModel from <see cref="ODataQueryContext"/>.
        /// </summary>
        /// <param name="rawValue"></param>
        /// <param name="context"></param>
        /// <param name="queryOptionParser"></param>
        public ComputeQueryOption(string rawValue, ODataQueryContext context, ODataQueryOptionParser queryOptionParser)
        {
            if (context == null)
            {
                throw Error.ArgumentNull("context");
            }

            if (String.IsNullOrEmpty(rawValue))
            {
                throw Error.ArgumentNullOrEmpty("rawValue");
            }

            if (queryOptionParser == null)
            {
                throw Error.ArgumentNull("queryOptionParser");
            }

            Context            = context;
            RawValue           = rawValue;
            Validator          = ComputeQueryValidator.GetComputeQueryValidator(context);
            _queryOptionParser = queryOptionParser;

            // The IWebApiAssembliesResolver service is internal and can only be injected by WebApi.
            // This code path may be used in cases when the service container is not available
            // and the service container is available but may not contain an instance of IWebApiAssembliesResolver.
            _assembliesResolver = Context.RequestContainer?.GetService <IWebApiAssembliesResolver>() ?? WebApiAssembliesResolver.Default;
        }
Пример #2
0
        // This constructor is intended for unit testing only.
        internal ComputeQueryOption(string rawValue, ODataQueryContext context)
        {
            if (context == null)
            {
                throw Error.ArgumentNull("context");
            }

            if (String.IsNullOrEmpty(rawValue))
            {
                throw Error.ArgumentNullOrEmpty("rawValue");
            }

            Context            = context;
            RawValue           = rawValue;
            Validator          = ComputeQueryValidator.GetComputeQueryValidator(context);
            _queryOptionParser = new ODataQueryOptionParser(
                context.Model,
                context.ElementType,
                context.NavigationSource,
                new Dictionary <string, string> {
                { "$compute", rawValue }
            });
        }