コード例 #1
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
 public static Attachment ToAttachment(NSJSValue value)
 {
     if (value == null)
     {
         return(null);
     }
     if (value is NSJSString)
     {
         string path = ((NSJSString)value).Value;
         if (!File.Exists(path))
         {
             return(null);
         }
         return(new Attachment(path));
     }
     if (value is NSJSObject)
     {
         NSJSObject o             = (NSJSObject)value;
         string     fileName      = o.Get("FileName").As <string>();
         string     mediaType     = o.Get("MediaType").As <string>();
         string     blobName      = o.Get("Name").As <string>();
         Stream     contentStream = NSJSStream.Get(o.Get("ContentStream") as NSJSObject);
         if (contentStream != null && !string.IsNullOrEmpty(blobName))
         {
             return(new Attachment(contentStream, blobName, mediaType));
         }
         if (!File.Exists(fileName))
         {
             return(null);
         }
         return(new Attachment(fileName, mediaType));
     }
     return(null);
 }
コード例 #2
0
ファイル: HttpClient.cs プロジェクト: liulilittle/nsjs
        private static HttpClientResponse object2response(NSJSObject response)
        {
            if (response == null)
            {
                return(null);
            }
            HttpClientResponse o       = new HttpClientResponse();
            NSJSBoolean        boolean = response.Get("ManualWriteToStream") as NSJSBoolean;

            if (boolean != null)
            {
                o.ManualWriteToStream = boolean.Value;
            }
            NSJSObject objectt = response.Get("ContentStream") as NSJSObject;

            if (objectt != null)
            {
                o.ContentStream = NSJSStream.Get(objectt);
            }
            return(o);
        }