protected override void WriteContent(IContext objContext, string strFullName) { // Get request and response HostRequest objRequest = objContext.HostContext.Request; HostResponse objResponse = objContext.HostContext.Response; // Get ResizeMethod and then either Percentage or Width+Height ResizeMethod enmResizeMethod = (ResizeMethod)Enum.Parse(typeof(ResizeMethod), objRequest.QueryString["Method"]); if (enmResizeMethod == ResizeMethod.None) { base.WriteContent(objContext, strFullName); } else if (enmResizeMethod == ResizeMethod.Propotional) { double dblPercentage = double.Parse(objRequest.QueryString["Percent"], System.Globalization.CultureInfo.InvariantCulture); Image objImage = this.ScaleToPercent(strFullName, dblPercentage); this.SaveImageToOutputStream(objResponse.OutputStream, objImage, strFullName); objImage.Dispose(); } else if (enmResizeMethod == ResizeMethod.Size) { int intWidth = int.Parse(objRequest.QueryString["Width"]); int intHeight = int.Parse(objRequest.QueryString["Height"]); Image objImage = this.ScaleToSize(strFullName, intWidth, intHeight); this.SaveImageToOutputStream(objResponse.OutputStream, objImage, strFullName); objImage.Dispose(); } else { throw new ArgumentOutOfRangeException("StaticImageResizeHandle missing resize method"); } }
private void PipeFunc(object o) { NamedPipeClientStream pipe = new NamedPipeClientStream(this.pipeServerAddress); pipe.Connect(); while (true) { var pipeRequest = (HostRequest)pipe.ReadByte(); HostResponse resp = HostResponse.Success; if (AdHocHost.hasFabricDied) { resp |= HostResponse.FabricHasExited; } if (AdHocHost.isActivationContextAvailable) { resp |= HostResponse.ActivationContextIsAvailable; } pipe.WriteByte((byte)resp); if (pipeRequest == HostRequest.Stop) { pipe.Close(); AdHocHost.shouldQuitNowEvent.Set(); return; } } }
/// <summary> /// Gets the gateway handler. /// </summary> /// <param name="objContext">Request context.</param> /// <returns></returns> IStaticGatewayHandler IStaticGateway.GetGatewayHandler(IContext objContext) { // Get request and response HostRequest objRequest = objContext.HostContext.Request; HostResponse objResponse = objContext.HostContext.Response; // Get filename and content type from decoded query parameters string strFilename = HttpUtility.UrlDecode(objRequest.QueryString["Qualifier"]); string strContentType = HttpUtility.UrlDecode(objRequest.QueryString["Token"]); // Write it this.Write(objContext, this.getFullName(strFilename), strContentType); return(null); }
public async Task <HostResult> GetHostDetails(string token) { JObject @params = new JObject() { new JProperty("params", new JObject() { new JProperty("auth", new JObject() { new JProperty("token", token) }) }) }; HostResponse response = await restClient.PostAsync <HostResponse, JObject>(ApiURI.URL_MAIN + ApiURI.URI_GET_HOST_DETAILS, @params); return(response?.Result); }
public async Task <HostResult> Login(string email, string password) { JObject @params = new JObject() { new JProperty("params", new JObject() { new JProperty("auth", new JObject() { new JProperty("db", "kamooni"), new JProperty("login", email.ToLower().Trim()), new JProperty("password", StringFormatUtil.ToBase64(password)) }) }) }; HostResponse response = await restClient.PostAsync <HostResponse, JObject>(ApiURI.URL_MAIN + ApiURI.URI_SIGN_IN, @params); return(response?.Result); }
override void writeSubstitution ( HostResponse .HostResponseSubstitutionCallback callback ) { this.response.WriteSubstitution(context=>callback(new IISHttpContext(context))); }