public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
            {
                var changeSetPreparer      = new TestChangeSetInitializer();
                var submitExecutor         = new TestSubmitExecutor();
                var queryExpressionSourcer = new TestQueryExpressionSourcer();

                ApiBase.ConfigureApi(apiType, services);
                services.AddService <IChangeSetInitializer>((sp, next) => changeSetPreparer);
                services.AddService <ISubmitExecutor>((sp, next) => submitExecutor);
                services.AddService <IQueryExpressionSourcer>((sp, next) => queryExpressionSourcer);

                var service = new TestSingleCallModelBuilder();

                services.AddService <IModelBuilder>((sp, next) => service);
                return(services);
            }
        public RestierQueryBuilder(ApiBase api, ODataPath path)
        {
            Ensure.NotNull(api, "api");
            Ensure.NotNull(path, "path");
            this.api  = api;
            this.path = path;

            this.handlers[ODataSegmentKinds.EntitySet]       = this.HandleEntitySetPathSegment;
            this.handlers[ODataSegmentKinds.Singleton]       = this.HandleSingletonPathSegment;
            this.handlers[ODataSegmentKinds.UnboundFunction] = this.HandleUnboundFunctionPathSegment;
            this.handlers[ODataSegmentKinds.Count]           = this.HandleCountPathSegment;
            this.handlers[ODataSegmentKinds.Value]           = this.HandleValuePathSegment;
            this.handlers[ODataSegmentKinds.Key]             = this.HandleKeyValuePathSegment;
            this.handlers[ODataSegmentKinds.Navigation]      = this.HandleNavigationPathSegment;
            this.handlers[ODataSegmentKinds.Property]        = this.HandlePropertyAccessPathSegment;
        }
Beispiel #3
0
        public static Type GetClrType(this IEdmType edmType, ApiBase api)
        {
            IEdmModel edmModel = api.GetModelAsync().Result;

            ClrTypeAnnotation annotation = edmModel.GetAnnotationValue <ClrTypeAnnotation>(edmType);

            if (annotation != null)
            {
                return(annotation.ClrType);
            }

            throw new NotSupportedException(string.Format(
                                                CultureInfo.InvariantCulture,
                                                Resources.ElementTypeNotFound,
                                                edmType.FullTypeName()));
        }
Beispiel #4
0
            public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
            {
                ApiBase.ConfigureApi(apiType, services);
                services.MakeTransient <ISomeService>()
                .AddService <ISomeService>((sp, next) => new SomeService
                {
                    Value = 2
                })
                .AddSingleton(new SomeService
                {
                    Value = 0
                })
                .AddService <ISomeService, SomeService4>();

                return(services);
            }
        protected ApiResultWithMoreResultIndicator <T> GetApiResultFromQuery <T, T2>(ApiBase apiSvc, string query, int?page = null, int?expectedResultsPerPage = null) where T2 : class, IServiceResult <T>
        {
            if (string.IsNullOrWhiteSpace(query))
            {
                throw new ArgumentException("Error: Cannot retrieve results due to an invalid or empty query");
            }

            try
            {
                //update query
                if (page != null && expectedResultsPerPage != null)
                {
                    query = AppendOffsetToProPublicaQuery(query, (int)page, (int)expectedResultsPerPage);
                }

                //var votesResults = GetMemberResults<DomainModel.ApiModels.ProPublica.VotesResult.Rootobject>(query, _congressApiSvc).Result;
                var votesResults = GetMemberResults <T2>(query, apiSvc).Result;
                var results      = (votesResults as IServiceResult <T>).GetResults();

                var isThereMoreResults = true;

                if (expectedResultsPerPage == null)
                {
                    isThereMoreResults = false;
                }
                else if (results.Count < (int)expectedResultsPerPage)
                {
                    isThereMoreResults = false;
                }
                else
                {
                    isThereMoreResults = true;
                }


                var apiResults = new ApiResultWithMoreResultIndicator <T>(results, isThereMoreResults);

                return(apiResults);
            }
            catch (Exception ex)
            {
                _logger.Error($"Error: Could not retrieve Bills from query {query}", ex);
            }

            return(null);
        }
            public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
            {
                var changeSetPreparer = new TestChangeSetInitializer();
                var submitExecutor    = new TestSubmitExecutor();

                ApiBase.ConfigureApi(apiType, services);
                services.AddService <IChangeSetInitializer>((sp, next) => changeSetPreparer);
                services.AddService <ISubmitExecutor>((sp, next) => submitExecutor);
                services.AddService <ISomeService>((sp, next) => new SomeService
                {
                    Inner = next,
                    Value = 1
                })
                .AddService <ISomeService, SomeServiceNoChain>()
                .MakeTransient <ISomeService>();
                return(services);
            }
Beispiel #7
0
        private void FormReportesDeOrdenes_Load(object sender, EventArgs e)
        {
            ApiBase       inicioApi = new ApiBase();
            IRestResponse respuesta = inicioApi.execApi(urlmesa, mesas);

            listaOrdenes = JsonConvert.DeserializeObject <List <Model.ReporteOrdenesModel> >(respuesta.Content);

            for (int n = 0; n < listaOrdenes.Count; n++)
            {
                String[] arr = { listaOrdenes[n].id_orden,
                                 listaOrdenes[n].fecha_hora,
                                 listaOrdenes[n].total,
                                 listaOrdenes[n].nombre,
                                 listaOrdenes[n].numero,
                                 listaOrdenes[n].estado };
                dgvReportesDeOrdenes.Rows.Add(arr);
            }
        }
        private void FormReportesDeProductos_Load(object sender, EventArgs e)
        {
            ApiBase       inicioApi = new ApiBase();
            IRestResponse respuesta = inicioApi.execApi(urlproductos, productos);

            listaProductos = JsonConvert.DeserializeObject <List <Model.ReportesProductosModel> >(respuesta.Content);

            for (int n = 0; n < listaProductos.Count; n++)
            {
                String[] arr = { listaProductos[n].id_producto,
                                 listaProductos[n].descripcion,
                                 listaProductos[n].precio,
                                 listaProductos[n].cantidad,
                                 listaProductos[n].id_categoria,
                                 listaProductos[n].activo };
                dgvReportesDeProductos.Rows.Add(arr);
            }
        }
        /// <summary>
        /// Gets the serializer for the given result type.
        /// The proxy provider will get the real provider to return the serializer.
        /// </summary>
        /// <param name="model">The EDM model.</param>
        /// <param name="type">The type of result to serialize.</param>
        /// <param name="request">The HTTP request.</param>
        /// <returns>The serializer instance.</returns>
        public override ODataSerializer GetODataPayloadSerializer(
            IEdmModel model,
            Type type,
            HttpRequestMessage request)
        {
            this.api = request.GetApiInstance();

            if (this.api != null)
            {
                ODataSerializerProvider provider = api.Context.GetApiService <ODataSerializerProvider>();
                if (provider != null)
                {
                    return(provider.GetODataPayloadSerializer(model, type, request));
                }
            }

            // In case user uses his own controller or NonFound error for request
            return(DefaultRestierSerializerProvider.SingletonInstance.GetODataPayloadSerializer(model, type, request));
        }
Beispiel #10
0
        private void FormReportesDeVentasTotales_Load(object sender, EventArgs e)
        {
            ApiBase       inicioApi = new ApiBase();
            IRestResponse respuesta = inicioApi.execApi(urlventas, ventas);

            listaventas = JsonConvert.DeserializeObject <List <Model.ReportesDeVentasTotalesModel> >(respuesta.Content);

            for (int n = 0; n < listaventas.Count; n++)
            {
                Console.WriteLine("Ventas ejecuntandoce");
                //String[] arr = { listaventas[n].id_producto,
                //                                listaventas[n].descripcion,
                //                                listaventas[n].precio,
                //                                listaventas[n].cantidad,
                //                                listaventas[n].id_categoria,
                //                                listaventas[n].activo };
                //dgvReportesDeVentasTotales.Rows.Add(arr);
            }
        }
Beispiel #11
0
        private void btnculm_Click(object sender, EventArgs e)
        {
            ApiBase    api   = new ApiBase();
            OrdenModel orden = new OrdenModel();

            orden.id_orden = idorden;
            IRestResponse res = api.execApi(urlculminar, JsonConvert.SerializeObject(orden));
            string        h   = JsonConvert.DeserializeObject <String>(res.Content);

            if (!string.IsNullOrEmpty(h))
            {
                this.OcupadO(h);
                this.Close();
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
Beispiel #12
0
        private void ShowResults <TArguments, TContainer>(ApiBase <TArguments, TContainer> api)
            where TArguments : ArgumentsBase, new()
            where TContainer : class
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Exception: " + api.Exception + Environment.NewLine);
            builder.Append("FetchMessage: " + api.FetchMessage + Environment.NewLine);
            builder.Append("URL: " + api.URL + Environment.NewLine);
            builder.Append("Arguments.Validators.Count: " + api.Arguments.Validators.Count.ToString() + Environment.NewLine);
            if (api.Arguments.ValidationErrors != null)
            {
                builder.Append("Arguments.ValidationErrors: ");
                foreach (string error in api.Arguments.ValidationErrors.Values)
                {
                    builder.Append("Error: " + error + Environment.NewLine);
                }
            }
            MessageBox.Show(builder.ToString());
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddCommandLine(args);

            IConfigurationRoot configuration = builder.Build();

            var a = new ApiBase(configuration);
            var z = a.Zones;

            foreach (var i in z)
            {
                if (i.Name == "mmkiwi.com")
                {
                    var rec = i.GetDnsRecords(a);
                }
            }
        }
        private static IEdmModel GetModel(ApiBase api)
        {
            // Here await is not used because if method MapRestierRoute is mapped async,
            // Then during application starts, the http service initialization may complete first
            // before this method call is complete.
            // Then all request will fail, and this happen for some test cases before when get model takes long time.
            IEdmModel model;

            try
            {
                model = api.GetModelAsync().Result;
            }
            catch (AggregateException e)
            {
                // Without await, the exception is wrapped and inner exception has more meaningful message.
                throw e.InnerException;
            }

            return(model);
        }
        public RestierQueryBuilder(ApiBase api, ODataPath path)
        {
            Ensure.NotNull(api, "api");
            Ensure.NotNull(path, "path");
            this.api  = api;
            this.path = path;

            this.handlers[typeof(EntitySetSegment)]          = this.HandleEntitySetPathSegment;
            this.handlers[typeof(SingletonSegment)]          = this.HandleSingletonPathSegment;
            this.handlers[typeof(OperationSegment)]          = this.EmptyHandler;
            this.handlers[typeof(OperationImportSegment)]    = this.EmptyHandler;
            this.handlers[typeof(CountSegment)]              = this.HandleCountPathSegment;
            this.handlers[typeof(ValueSegment)]              = this.HandleValuePathSegment;
            this.handlers[typeof(KeySegment)]                = this.HandleKeyValuePathSegment;
            this.handlers[typeof(NavigationPropertySegment)] = this.HandleNavigationPathSegment;
            this.handlers[typeof(PropertySegment)]           = this.HandlePropertyAccessPathSegment;
            this.handlers[typeof(TypeSegment)]               = this.HandleEntityTypeSegment;

            // Complex cast is not supported by EF, and is not supported here
            // this.handlers[ODataSegmentKinds.ComplexCast] = null;
        }
Beispiel #16
0
        /// <summary>
        /// Send a request to get cipher keys from an user
        /// </summary>
        /// <param name="number">Phone number of the user you want to get the cipher keys</param>
        /// <param name="replaceKey"></param>
        public void sendGetCipherKeysFromUser(string number, bool replaceKeyIn = false)
        {
            replaceKey = replaceKeyIn;
            var msgId = TicketManager.GenerateId();

            cipherKeys.Add(msgId);

            ProtocolTreeNode user = new ProtocolTreeNode("user", new[] {
                new KeyValue("jid", ApiBase.GetJID(number)),
            }, null, null);

            ProtocolTreeNode keyNode = new ProtocolTreeNode("key", null, new ProtocolTreeNode[] { user }, null);
            ProtocolTreeNode Node    = new ProtocolTreeNode("iq", new[] {
                new KeyValue("id", msgId),
                new KeyValue("xmlns", "encrypt"),
                new KeyValue("type", "get"),
                new KeyValue("to", "s.whatsapp.net")
            }, new ProtocolTreeNode[] { keyNode }, null);

            this.SendNode(Node);
        }
Beispiel #17
0
        public async Task VerifyMetadataPropertyType()
        {
            ApiBase.AddPublisherServices(typeof(PrimitivesApi), services =>
            {
                services.AddODataServices <PrimitivesApi>();
            });
            var container = new RestierContainerBuilder(typeof(PrimitivesApi));
            var provider  = container.BuildContainer();
            var api       = provider.GetService <ApiBase>();
            var edmModel  = await api.GetModelAsync();

            var entityType = (IEdmEntityType)
                             edmModel.FindDeclaredType(@"Microsoft.Restier.Providers.EntityFramework7.Tests.Models.Primitives.DateItem");

            Assert.NotNull(entityType);

            Assert.True(entityType.FindProperty("DTProperty").Type.IsDateTimeOffset());
            Assert.True(entityType.FindProperty("DateProperty").Type.IsDate());
            Assert.True(entityType.FindProperty("TODProperty").Type.IsTimeOfDay());
            Assert.True(entityType.FindProperty("TSProperty").Type.IsDuration());
        }
 /// <summary>
 /// Sets the color of the <see cref="Led"/> having the specified ID.
 /// The method throws a <see cref="ResourceNotFoundException"/> if the underlying <see cref="Led"/> does not exist.
 /// The method throws a <see cref="BadRequestException"/> if the passed ID is invalid.
 /// </summary>
 /// <param name="ledId">ID of the <see cref="Led"/> whose color should be changed</param>
 /// <param name="rbg">desired RGB value</param>
 public void SetColor(string ledId, string rgb)
 {
     string[] split = ledId.Split(':');
     if (split.Length != 2)
     {
         throw new BadRequestException(BadRequestException.MSG_INVALID_LED_ID);
     }
     else
     {
         int controllerId = ApiBase.ParseInt(split[0], BadRequestException.MSG_INVALID_LED_ID);
         int ledNumber    = ApiBase.ParseInt(split[1], BadRequestException.MSG_INVALID_LED_ID);
         if (_ledStorage.HasLed(controllerId, ledNumber))
         {
             _ledStorage.SetColor(controllerId, ledNumber, rgb);
         }
         else
         {
             throw new ResourceNotFoundException(ResourceNotFoundException.MSG_LED_NOT_FOUND.Replace("{VALUE}", ledId));
         }
     }
 }
Beispiel #19
0
            public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
            {
                var changeSetPreparer      = new TestChangeSetInitializer();
                var submitExecutor         = new TestSubmitExecutor();
                var queryExpressionSourcer = new TestQueryExpressionSourcer();

                ApiBase.ConfigureApi(apiType, services);
                services.AddService <IChangeSetInitializer>((sp, next) => changeSetPreparer);
                services.AddService <ISubmitExecutor>((sp, next) => submitExecutor);
                services.AddService <IQueryExpressionSourcer>((sp, next) => queryExpressionSourcer);
                var q1 = new ServiceB("q1Pre", "q1Post");
                var q2 = new ServiceB("q2Pre", "q2Post");

                services.AddService <IServiceB>((sp, next) => q1)
                .AddService <IServiceB>((sp, next) =>
                {
                    q2.InnerHandler = next;
                    return(q2);
                });

                return(services);
            }
Beispiel #20
0
        /// <summary>
        /// Creates a dictionary of changed property values.
        /// </summary>
        /// <param name="entity">The entity inside the delta.</param>
        /// <param name="edmType">The Edm Type.</param>
        /// <param name="api">The api.</param>
        /// <param name="isCreation">Whether this is entity creation or update.</param>
        /// <returns>A dictionary of changed property values.</returns>
        public static IReadOnlyDictionary <string, object> CreatePropertyDictionary(
            this Delta entity, IEdmStructuredType edmType, ApiBase api, bool isCreation)
        {
            var propertiesAttributes = RetrievePropertiesAttributes(edmType, api);

            var propertyValues = new Dictionary <string, object>();

            foreach (var propertyName in entity.GetChangedPropertyNames())
            {
                if (propertiesAttributes != null && propertiesAttributes.TryGetValue(propertyName, out var attributes))
                {
                    if ((isCreation && (attributes & PropertyAttributes.IgnoreForCreation) != PropertyAttributes.None) ||
                        (!isCreation && (attributes & PropertyAttributes.IgnoreForUpdate) != PropertyAttributes.None))
                    {
                        // Will not get the properties for update or creation
                        continue;
                    }
                }

                if (entity.TryGetPropertyValue(propertyName, out var value))
                {
                    if (value is EdmComplexObject complexObj)
                    {
                        value = CreatePropertyDictionary(complexObj, complexObj.ActualEdmType, api, isCreation);
                    }

                    // RWM: Other entities are not allowed in the payload until we support Delta payloads.
                    if (value is EdmEntityObject entityObj)
                    {
                        // TODO: RWM: Turn this message into a language resource.
                        throw new StatusCodeException(HttpStatusCode.BadRequest, "Navigation Properties were also present in the payload. Please remove related entities from your request and try again.");
                    }

                    propertyValues.Add(propertyName, value);
                }
            }

            return(propertyValues);
        }
Beispiel #21
0
        public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
        {
            Func <IServiceProvider, IDataStoreManager <string, TripPinDataSource> > defaultDataStoreManager =
                sp => new DefaultDataStoreManager <string, TripPinDataSource>()
            {
                MaxDataStoreInstanceCapacity = 1000,
                MaxDataStoreInstanceLifeTime = new TimeSpan(0, 30, 0)
            };

            Func <IServiceProvider, ODataValidationSettings> validationSettingFactory = sp => new ODataValidationSettings
            {
                MaxAnyAllExpressionDepth = 4,
                MaxExpansionDepth        = 4
            };

            services.AddSingleton <ODataValidationSettings>(validationSettingFactory);
            services.AddService <IModelBuilder>((sp, next) => new ModelBuilder());
            services.AddService <IChangeSetInitializer>((sp, next) => new ChangeSetInitializer <TripPinDataSource>());
            services.AddService <ISubmitExecutor>((sp, next) => new SubmitExecutor());
            services.AddSingleton(defaultDataStoreManager);
            return(ApiBase.ConfigureApi(apiType, services));
        }
            public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
            {
                var changeSetPreparer      = new TestChangeSetInitializer();
                var submitExecutor         = new TestSubmitExecutor();
                var queryExpressionSourcer = new TestQueryExpressionSourcer();

                ApiBase.ConfigureApi(apiType, services);
                services.AddService <IChangeSetInitializer>((sp, next) => changeSetPreparer);
                services.AddService <ISubmitExecutor>((sp, next) => submitExecutor);
                services.AddService <IQueryExpressionSourcer>((sp, next) => queryExpressionSourcer);

                var first = new SomeService
                {
                    Value = 42
                };

                services.MakeTransient <ISomeService>()
                .AddService <ISomeService>((sp, next) => first)
                .AddService <ISomeService, SomeService2>()
                .AddSingleton("Text");
                return(services);
            }
        protected async Task <T> GetMemberResults <T>(string legislatorsUri, ApiBase apiSvc, Func <string, string> actionToPerformOnJsonOutput = null) where T : class
        {
            try
            {
                var client = apiSvc.CreateHttpClient();

                //TODO RM (Low Priority): Ensure this is async
                var response = client.GetAsync(legislatorsUri).Result;
                //var response = await client.GetAsync(legislatorsByZipUri); //TODO Find out why this fails
                //http://stackoverflow.com/questions/10343632/httpclient-getasync-never-returns-when-using-await-async


                if (response.IsSuccessStatusCode)
                {
                    //var responseText = await response.Content.ReadAsStringAsync();
                    var responseText = response.Content.ReadAsStringAsync().Result;

                    if (actionToPerformOnJsonOutput != null)
                    {
                        responseText = actionToPerformOnJsonOutput(responseText);
                    }

                    var results = JsonConvert.DeserializeObject <T>(responseText);

                    return(results);
                }
                else
                {
                    _logger.Error($"Error occurred retrieving legislators using URI: {legislatorsUri}");
                }
            }
            catch (Exception e)
            {
                _logger.Error("Error retrieving legislators.", e);
            }

            return(null);
        }
Beispiel #24
0
        public RestierQueryBuilder(ApiBase api, ODataPath path)
        {
            Ensure.NotNull(api, "api");
            Ensure.NotNull(path, "path");
            this.api  = api;
            this.path = path;

            this.handlers[ODataSegmentKinds.EntitySet]       = this.HandleEntitySetPathSegment;
            this.handlers[ODataSegmentKinds.Singleton]       = this.HandleSingletonPathSegment;
            this.handlers[ODataSegmentKinds.UnboundFunction] = this.EmptyHandler;
            this.handlers[ODataSegmentKinds.Function]        = this.EmptyHandler;
            this.handlers[ODataSegmentKinds.Action]          = this.EmptyHandler;
            this.handlers[ODataSegmentKinds.UnboundAction]   = this.EmptyHandler;
            this.handlers[ODataSegmentKinds.Count]           = this.HandleCountPathSegment;
            this.handlers[ODataSegmentKinds.Value]           = this.HandleValuePathSegment;
            this.handlers[ODataSegmentKinds.Key]             = this.HandleKeyValuePathSegment;
            this.handlers[ODataSegmentKinds.Navigation]      = this.HandleNavigationPathSegment;
            this.handlers[ODataSegmentKinds.Property]        = this.HandlePropertyAccessPathSegment;
            this.handlers[ODataSegmentKinds.Cast]            = this.HandleCastPathSegment;

            // Complex cast is not supported by EF, and is not supported here
            // this.handlers[ODataSegmentKinds.ComplexCast] = null;
        }
            public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
            {
                var changeSetPreparer      = new TestChangeSetInitializer();
                var submitExecutor         = new TestSubmitExecutor();
                var queryExpressionSourcer = new TestQueryExpressionSourcer();

                ApiBase.ConfigureApi(apiType, services);
                services.AddService <IChangeSetInitializer>((sp, next) => changeSetPreparer);
                services.AddService <ISubmitExecutor>((sp, next) => submitExecutor);
                services.AddService <IQueryExpressionSourcer>((sp, next) => queryExpressionSourcer);

                services.AddService <IModelBuilder>((sp, next) => new TestModelProducer());
                services.AddService <IModelBuilder>((sp, next) => new TestModelExtender(2)
                {
                    InnerHandler = next,
                });
                services.AddService <IModelBuilder>((sp, next) => new TestModelExtender(3)
                {
                    InnerHandler = next,
                });

                return(services);
            }
Beispiel #26
0
        /// <summary>
        /// Initializes the <see cref="ApiController"/> instance with the specified controllerContext.
        /// </summary>
        /// <remarks>
        /// Resolves the api, query settings, validation settings, operation executor from
        /// the Request container associated with the HttpRequestMessage.
        /// </remarks>
        /// <param name="controllerContext">
        /// The <see cref="HttpControllerContext"/> object that is used for the initialization.
        /// </param>
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);

            if (api != null && querySettings != null && validationSettings != null && operationExecutor != null)
            {
                return;
            }

            // TODO: JWS Either properly inject RestierController into the DI Container.
            // or provide sensible defaults for these dependencies to reduce DI dependency.
#pragma warning disable CA1062 // Validate arguments of public methods
            var provider = controllerContext.Request.GetRequestContainer();
#pragma warning restore CA1062 // Validate arguments of public methods


            if (api == null)
            {
                //var registrations = provider.GetService(typeof(RestierApiRouteDictionary)) as RestierApiRouteDictionary;
                //var apiType = registrations[(((controllerContext.RouteData as HttpRouteData).Route as ODataRoute).RouteConstraint as ODataPathRouteConstraint).RouteName].ApiType;
                //api = provider.GetService(apiType) as ApiBase;
                api = provider.GetService(typeof(ApiBase)) as ApiBase;
            }
            if (querySettings == null)
            {
                querySettings = provider.GetService(typeof(ODataQuerySettings)) as ODataQuerySettings;
            }
            if (validationSettings == null)
            {
                validationSettings = provider.GetService(typeof(ODataValidationSettings)) as ODataValidationSettings;
            }
            if (operationExecutor == null)
            {
                operationExecutor = provider.GetService(typeof(IOperationExecutor)) as IOperationExecutor;
            }
        }
Beispiel #27
0
 public void ThrowsErrorOnNotFound()
 {
     Assert.Throws <ArgumentException>(() => ApiBase.DownloadJsonString("https://api.guildwars2.com/v2/buildmeh"));
 }
Beispiel #28
0
        public void ShouldReturnCorrectJsonString()
        {
            string actual = ApiBase.DownloadJsonString("https://api.guildwars2.com/v2/build");

            Assert.That(actual.Contains("id"));
        }
Beispiel #29
0
 /// <summary>
 /// Creates the <see cref="RestierBatchChangeSetRequestItem"/> instance.
 /// </summary>
 /// <param name="api">A reference to the Api.</param>
 /// <param name="changeSetContexts">The list of changeset contexts.</param>
 /// <returns>The created <see cref="RestierBatchChangeSetRequestItem"/> instance.</returns>
 protected virtual RestierBatchChangeSetRequestItem CreateRestierBatchChangeSetRequestItem(ApiBase api, IList <HttpContext> changeSetContexts)
 => new RestierBatchChangeSetRequestItem(api, changeSetContexts);
Beispiel #30
0
        /// <summary>
        /// 取得InvocieApi代理
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model">Model參數</param>
        /// <returns></returns>
        public ApiBase <T> GetProxyInstace <T>(T model, object[] args = null) where T : class, new()
        {
            ApiBase <T> realSubject = GetInstace(model, args) as ApiBase <T>;

            return(ProxyFactory.GetProxyInstance(realSubject));
        }
Beispiel #31
0
 public Service(ApiBase api, ApiContext context)
 {
     Api = api;
     Context = context;
 }