public static MailAddress ToMailAddress(NSJSValue value) { NSJSObject a = value as NSJSObject; string address = null; if (a == null) { NSJSString s = value as NSJSString; if (s != null) { address = s.Value; if (string.IsNullOrEmpty(address)) { return(null); } return(new MailAddress(address)); } return(null); } address = ValueAuxiliary.ToString(a.Get("Address")); if (string.IsNullOrEmpty(address)) { return(null); } string displayName = ValueAuxiliary.ToString(a.Get("DisplayName")); return(new MailAddress(address, displayName, Encoding.UTF8)); }
public static Cookie ToCookie(NSJSValue value) { NSJSObject o = value as NSJSObject; if (o == null) { return(null); } Cookie cookie = new Cookie(); cookie.Comment = ValueAuxiliary.ToString(o.Get("Comment")); cookie.Discard = ValueAuxiliary.ToBoolean(o.Get("Discard")); Uri url = default(Uri); if (Uri.TryCreate(ValueAuxiliary.ToString(o.Get("CommentUri")), UriKind.RelativeOrAbsolute, out url)) { cookie.CommentUri = url; } cookie.Domain = ValueAuxiliary.ToString(o.Get("Domain")); cookie.Expired = ValueAuxiliary.ToBoolean(o.Get("Expired")); cookie.Expires = ValueAuxiliary.ToDateTime(o.Get("Expires")); cookie.HttpOnly = ValueAuxiliary.ToBoolean(o.Get("HttpOnly")); cookie.Name = ValueAuxiliary.ToString(o.Get("Name")); cookie.Path = ValueAuxiliary.ToString(o.Get("Path")); cookie.Port = ValueAuxiliary.ToString(o.Get("Port")); cookie.Secure = ValueAuxiliary.ToBoolean(o.Get("Secure")); cookie.Value = ValueAuxiliary.ToString(o.Get("Value")); cookie.Version = ValueAuxiliary.ToInt32(o.Get("Version")); return(cookie); }
public static MailMessage ToMailMessage(NSJSValue value) { NSJSObject mail = value as NSJSObject; if (mail == null) { return(null); } MailMessage message = new MailMessage(); message.Body = ValueAuxiliary.ToString(mail.Get("Body")); message.Subject = ValueAuxiliary.ToString(mail.Get("Subject")); message.IsBodyHtml = ValueAuxiliary.ToBoolean(mail.Get("IsBodyHtml")); message.BodyEncoding = Encoding.UTF8; message.HeadersEncoding = Encoding.UTF8; message.SubjectEncoding = Encoding.UTF8; MailAddress address = ToMailAddress(mail.Get("From")); if (address == null) { return(null); } message.From = address; message.Sender = ToMailAddress(mail.Get("Sender")); ArrayAuxiliary.Fill(mail.Get("To"), message.To); ArrayAuxiliary.Fill(mail.Get("ReplyToList"), message.ReplyToList); ArrayAuxiliary.Fill(mail.Get("Attachments"), message.Attachments); return(message); }
public static IList <string> ToStringList(NSJSValue value) { if (value == null) { return(null); } IList <string> s = new List <string>(); try { NSJSArray arrays = value as NSJSArray; if (arrays != null) { foreach (NSJSValue i in arrays) { if (i == null) { continue; } s.Add(ValueAuxiliary.ToString(i)); } } } catch (Exception) { } return(s); }
public static IList <object> ToArray(IEnumerable <NSJSValue> s) { IList <object> list = new List <object>(); if (s != null) { foreach (NSJSValue i in s) { list.Add(ValueAuxiliary.Value(i)); } } return(list); }
public static int Fill(NSJSValue source, NameValueCollection destination) { NSJSObject objecttive = source as NSJSObject; int count = 0; if (objecttive == null || destination == null) { return(count); } foreach (string key in objecttive.GetAllKeys()) { if (string.IsNullOrEmpty(key)) { continue; } destination.Set(key, ValueAuxiliary.ToString(objecttive.Get(key))); count++; } return(count); }
public static void Call <TThis>(IntPtr info, Action <TThis, NSJSFunctionCallbackInfo, DateTime> doo) { Throwable.ArgumentNullException(info, doo); Call <TThis>(info, (self, arguments, value) => doo(self, arguments, ValueAuxiliary.ToDateTime(value))); }
public static void GetOrSetProperty <TThis>(IntPtr info, Func <TThis, int> get, Action <TThis, int> set) { Throwable.ArgumentNullException(info, get, set); GetOrSetProperty <TThis>(info, (self, arguments) => arguments.SetReturnValue(get(self)), (self, value) => set(self, ValueAuxiliary.ToInt32(value))); }