Ejemplo n.º 1
0
        protected virtual Task <IWebResponse> OnCreateResponseAsync(IWebRequest request, UnityWebRequest unityWebRequest)
        {
            Dictionary <string, string> headers = unityWebRequest.GetResponseHeaders() ?? new Dictionary <string, string>();
            var statusCode = (HttpStatusCode)unityWebRequest.responseCode;
            var response   = new WebResponse(headers, request.Method, request.Url, statusCode);

            byte[] data = unityWebRequest.downloadHandler?.data;

            if (data == null)
            {
                string error = unityWebRequest.error;

                if (!string.IsNullOrEmpty(error))
                {
                    Encoding encoding = EncodingUtility.GetEncoding(Description.ErrorEncoding);

                    data = encoding.GetBytes(error);
                }
            }

            if (data != null && data.Length > 0)
            {
                response.SetData(data);
            }

            return(Task.FromResult <IWebResponse>(response));
        }
Ejemplo n.º 2
0
 public override void In(FlowScriptEngine.FlowEventArgs e)
 {
     SetStream();
     SetValue(nameof(Encoding));
     if (Stream != null)
     {
         using (var reader = new StreamReader(Stream, EncodingUtility.GetEncoding(Encoding)))
         {
             Value = reader.ReadToEnd();
         }
         OnSuccess();
     }
     else
     {
         OnFailed();
     }
 }
Ejemplo n.º 3
0
 public override void In(FlowScriptEngine.FlowEventArgs e)
 {
     SetStream();
     SetValue(nameof(Encoding));
     if (Stream != null)
     {
         byte[] array = new byte[Stream.Length - Stream.Position];
         Stream.Read(array, 0, array.Length);
         var str = EncodingUtility.GetEncoding(Encoding).GetString(array);
         Value = new List <object>(str.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n'));
         OnSuccess();
     }
     else
     {
         OnFailed();
     }
 }
Ejemplo n.º 4
0
        protected override IDataLoader OnBuild(IApplication arguments)
        {
            Encoding encoding = EncodingUtility.GetEncoding(m_encoding);

            return(new DataLoaderFileText(encoding));
        }