protected void SetUp() { PlaylistItemDataMapper = new PlaylistItemDataMapper(); Config = new TestConfiguration(); WebApi = new TestWebApi(Config); Repo = new PlaylistsRepositoryImpl(WebApi, PlaylistItemDataMapper); }
public MainPageViewModel(IWebApi webApi) { _webApi = webApi; MoreCommand.Subscribe(async _ => { foreach (var book in await GetData()) { Books.Add(book); } }); PrevCommand.Subscribe(_ => { if (Position.Value > 0) { Position.Value--; } }); NextCommand.Subscribe(_ => { if (Position.Value < Books.Count - 1) { Position.Value++; } }); }
public SpotifyPlaybackWorkload( IWebApi webApi, IEventAggregator eventAggregator) { this.webApi = webApi; this.eventAggregator = eventAggregator; }
public SettingsViewModel( IWebApi webApi, ILogger logger) { this.webApi = webApi; this.logger = logger; }
public QuestionResponder(IChatApi chatApi) { this.webApi = new WebApi(ConfigurationManager.AppSettings["ServerAddress"], ConfigurationManager.AppSettings["SlackBotApiToken"], ConfigurationManager.AppSettings["ChannelId"]); this.chatApi = chatApi; }
private AppController(Config config) { _log = Logger.New(Path.Combine(config.LogPath, config.LogFile)); _config = config; _repo = SyncRepo.New(AppRepo.New()); _api = WebApi.New(_log); }
// GET /devices/collectedData // Retrieve Collected Data in Bulk public static async Task <List <CollectedDataModel> > GetCollectedDataAsync(IWebApi webApi, string deviceGroupPath, DateTimeOffset startDate, DateTimeOffset stopDate, string builtInDataType, string customDataType) { List <CollectedDataModel> collectedDateModels; string resourcePath = "devices/collectedData?" + Helpers.GetUrlStartStop(startDate, stopDate); if (!String.IsNullOrWhiteSpace(deviceGroupPath)) { resourcePath += "&path=" + deviceGroupPath; } if (!String.IsNullOrWhiteSpace(builtInDataType)) { resourcePath += "&builtInDataType=" + builtInDataType; } if (!String.IsNullOrWhiteSpace(customDataType)) { resourcePath += "&customDataType=" + customDataType; } // Get data from web API collectedDateModels = await GetObjectListFromWebApi.GetObjectListFromSotiAsync <CollectedDataModel>(webApi, resourcePath); return(collectedDateModels); }
public static ApiAction Get(IWebApi api, string methodName, string version) { if (string.IsNullOrEmpty(methodName)) { throw new ArgumentException(nameof(methodName)); } var invokeMethodName = methodName; var apiver = 0; if (version == null) { var index = methodName.LastIndexOf('V'); if (index > 0) { version = methodName.Remove(0, index + 1); if (int.TryParse(version, out apiver) && apiver >= 0) { methodName = methodName.Remove(index); } } } else if (int.TryParse(version, out apiver) && apiver >= 0) { invokeMethodName = methodName + "V" + version; } else { return(null); } try { var method = api.GetType().GetMethod(invokeMethodName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly | BindingFlags.InvokeMethod); if (method == null || method.Attributes.HasFlag(MethodAttributes.Abstract) || method.Attributes.HasFlag(MethodAttributes.SpecialName)) { return(null); } ApiAction action; if (Actions.TryGetValue(method, out action) == false) { action = new ApiAction(method) { Name = methodName, ApiVersion = apiver }; action.InitFilters(); Actions.TryAdd(method, action); } return(action); } catch (AmbiguousMatchException e) { Trace.WriteLine(e.Message); return(null); } }
/// <summary> /// Initialises a new instance of the <see cref="ServerManagementAccessor"/> class. /// </summary> /// <param name="webApi"> /// The webapi. /// </param> public ServerManagementAccessor(IWebApi webApi) { Server = new ServerAccessor(webApi); ServerImage = new ServerImageAccessor(webApi); AntiAffinityRule = new AntiAffinityRuleAccessor(webApi); Monitoring = new MonitoringAccessor(webApi); }
protected void SetUp() { Config = new TestConfiguration(); WebApi = new TestWebApi(Config); Cache = new TestFileCache(); Storage = new PictureStorageImpl(WebApi, Cache); }
public ConvertController(IAuditApi auditApi, IWebApi webApi, IHttpContextAccessor httpContextAccessor) { WebApi = webApi; AuditApi = auditApi; ContextAccessor = httpContextAccessor; RequestUser = ContextAccessor.HttpContext.User.Identity.IsAuthenticated ? ContextAccessor.HttpContext.User.Identity.Name : "Unauthenticated"; }
protected void SetUp() { Config = new TestConfiguration(); WebApi = new TestWebApi(Config); ProfileDataMapper = new ProfileDataMapper(Config); Repo = new ProfileRepositoryImpl(WebApi, ProfileDataMapper); }
protected void SetUp() { Config = new TestConfiguration(); WebApi = new TestWebApi(Config); LibraryItemDataMapper = new LibraryItemDataMapper(Config); FavoritesRepo = new TestFavoritesRepository(); Repo = new LibraryRepositoryImpl(WebApi, LibraryItemDataMapper, FavoritesRepo); }
public void SetupWebApi(IWebApi webApi, string pathPrefix = "/api/notify") { webApi.OnPost($"{pathPrefix}/send-verify-code", async(req, res) => { Dict values = await req.ParseAsJsonAsync <Dict>(); string contact = values.GetAs("contact", (string)null); await this.SendVerifyCodeAsync(contact); }); }
public override object OnActionExecuting(IWebApi api) { if (api.ApiAction.HasFilter <NoLoginAttribute>()) { return(null); } return(api.OAuthUser == null || api.OAuthUser.IsAuthenticated == false ? new ApiException(ExceptionCode.NotLogin) : null); }
private static async Task <string> GetBatchAsync(IWebApi webApi, string resourcePath, int skip, int take) { resourcePath += "&skip=" + skip.ToString() + "&take=" + take.ToString(); // Call GetJsonAsync return(await webApi.GetJsonAsync(resourcePath)); }
public static OAuthUser GetOAuthUserByAccessToken(IWebApi api, Guid accessToken) { if (accessToken == Guid.Empty) { return(null); } var oauthUser = (OAuthUser)api.Session["LoginedUsers.AccessToken=" + accessToken]; return(oauthUser); }
protected void SetUp() { Log = new LogImpl(); Config = new TestConfiguration(); WebApi = new TestWebApi(Config); LibraryItemDataMapper = new LibraryItemDataMapper(Config); FavoritesRepo = new TestFavoritesRepository(); Repo = new LibraryRepositoryImpl(WebApi, LibraryItemDataMapper, FavoritesRepo); UseCase = new SearchLibraryRequestUseCase(Log, Repo); }
public static Uri UriForAbsolutePath(this IWebApi webApi, string absolutePath) { return(new UriBuilder { Scheme = webApi.Scheme, Host = webApi.Host, Port = webApi.Port ?? -1, Path = absolutePath, }.Uri); }
private string GetIdempotentKey(IWebApi api) { using (var md5Provider = new MD5CryptoServiceProvider()) { var str = string.Join("\n", GetValues(api)); var bytes = Encoding.UTF8.GetBytes(str); var hash = md5Provider.ComputeHash(bytes); return(new Guid(hash).ToString("n")); } }
public HttpResponseMessage GetResponseMessage(IWebApi api) { Api = api; var content = GetHttpContent(); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = content, }); }
public static Uri UriForRelativePath(this IWebApi webApi, string relativePath) { return(new UriBuilder { Scheme = webApi.Scheme, Host = webApi.Host, Port = webApi.Port ?? -1, Path = _PathCombine(webApi.BasePath, relativePath), }.Uri); }
private FacebookApp(string sessionId, FbConfig config, IWebApi api, ILogger log) { _log = log; _sessionId = sessionId; _config = config; _connected = new ManualResetEvent(false); _api = GraphApi.New(config, api); _uploader = PhotoUploader.New(); trace(config.ToJson()); }
public ImpostorPlugin( HttpRootConfigurator httpConfigurator, HttpServer server, IWebApi api, ILogManager logManager, IPlayerCommandHandler playerCommandHandler) { httpConfigurator.Configure(); _httpServer = server; _api = api; _logs = logManager; }
System.Net.Http.HttpResponseMessage IApiResult.GetResponseMessage(IWebApi api) { switch (api.Agent) { case ApiAgent.Web: var message = new HttpResponseMessage(System.Net.HttpStatusCode.OK); message.Content = new ByteArrayContent(Data ?? new byte[0]); message.Content.Headers.ContentType = new MediaTypeHeaderValue(ContentType ?? "application/octet-stream"); if (api.UrlReferrer != null) { var name = FileName ?? Guid.NewGuid().ToString("n"); if (api.UserAgent.IndexOf("Safari", StringComparison.OrdinalIgnoreCase) > -1 && api.UserAgent.IndexOf("Edge", StringComparison.OrdinalIgnoreCase) < 0) //浏览器兼容 { message.Content.Headers.Add("Content-Disposition", "attachment;filename=\"" + name + "\""); } else { message.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = name, FileNameStar = name, Name = name, }; } } return(message); case ApiAgent.Android: case ApiAgent.Ios: case ApiAgent.DotNet: case ApiAgent.Ajax: case ApiAgent.Jsonp: return(((IApiResult) new JsonResult(new { ContentType = ContentType ?? "text/txt", FileName = FileName ?? Guid.NewGuid().ToString("n"), Content = Convert.ToBase64String(Data ?? new byte[0]), }) { ExceptionCode = ExceptionCode.File }).GetResponseMessage(api)); default: return(((IApiResult) new JsonResult(null) { ExceptionCode = ExceptionCode.NotImplemented, Message = "不支持", }).GetResponseMessage(api)); } }
public RedHttpServerContext(string url, string staticPath = null) { // Binding to all local IP addresses requires adding an HTTP URL ACL rule // This may prompt to "allow app to modify your device" ProcessX.AddHttpUrlAclIfNeeded(url); // Create the underlying RedHttpServer (see https://github.com/rosenbjerg/Red) this.webServer = new Red.RedHttpServer(8000, staticPath); // Create the IWebApi and ISubscriptionApi wrappers this.webApi = new RedHttpServerWebApi(webServer); this.subscriptionApi = new RedHttpServerSubscriptionApi(webServer, path: "/ws"); }
public MainWindowViewModel( IWebApi webApi, IWindowManager windowManager, ISettingsViewModel settingsViewModel, IEventAggregator eventAggregator) { this.webApi = webApi; this.windowManager = windowManager; this.settingsViewModel = settingsViewModel; eventAggregator.SubscribeOnUIThread(this); }
/// <summary> /// Initializes a new instance of the <see cref="NetworkingAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api Client. /// </param> public NetworkingAccessor(IWebApi apiClient) { NetworkDomain = new NetworkDomainAccessor(apiClient); Vlan = new VlanAccessor(apiClient); SecurityGroup = new SecurityGroupAccessor(apiClient); IpAddress = new IpAddressAccessor(apiClient); Nat = new NatAccessor(apiClient); FirewallRule = new FirewallRuleAccessor(apiClient); VipSupport = new VipSupportAccessor(apiClient); VipPool = new VipPoolAccessor(apiClient); VipNode = new VipNodeAccessor(apiClient); VipVirtualListener = new VipVirtualListenerAccessor(apiClient); }
public Startup( ISettingsProvider settingsProvider, IEventAggregator eventAggregator, IWebApi webApi, IApplicationController applicationController, ILogger logger, IReAuthenticationEventAggregator reAuthenticationEventAggregator) { this.settingsProvider = settingsProvider; this.webApi = webApi; this.applicationController = applicationController; this.logger = logger; this.reAuthenticationEventAggregator = reAuthenticationEventAggregator; eventAggregator.SubscribeOnPublishedThread(this); }
/// <summary> /// 执行Action之后触发 /// </summary> /// <param name="api"></param> /// <param name="result"></param> /// <returns></returns> public async Task <object> OnActionExecuted(IWebApi api, object result) { var length = _filters.Count; for (var i = 0; i < length; i++) { var f = _filters[i]; var r = await TryRunTask(f.OnActionExecuted(api, result)); if (r != null) { return(r); } } return(null); }
/// <summary> /// Initialises a new instance of the <see cref="BackupAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api client. /// </param> public BackupAccessor(IWebApi apiClient) { this._apiClient = apiClient; }
/// <summary> /// Initialises a new instance of the <see cref="ServerManagementLegacyAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api client. /// </param> public ServerManagementLegacyAccessor(IWebApi apiClient) { this.Server = new ServerAccessor(apiClient); this.ServerImage = new ServerImagesAccessor(apiClient); }
/// <summary> /// Initialises a new instance of the <see cref="AccountAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api client. /// </param> public AccountAccessor(IWebApi apiClient) { this._apiClient = apiClient; }
/// <summary> /// Initializes a new instance of the DD.CBU.Compute.Api.Client.Network20.Networking /// class. /// </summary> /// <param name="apiClient"> /// The api Client. /// </param> public NetworkingAccessor(IWebApi apiClient) { NetworkDomain = new NetworkDomainAccessor(apiClient); Vlan = new VlanAccessor(apiClient); IpAddressManagement = new IpAddressManagementAccessor(apiClient); }
/// <summary> /// Initialises a new instance of the <see cref="ServerImagesAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api client. /// </param> public ServerImagesAccessor(IWebApi apiClient) { this._apiClient = apiClient; }
/// <summary> /// Initialises a new instance of the <see cref="ServerAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api client. /// </param> public ServerAccessor(IWebApi apiClient) { _apiClient = apiClient; }
/// <summary> /// Initializes a new instance of the DD.CBU.Compute.Api.Client.Network20.NetworkDomain /// class. /// </summary> /// <param name="apiClient"> The client. </param> public NetworkDomainAccessor(IWebApi apiClient) { _apiClient = apiClient; }
/// <summary> /// Initializes a new instance of the <see cref="IpAddressManagementAccessor"/>. /// </summary> /// <param name="apiClient"> The client. </param> public IpAddressManagementAccessor(IWebApi apiClient) { this._apiClient = apiClient; }
/// <summary> /// Initialises a new instance of the <see cref="ImportExportCustomerImageAccessor"/> class. /// </summary> /// <param name="apiClient"> /// The api client. /// </param> public ImportExportCustomerImageAccessor(IWebApi apiClient) { _apiClient = apiClient; }
/// <summary> /// Initialises a new instance of the <see cref="VlanAccessor"/> class. /// </summary> /// <param name="api"> /// The api. /// </param> public VlanAccessor(IWebApi api) { _api = api; }
/// <summary> /// Initialises a new instance of the <see cref="ServerManagementAccessor"/> class. /// </summary> /// <param name="webapi"> /// The webapi. /// </param> public ServerManagementAccessor(IWebApi webapi) { Server = new ServerAccessor(webapi); }
/// <summary> /// Initializes a new instance of the DD.CBU.Compute.Api.Client.Network20.Networking /// class. /// </summary> /// <param name="apiClient"> /// The api Client. /// </param> public NetworkingLegacyAccessor(IWebApi apiClient) { this.Network = new NetworkAccessor(apiClient); this.NetworkVip = new NetworkVipAccessor(apiClient); }