Esempio n. 1
0
        public EventfulService(IRestProxy proxy)
        {
            _proxy = proxy;

            _proxy.BaseUrl = "http://api.eventful.com/rest/events/search";
            _proxy.ApiKey  = new KeyValuePair <string, string>("app_key", "XqcX3pSvZbQMH8cj");
        }
Esempio n. 2
0
 public Client1(
     IRestProxy restProxy,
     string baseUri)
 {
     this.restProxy = restProxy;
     this.baseUri   = baseUri + "/api/v1.0/helloworld";
 }
Esempio n. 3
0
        public GoogleGeocodeService(IRestProxy proxy)
        {
            _proxy = proxy;

            _proxy.BaseUrl = "https://maps.googleapis.com/maps/api/geocode/xml";
            _proxy.ApiKey  = new KeyValuePair <string, string>("key", "AIzaSyD66orgqVtAbC1brokj4jEIIt0M_MXe6vc");
        }
Esempio n. 4
0
 protected TfsRestProxyBase(
     IRestProxy restProxy,
     ITfsSettingsProvider tfsSettingsProvider)
 {
     _restProxy   = restProxy;
     _tfsSettings = tfsSettingsProvider.ProvideTfsSettings();
 }
Esempio n. 5
0
 public Alcoholic(
     IRestProxy restProxy,
     string baseUri)
 {
     this.restProxy = restProxy;
     this.baseUri   = baseUri;
 }
Esempio n. 6
0
 public BuildRestProxy(
     IRestProxy restProxy,
     ITfsSettingsProvider tfsSettingsProvider,
     IJsonBuildChangeAdapter jsonBuildChangeAdapter) : base(restProxy, tfsSettingsProvider)
 {
     _jsonBuildChangeAdapter = jsonBuildChangeAdapter;
 }
Esempio n. 7
0
 public IndividualRestResourceService(
     IRestProxy restProxy,
     IRestCallBuilderFactory restCallBuilderFactory,
     IIndividualRestSettingsProvider individalRestSettingsProvider)
     : base(restProxy, restCallBuilderFactory, individalRestSettingsProvider)
 {
     _restProxy = restProxy;
 }
 public WorkItemRestProxy(
     IRestProxy restProxy,
     ITfsSettingsProvider tfsSettingsProvider,
     IJsonWorkItemAdapter jsonWorkItemAdapter)
     : base(restProxy, tfsSettingsProvider)
 {
     _jsonWorkItemAdapter = jsonWorkItemAdapter;
 }
 public WorkItemRepository(
     IRestProxy restProxy,
     IAppSettingsProvider settingsProvider,
     IAdapterResolver adapterResolver)
 {
     _restProxy       = restProxy;
     _adapterResolver = adapterResolver;
     _settings        = settingsProvider.ProvideSettings().AzureFunctionsSettings;
 }
Esempio n. 10
0
 public HomeController(
     IRestProxy restProxy,
     IRestCallBuilderFactory restCallBuilderFactory,
     ILogger <HomeController> logger)
 {
     _restProxy = restProxy;
     _restCallBuilderFactory = restCallBuilderFactory;
     _logger = logger;
 }
 public TranslationRequestSender(
     IDeeplSettingsProvider settingsProvider,
     IRestCallBuilderFactory restCallBuilderFactory,
     IRestProxy restProxy)
 {
     _settingsProvider       = settingsProvider;
     _restCallBuilderFactory = restCallBuilderFactory;
     _restProxy = restProxy;
 }
 protected RestResourceServiceBase(
     IRestProxy restProxy,
     IRestCallBuilderFactory restCallBuilderFactory,
     IRestSettingsProvider restSettingsProvider)
 {
     _restProxy = restProxy;
     _restCallBuilderFactory = restCallBuilderFactory;
     RestSettings            = restSettingsProvider.ProvideRestSettings();
 }
 public BuildChangeRepository(
     IRestProxy restProxy,
     IAdapterResolver adapterResolver,
     IAppSettingsProvider settingsProvider)
 {
     _restProxy                = restProxy;
     _adapterResolver          = adapterResolver;
     _buildChangesFunctionPath = settingsProvider.ProvideSettings().AzureFunctionsSettings.GetBuildChangesByBuildIdPath;
 }
Esempio n. 14
0
 public AuthorizationTokenFactory(
     IAuthorizationTokenCache tokenCache,
     ITranslationServiceSettingsProvider settingsProvider,
     IRestProxy restProxy)
 {
     _tokenCache       = tokenCache;
     _settingsProvider = settingsProvider;
     _restProxy        = restProxy;
 }
 public TranslationApiProxy(
     IRestProxy restProxy,
     ITranslationRestCallFactory restCallFactory,
     IMapper mapper,
     ITranslationResultAdapter translationResultAdapter)
 {
     _restProxy                = restProxy;
     _restCallFactory          = restCallFactory;
     _mapper                   = mapper;
     _translationResultAdapter = translationResultAdapter;
 }
Esempio n. 16
0
 public TextTranslationService(
     IRestProxy restProxy,
     IRestCallBuilderFactory restCallBuilderFactory,
     IStandaloneQueryParameterBuilderFactory queryParamBuilderFactory,
     ISettingsProvider settingsProvider,
     ITextTranslationResultAdapter resultAdapter)
 {
     _restProxy = restProxy;
     _restCallBuilderFactory   = restCallBuilderFactory;
     _queryParamBuilderFactory = queryParamBuilderFactory;
     _settingsProvider         = settingsProvider;
     _resultAdapter            = resultAdapter;
 }
Esempio n. 17
0
 public ProductClient(IRestProxy restProxy, string baseUri)
 {
     this.RestProxy = restProxy;
     this.BaseUri   = baseUri + "/api/multiply";
 }
 public ExternalCallAppService(IRestProxy restProxy)
 {
     _restProxy = restProxy;
 }
Esempio n. 19
0
        public void ProcessRequest(HttpContext context)
        {
            Type t = null;

            #region prepare the IAjaxProxy/IRestProxy type
            string   className = null;
            string   idPart    = null;
            string[] parts     = context.Request.Path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < parts.Length; i++)
            {
                if (parts[i].ToLower() == "ext4")
                {
                    if (i + 1 < parts.Length)
                    {
                        className = parts[i + 1];
                        if (i + 2 < parts.Length)
                        {
                            idPart = parts[i + 2];
                        }
                    }
                    break;
                }
            }
            if (className == null)
            {
                ResponseError(context, new Exception("Type not set."));
                return;
            }

            if (className.EndsWith(".ashx"))
            {
                className = className.Substring(0, className.Length - 5);
            }
            if (idPart != null && idPart.EndsWith(".ashx"))
            {
                idPart = idPart.Substring(0, idPart.Length - 5);
            }

            if (Utility.Settings != null && Utility.Settings.UrlClassMappings.ContainsKey(className))
            {
                className = Utility.Settings.UrlClassMappings[className] as string;
                if (context.Trace.IsEnabled)
                {
                    context.Trace.Write(Constant.AjaxID, "Url match to Type: " + className);
                }
            }

            try
            {
                t = Type.GetType(className, true);
            }
            catch (Exception ex)
            {
                if (context.Trace.IsEnabled)
                {
                    context.Trace.Write(Constant.AjaxID, "Type not found: " + className);
                }
                ResponseError(context, ex);
                return;
            }
            #endregion

            #region GET via IAjaxProxy
            if (context.Request.HttpMethod == "GET")
            {
                if (!typeof(IAjaxProxy).IsAssignableFrom(t))
                {
                    ResponseError(context, new Exception("The type is not a IAjaxProxy: " + className));
                    return;
                }

                try
                {
                    IAjaxProxy ajax = (IAjaxProxy)Activator.CreateInstance(t, new object[] { });

                    QueryParams paras = new QueryParams();
                    if (!string.IsNullOrEmpty(context.Request.Params["page"]))
                    {
                        paras.PageIndex = Convert.ToInt32(context.Request.Params["page"]) - 1;
                    }
                    if (!string.IsNullOrEmpty(context.Request.Params["start"]))
                    {
                        paras.Start = Convert.ToInt32(context.Request.Params["start"]);
                    }
                    if (!string.IsNullOrEmpty(context.Request.Params["limit"]))
                    {
                        paras.PageSize = Convert.ToInt32(context.Request.Params["limit"]);
                    }
                    paras.Id = context.Request.Params["id"];

                    if (!string.IsNullOrEmpty(context.Request.Params["sort"]))
                    {
                        ExtSortParam para = new ExtSortParam();
                        para.Sorts = (ExtSort[])JavaScriptDeserializer.DeserializeFromJson(
                            context.Request.Params["sort"],
                            typeof(ExtSort[]));
                        paras.Sort = para;
                    }
                    if (!string.IsNullOrEmpty(context.Request.Params["group"]))
                    {
                        ExtSortParam para = new ExtSortParam();
                        para.Sorts = (ExtSort[])JavaScriptDeserializer.DeserializeFromJson(
                            context.Request.Params["group"],
                            typeof(ExtSort[]));
                        paras.Group = para;
                    }
                    if (!string.IsNullOrEmpty(context.Request.Params["filter"]))
                    {
                        ExtFilterParam para = new ExtFilterParam();
                        para.Filters = (ExtFilter[])JavaScriptDeserializer.DeserializeFromJson(
                            context.Request.Params["filter"],
                            typeof(ExtFilter[]));
                        paras.Filter = para;
                    }
                    paras.Context = context;

                    ajax.Query(paras);

                    if (paras.RootDirect)
                    {
                        ResponseObject(context, paras.Results);
                    }
                    else
                    {
                        if (paras.Extra == null)
                        {
                            ResponseObject(context, new
                            {
                                success = true,
                                total   = paras.TotalRecords,
                                root    = paras.Results
                            });
                        }
                        else
                        {
                            ResponseObject(context, new
                            {
                                success = true,
                                total   = paras.TotalRecords,
                                root    = paras.Results,
                                extra   = paras.Extra
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    ResponseError(context, ex);
                    return;
                }
            }
            #endregion

            #region POST/PUT/DELETE via IRestProxy
            if (context.Request.HttpMethod == "POST" ||
                context.Request.HttpMethod == "PUT" ||
                context.Request.HttpMethod == "DELETE")
            {
                if (!typeof(IRestProxy).IsAssignableFrom(t))
                {
                    ResponseError(context, new Exception("The type is not a IRestProxy: " + className));
                    return;
                }

                try
                {
                    IRestProxy rest = (IRestProxy)Activator.CreateInstance(t, new object[] { });

                    string payload = ReadRequestPayload(context);
                    object entity  = JavaScriptDeserializer.DeserializeFromJson(payload, rest.EntityType);

                    switch (context.Request.HttpMethod)
                    {
                    case "POST":     //new
                        object obj1 = rest.Create(entity);
                        ResponseObject(context, new
                        {
                            success = true,
                            root    = new object[] { obj1 }
                        });
                        break;

                    case "PUT":     //update
                        object obj2 = rest.Update(entity);
                        ResponseObject(context, new
                        {
                            success = true,
                            root    = new object[] { obj2 }
                        });
                        break;

                    case "DELETE":
                        rest.Delete(entity);
                        ResponseObject(context, new
                        {
                            success = true
                        });
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ResponseError(context, ex);
                    return;
                }
            }
            #endregion
        }
Esempio n. 20
0
 public MessageService(ISerializer serializer, IRestProxy restProxy, IBusApiConfiguration busApiConfiguration)
 {
     _serializer          = serializer;
     _restProxy           = restProxy;
     _busApiConfiguration = busApiConfiguration;
 }
Esempio n. 21
0
 public DividerClient(IRestProxy restProxy, string baseUri)
 {
     this.RestProxy = restProxy;
     this.BaseUri   = baseUri + "/api/divide";
 }
Esempio n. 22
0
 public AdderClient(IRestProxy restProxy, string baseUri)
 {
     this.RestProxy = restProxy;
     this.BaseUri   = baseUri + "/api/add";
 }