public RpcProxyNexus(IRpcClientChannel channel, BaseUri uri, string serviceRole) { _channel = channel; _serverUri = uri; _version = RpcProtocolVersion.V4; _serviceRole = serviceRole; }
public IRpcClientTransaction CreateTransaction(BaseUri serverUri) { IICAssert.Is<NamedPipeUri>(serverUri); return new RpcPipeClientTransaction(this, (NamedPipeUri)serverUri); }
/// <summary> /// Returns a <see cref="System.String" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String" /> that represents this instance. /// </returns> public override string ToString() { return(BaseUri.ToString()); }
public string ToString(CoapEndpointStringFormat format) { return(BaseUri.ToString()); }
public void Can_access_Admin_service_with_AuthSecret() { BaseUri.AppendPath("requestlogs").AddQueryParam("authsecret", AuthSecret).GetStringFromUrl(); }
protected override Uri GetUri(params string[] values) { return(BaseUri.Append("me", "roles")); }
protected override Uri GetUri(params string[] values) { return(BaseUri.Append("me", values[0], "cash-drawer-shifts")); }
public IRpcClientTransaction CreateTransaction(BaseUri serverUri) { IICAssert.Is <InprocUri>(serverUri, ""); return(new RpcInprocTransaction(this)); }
public void Can_access_Admin_service_with_AuthSecret() { BaseUri.AppendPath("requiresadmin") .AddQueryParam("authsecret", AuthSecret).GetJsonFromUrl(); }
public void Start() { _webApp = WebApp.Start(BaseUri.ToString(), app => app.Use <ProxyMiddleware>(Expect, _capturedRequests)); Client = new HttpClient(); Client.BaseAddress = BaseUri; }
private HttpStatusCode MakeRequest(RestfulObject <T> obj, out RestfulObject <T> responseObj) { //ISerializer<T> iSerializer = SerializerFactory.Create<T>( QueueSerializationFormat ); //Device.Log.Debug (string.QueueSerializationFormat ("Request Body: {0}", iSerializer.SerializeObject (obj.Object, MonoCross.Utilities.EncryptionMode.NoEncryption))); byte[] postBytes = Serializer.SerializeObjectToBytes(obj.Object, EncryptionMode.NoEncryption); var headers = MergeHeaders(obj); var body = Serializer.SerializeObject(obj.Object); // add OData Accept header if (Format == SerializationFormat.ODATA && !obj.PutPostDeleteHeaders.Contains("Accept")) { obj.PutPostDeleteHeaders.Add("Accept", "application/json"); } NetworkResponse retval = Device.Network.Poster.PostBytes(BaseUri.AppendPath(obj.TransactionEndpoint), postBytes, Serializer.ContentType, obj.Verb, headers, obj.Object, _responseTimeout); // if Rest returns type and verb Put/Post then convert response to type T // and call event with object to pass to subscriber (e.g. a provider) responseObj = default(RestfulObject <T>); if (retval.StatusCode == HttpStatusCode.OK || retval.StatusCode == HttpStatusCode.Created || retval.StatusCode == HttpStatusCode.Accepted || retval.StatusCode == HttpStatusCode.NoContent) { if (RequestReturnsObject) { if (obj.Verb == HttpVerb.Post || (obj.Verb == HttpVerb.Put && Format != SerializationFormat.ODATA)) { obj.ExpirationDate = retval.Expiration; obj.AttemptRefreshDate = retval.AttemptToRefresh; if (retval.ResponseBytes != null) { T returnObj = Serializer.DeserializeObject(retval.ResponseBytes, EncryptionMode.NoEncryption); if (returnObj == null) { responseObj = obj.Clone(returnObj); return(retval.StatusCode); } responseObj = obj.Clone(returnObj); } else { responseObj = obj.Clone(default(T)); } } else if (obj.Verb == HttpVerb.Delete || (obj.Verb == HttpVerb.Put && Format == SerializationFormat.ODATA)) { responseObj = obj.Clone(obj.Object); // set response object to return if DELETE or OData PUT } } else { responseObj = obj.Clone(obj.Object); obj.ExpirationDate = retval.Expiration; obj.AttemptRefreshDate = retval.AttemptToRefresh; } //if ( RequestReturnsObject && ( obj.Verb == HttpVerb.Post || obj.Verb == HttpVerb.Put ) ) //{ // T returnObj = iSerializer.DeserializeObject( retval.ResponseString, Core.Utilities.EncryptionMode.NoEncryption ); // if ( returnObj == null ) // return retval.StatusCode; // obj.ExpirationDate = retval.Expiration; // obj.AttemptRefreshDate = retval.AttemptToRefresh; // responseObj = obj.Clone( returnObj ); //} } return(retval.StatusCode); }
public void Start() { _webApp = WebApp.Start(BaseUri.ToString(), app => app.Use <ProxyMiddleware>(Expect, _capturedRequests)); }
void initializeView() { if (!ArcGISOnlineEnvironment.ArcGISOnline.IsInitialized) // Wait for AGOL environment initialization { EventHandler <EventArgs> onInitialized = null; onInitialized = (o, e) => { ArcGISOnlineEnvironment.ArcGISOnline.Initialized -= onInitialized; initializeView(); }; ArcGISOnlineEnvironment.ArcGISOnline.Initialized += onInitialized; } else { WindowManager manager = View != null && View.WindowManager != null ? View.WindowManager : null; string portalUrl = BaseUri.Scheme == "http" ? ViewerApplication.ArcGISOnlineSharing : ViewerApplication.ArcGISOnlineSecure; // TODO: Investigate difference between ViewerApplication.ArcGISOnlineProxy and ViewerApplication.Proxy ArcGISPortal portal = new ArcGISPortal() { Url = portalUrl, Token = ArcGISOnlineEnvironment.ArcGISOnline.User != null ? ArcGISOnlineEnvironment.ArcGISOnline.User.Token : null, ProxyUrl = ViewerApplication.ArcGISOnlineProxy }; View = new View(ApplicationServices, manager) { IsEditMode = IsEditMode, BaseUrl = BaseUri.ToString(), ApplicationColorSet = ApplicationColorSet, LayoutProvider = new LayoutFileProvider() { LayoutFileContents = layoutFileContents, }, Portal = portal }; if (!string.IsNullOrWhiteSpace(ConfigurationStoreFilePath)) { View.ConfigurationStoreProvider = new ViewerConfigurationStoreProvider(ViewerApplication.GeometryService, ViewerApplication.BingMapsAppId, ViewerApplication.PortalAppId); } View.ProxyUrl = View.DefaultProxyUrl = ViewerApplication.Proxy; layoutResourceDictionaries = new List <ResourceDictionary>(); foreach (string layoutResourceDictionaryFileContent in layoutResourceDictionaryFileContents) { if (!string.IsNullOrWhiteSpace(layoutResourceDictionaryFileContent)) { ResourceDictionary resourceDict = XamlReader.Load(layoutResourceDictionaryFileContent) as ResourceDictionary; if (resourceDict != null) { Application.Current.Resources.MergedDictionaries.Add(resourceDict); layoutResourceDictionaries.Add(resourceDict); } } } View.LayoutResourceDictionaries = layoutResourceDictionaries; if (!string.IsNullOrWhiteSpace(ThemeFilePath)) { View.ThemeProvider = new ThemeProvider() { ThemeFileUrl = ThemeFilePath, }; } if (!string.IsNullOrWhiteSpace(ConnectionsFileFilePath)) { View.ConnectionsProvider = new FileConnectionsProvider() { ConfigurationFile = new DataFile() { IsUrl = true, Path = ConnectionsFileFilePath } }; } if (!string.IsNullOrWhiteSpace(MapConfigurationFilePath)) { FileConfigurationProvider fileConfigurationProvider = ConfigurationProvider ?? new FileConfigurationProvider(); fileConfigurationProvider.ConfigurationFile = new DataFile() { IsUrl = true, Path = MapConfigurationFilePath }; View.ConfigurationProvider = fileConfigurationProvider; } if (!string.IsNullOrWhiteSpace(SymbolConfigurationFilePath)) { View.SymbolConfigProvider = new FileSymbolConfigProvider() { ConfigFileUrl = SymbolConfigurationFilePath, ClassBreaksColorGradientsConfigFileUrl = ClassBreaksColorGradientsConfigFileUrl, HeatMapColorGradientsConfigFileUrl = HeatMapColorGradientsConfigFileUrl, SymbolFolderParentUrl = SymbolFolderParentUrl, UniqueValueColorGradientsConfigFileUrl = UniqueValueColorGradientsConfigFileUrl, }; } View.ExtensionsDataManager = new ExtensionsDataManager() { ExtensionsConfigData = new ExtensionsConfigData(controlsXmlFileContents) }; View.ExtensionBehaviors = getBehaviors(behaviorsXmlFileContents); View.ExtensionLoadFailed += new EventHandler <ExceptionEventArgs>(View_ExtensionLoadFailed); View.ConfigurationLoaded += new EventHandler(View_ConfigurationLoaded); this.Content = View; OnViewInitialized(new ViewEventArgs() { View = View }); } }
/// <summary> /// Сохранить конфигурацию. /// </summary> /// <param name="container">Контейнер.</param> protected override void SaveConfiguration(ApplicationDataContainer container) { container.Values["baseUri"] = BaseUri?.ToString() ?? "https://2ch.hk/"; }
void ProcessRequest() { try { var requestUri = new StringBuilder(); requestUri.AppendFormat("{0}{1}{2}/{3}", BaseUri, (BaseUri.ToString().EndsWith("/")) ? string.Empty : "/", Uri.EscapeUriString(ScopeName), _wrapper.CacheRequest.RequestType.ToString()); string prefix = "?"; // Add the scope params if any foreach (KeyValuePair <string, string> kvp in _scopeParameters) { requestUri.AppendFormat("{0}{1}={2}", prefix, Uri.EscapeUriString(kvp.Key), Uri.EscapeUriString(kvp.Value)); if (prefix.Equals("?")) { prefix = "&"; } } // Create the WebRequest var webRequest = new NSMutableUrlRequest(new NSUrl(requestUri.ToString())); if (_credentials != null) { NetworkCredential credential = _credentials.GetCredential(BaseUri, "Basic"); string svcCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credential.UserName + ":" + credential.Password)); webRequest["Authorization"] = "Basic " + svcCredentials; webRequest["configname"] = _behaviors.ConfigName; webRequest["configversion"] = _behaviors.ConfigVersion; webRequest["coreversion"] = _behaviors.CoreVersion.ToString(); } else { throw new Exception("Credentials is null"); } foreach (var item in _behaviors.DeviceInfo) { webRequest[item.Key] = item.Value; } webRequest.HttpMethod = "POST"; webRequest["Accept"] = ApplicationContext.Current.Settings.BitMobileFormatterDisabled ? "application/atom+xml" : "application/bitmobile"; webRequest["Content-Type"] = ApplicationContext.Current.Settings.BitMobileFormatterDisabled ? "application/atom+xml" : "application/bitmobile"; webRequest["Accept-Encoding"] = "gzip, deflate"; webRequest.TimeoutInterval = Timeout; webRequest.Body = CreateRequestBody(); _wrapper.WebRequest = webRequest; if (_wrapper.CacheRequest.RequestType == CacheRequestType.UploadChanges) { lock (_lockObject) { _currentTask = CreateUploadSession().CreateDownloadTask(webRequest); _currentTask.Resume(); } } else { lock (_lockObject) { _currentTask = CreateDownloadSession().CreateDownloadTask(webRequest); _currentTask.Resume(); } } } catch (Exception e) { if (ExceptionUtility.IsFatal(e)) { throw; } _wrapper.Error = e; _workerManager.CompleteWorkRequest(_wrapper.WorkerRequest, _wrapper); } }
internal CspOptions Build() { List <string> directives = new List <string>(); string connectSourcesString = ConnectSources.Build(); if (!string.IsNullOrEmpty(connectSourcesString)) { directives.Add($"connect-src {connectSourcesString}"); } string defaultResourcesString = DefaultSources.Build(); if (!string.IsNullOrEmpty(defaultResourcesString)) { directives.Add($"default-src {defaultResourcesString}"); } string fontSourcesString = FontSources.Build(); if (!string.IsNullOrEmpty(fontSourcesString)) { directives.Add($"font-src {fontSourcesString}"); } string frameSourcesString = FrameSources.Build(); if (!string.IsNullOrEmpty(frameSourcesString)) { directives.Add($"frame-src {frameSourcesString}"); } string imgSourcesString = ImgSources.Build(); if (!string.IsNullOrEmpty(imgSourcesString)) { directives.Add($"img-src {imgSourcesString}"); } string manifestSourcesString = ManifestSources.Build(); if (!string.IsNullOrEmpty(manifestSourcesString)) { directives.Add($"manifest-src {manifestSourcesString}"); } string mediaSourcesString = MediaSources.Build(); if (!string.IsNullOrEmpty(mediaSourcesString)) { directives.Add($"media-src {mediaSourcesString}"); } string objectSourcesString = ObjectSources.Build(); if (!string.IsNullOrEmpty(objectSourcesString)) { directives.Add($"object-src {objectSourcesString}"); } string prefetchSourcesString = PrefetchSources.Build(); if (!string.IsNullOrEmpty(prefetchSourcesString)) { directives.Add($"prefetch-src {prefetchSourcesString}"); } string scriptSourcesString = ScriptSources.Build(); if (!string.IsNullOrEmpty(scriptSourcesString)) { directives.Add($"script-src {scriptSourcesString}"); } string styleSourcesString = StyleSources.Build(); if (!string.IsNullOrEmpty(styleSourcesString)) { directives.Add($"style-src {styleSourcesString}"); } string webrtcSourcesString = WebRtcSources.Build(); if (!string.IsNullOrEmpty(webrtcSourcesString)) { directives.Add($"webrtc-src {webrtcSourcesString}"); } string workerSourcesString = WorkerSources.Build(); if (!string.IsNullOrEmpty(workerSourcesString)) { directives.Add($"worker-src {workerSourcesString}"); } string baseUriString = BaseUri.Build(); if (!string.IsNullOrEmpty(baseUriString)) { directives.Add($"base-uri {baseUriString}"); } string pluginTypesString = PluginTypes.Build(); if (!string.IsNullOrEmpty(pluginTypesString)) { directives.Add($"plugin-types {pluginTypesString}"); } string sanboxOptionsString = Sandbox.Build(); if (!string.IsNullOrEmpty(sanboxOptionsString)) { directives.Add($"sandbox {sanboxOptionsString}"); } string formActionString = FormAction.Build(); if (!string.IsNullOrEmpty(formActionString)) { directives.Add($"form-action {formActionString}"); } string frameAncestors = FrameAncestors.Build(); if (!string.IsNullOrEmpty(frameAncestors)) { directives.Add($"frame-ancestors {frameAncestors}"); } if (upgrateInsecureRequests) { directives.Add("upgrade-insecure-requests"); } if (blockAllMixedContent) { directives.Add("block-all-mixed-content"); } string requireSriForString = RequireSriFor.Build(); if (!string.IsNullOrEmpty(requireSriForString)) { directives.Add($"require-sri-for {requireSriForString}"); } if (reportGroup != null) { directives.Add($"report-to {reportGroup.Group}"); } CspOptions options = new CspOptions { Content = string.Join("; ", directives), ReportingGroup = reportGroup }; return(options); }