/// <summary> /// Valida os parametros informados para criação de usuário. /// </summary> /// <param name="newUserRequest"></param> /// <returns></returns> private static AuthResult ValidateRequest(NewRequest newUserRequest, bool create = true) { AuthResult authResult = new AuthResult(); if (TextUtils.StringContainsAccents(newUserRequest.Username)) { authResult.AuthStatus = AuthStatus.INVALID_USERNAME; } authResult.AuthStatus = ValidatePassword(newUserRequest.Password) ? AuthStatus.OK : AuthStatus.INVALID_PASSWORD; if (authResult.AuthStatus == AuthStatus.OK && create) { if (!string.IsNullOrWhiteSpace(newUserRequest.Cpf)) { if (!TextUtils.IsValidCpf(newUserRequest.Cpf)) { authResult.AuthStatus = AuthStatus.INVALID_CPF; } } } return(authResult); }
protected void btnLogin_Click(object sender, EventArgs e) { try { DataBaseManager.ConnectToSlashDatabase(); int count = DataBaseManager.SelectUserCount(txtEmail.Text, txtPwd.Text); if (count != 1) { //TODO redirect to problem submit webpage //Response.Redirect() } else { SqlDataReader reader = DataBaseManager.SelectUser(txtEmail.Text, txtPwd.Text); reader.Read(); string name = (string)reader["username"]; SessionVar.Set <string>("user_name", name); string key = TextUtils.GetRandomLoginKey(); Debug.WriteLine("test tag generated key " + key); Response.Cookies["login_key"].Value = key; Response.Cookies["login_key"].Expires = DateTime.Now.AddDays(10); SessionVar.SetString("login_key", key); Debug.WriteLine("cookie key " + Response.Cookies["login_key"].Value); Response.Redirect("home/" + Server.UrlEncode(name)); } } catch (Exception err) { lblError.Text = err.Message.ToString(); } finally { DataBaseManager.CloseConnection(); } }
public async Task EndReminders(string eventName = "") { if (eventName.IsNullOrEmpty()) { eventName = GetDefaultEventName(); } if (MarathonReminderService.DoesLockFileExist(eventName) == false) { await ReplyAsync(TextUtils.GetWarnText($"Reminder Service for {eventName} is not running")); return; } try { MarathonReminderService.EndRun(eventName); await ReplyAsync(TextUtils.GetInfoText($"Kill command sent for {eventName}, please allow up to 2 minutes for service to end")); } catch (Exception e) { await ReplyAsync(TextUtils.GetErrorText($"Unable to end run: {e.Message}")); } }
public void ScheduleJob(View v) { if (!EnsureTestService()) { return; } var builder = new JobInfo.Builder(kJobId++, serviceComponent); var delay = delayEditText.Text; if (delay != null && !TextUtils.IsEmpty(delay)) { builder.SetMinimumLatency(long.Parse(delay) * 1000); } var deadline = deadlineEditText.Text; if (deadline != null && !TextUtils.IsEmpty(deadline)) { builder.SetOverrideDeadline(long.Parse(deadline) * 1000); } bool requiresUnmetered = wiFiConnectivityRadioButton.Checked; bool requiresAnyConnectivity = anyConnectivityRadioButton.Checked; if (requiresUnmetered) { builder.SetRequiredNetworkCapabilities(NetworkTypeValue.Unmetered); } else if (requiresAnyConnectivity) { builder.SetRequiredNetworkCapabilities(NetworkTypeValue.Any); } builder.SetRequiresDeviceIdle(requiresIdleCheckbox.Checked); builder.SetRequiresCharging(requiresChargingCheckBox.Checked); testService.ScheduleJob(builder.Build()); }
private static void parse(JSONObject json, string key) { bool success = false; JSONObject result = json.OptJSONObject("result"); if (result != null) { string license = result.OptString("license"); if (!TextUtils.IsEmpty(license)) { string[] licenses = license.Split(','); if (licenses != null && licenses.Length == 2) { PreferencesUtil.putString("activate_key", key); Java.Util.ArrayList list = new Java.Util.ArrayList(); list.Add(licenses[0]); list.Add(licenses[1]); success = FileUitls.c(Contexts, FaceSDKManager.LICENSE_NAME, list); } } } if (success) { toast("激活成功"); if (activationCallback != null) { activationCallback.callback(true); activationDialog.Dismiss(); } } else { toast("激活失败"); } }
/// <summary> /// Tries to save all changed values to server. Throws Exception if fails. /// </summary> public void Commit() { // Values haven't chnaged, so just skip saving. if (!m_ValuesChanged) { return; } /* UpdateUserMessageRuleAction <virtualServerID> "<userRuleID>" "<messageRuleID>" "<messageRuleActionID>" "<description>" <actionType> "<actionData>:base64" * Responses: +OK <sizeOfData> * <data> * * -ERR <errorText> */ // Call TCP UpdateUserMessageRuleAction m_pRule.Owner.VirtualServer.Server.TcpClient.TcpStream.WriteLine("UpdateUserMessageRuleAction " + m_pRule.Owner.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pRule.Owner.Owner.UserID) + " " + TextUtils.QuoteString(m_pRule.ID) + " " + TextUtils.QuoteString(m_ID) + " " + TextUtils.QuoteString(m_Description) + " " + ((int)ActionType).ToString() + " " + Convert.ToBase64String(this.Serialize()) ); string response = m_pRule.Owner.VirtualServer.Server.ReadLine(); if (!response.ToUpper().StartsWith("+OK")) { throw new Exception(response); } m_ValuesChanged = false; }
private static IMAP_Namespace ParseNamespace(string val) { string[] parts = TextUtils.SplitQuotedString(val, ' ', true); string name = ""; if (parts.Length > 0) { name = parts[0]; } string delimiter = ""; if (parts.Length > 1) { delimiter = parts[1]; } // Remove delimiter from end, if it's there. if (name.EndsWith(delimiter)) { name = name.Substring(0, name.Length - delimiter.Length); } return(new IMAP_Namespace(name, delimiter)); }
private void cmbSound_SelectedIndexChanged(object sender, EventArgs e) { mEditorItem.Sound = TextUtils.SanitizeNone(cmbSound?.Text); }
/// <summary> /// Returns the current sentence at the caret - beginning /// from the beginning of the sentence up to the caret position /// </summary> /// <param name="sentence">Returns the sentence</param> public virtual void GetSentenceAtCaret(out String sentence) { TextUtils.GetSentenceAtCaret(GetText(), GetCaretPos(), out sentence); }
/// <summary> /// Returns the word previous to the one the caret is at. /// </summary> /// <param name="word">Word</param> /// <returns>Offset of the previous word</returns> public virtual int GetPreviousWordAtCaret(out String word) { return(TextUtils.GetPreviousWord(GetText(), GetCaretPos(), out word)); }
/// <summary> /// Returns 'count' character preceding the caret position /// </summary> /// <param name="count">How many characters to fetch</param> /// <param name="word">returns the string of characters</param> /// <returns>number of characters </returns> public virtual int GetPrecedingCharacters(int count, out String word) { return(TextUtils.GetPrecedingCharacters(GetText(), GetCaretPos(), count, out word)); }
protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update) { IList <OutputTO> outputs = new List <OutputTO>(); allErrors = new ErrorResultTO(); var colItr = new WarewolfListIterator(); //get all the possible paths for all the string variables var inputItr = new WarewolfIterator(dataObject.Environment.Eval(OutputPath, update)); colItr.AddVariableToIterateOn(inputItr); var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update)); colItr.AddVariableToIterateOn(unameItr); var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update)); colItr.AddVariableToIterateOn(passItr); var privateKeyItr = new WarewolfIterator(dataObject.Environment.Eval(PrivateKeyFile, update)); colItr.AddVariableToIterateOn(privateKeyItr); var contentItr = new WarewolfIterator(dataObject.Environment.Eval(FileContents, update)); colItr.AddVariableToIterateOn(contentItr); outputs.Add(DataListFactory.CreateOutputTO(Result)); if (dataObject.IsDebugMode()) { AddDebugInputItem(OutputPath, "Output Path", dataObject.Environment, update); AddDebugInputItem(new DebugItemStaticDataParams(GetMethod(), "Method")); AddDebugInputItemUserNamePassword(dataObject.Environment, update); if (!string.IsNullOrEmpty(PrivateKeyFile)) { AddDebugInputItem(PrivateKeyFile, "Private Key File", dataObject.Environment, update); } AddDebugInputItem(FileContents, "File Contents", dataObject.Environment, update); } while (colItr.HasMoreData()) { IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker(); var writeType = GetCorrectWriteType(); Dev2PutRawOperationTO putTo = ActivityIOFactory.CreatePutRawOperationTO(writeType, TextUtils.ReplaceWorkflowNewLinesWithEnvironmentNewLines(colItr.FetchNextValue(contentItr))); IActivityIOPath opath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr), colItr.FetchNextValue(unameItr), colItr.FetchNextValue(passItr), true, colItr.FetchNextValue(privateKeyItr)); IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(opath); try { if (allErrors.HasErrors()) { outputs[0].OutputStrings.Add(null); } else { string result = broker.PutRaw(endPoint, putTo); outputs[0].OutputStrings.Add(result); } } catch (Exception e) { outputs[0].OutputStrings.Add(null); allErrors.AddError(e.Message); break; } } return(outputs); }
private CalligraphyConfig(string defaultFontAssetPath, int attrId = -1) { FontPath = defaultFontAssetPath; IsFontSet = !TextUtils.IsEmpty(defaultFontAssetPath); AttrId = attrId != -1 ? attrId : -1; }
public static string Style(this string text, Color color, int size) { return(TextUtils.TextWith(text, color, size)); }
public void setEllipsize(TextUtils.TruncateAt where) { // Ellipsize settings are not respected }
public static string Size(this string text, int size) { return(TextUtils.TextWith(text, size)); }
protected CRSMEmail CreateMessage(bool isTemplate) { var activityCache = Graph.Caches[typeof(CRSMEmail)]; var act = (CRSMEmail)activityCache.Insert(); //CRActivity act.ClassID = CRActivityClass.Email; act.Type = null; act.OwnerID = Owner; act.StartDate = PXTimeZoneInfo.Now; act.BAccountID = BAccountID; if (act.ContactID == null) { act.ContactID = ContactID; } act.RefNoteID = RefNoteID; act.ParentNoteID = ParentNoteID; //SMEmail var accountId = MailAccountId ?? MailAccountManager.DefaultMailAccountID; act.MailAccountID = accountId; var account = (EMailAccount)PXSelect <EMailAccount, Where <EMailAccount.emailAccountID, Equal <Required <EMailAccount.emailAccountID> > > > . Select(_graph, accountId); if (account != null) { act.MailFrom = $"{TextUtils.QuoteString(account.Description)} <{account.Address}>"; } if (!isTemplate) { act.MailTo = MergeAddressList(act, To, act.MailTo); act.MailCc = MergeAddressList(act, Cc, act.MailCc); act.MailBcc = MergeAddressList(act, Bcc, act.MailBcc); act.MailReply = string.IsNullOrEmpty(Reply) ? act.MailFrom : Reply; act.Subject = Subject; act.Body = BodyFormat == null || BodyFormat == EmailFormatListAttribute.Html ? CreateHtmlBody(Body) : CreateTextBody(Body); } act.IsIncome = false; act.MPStatus = MailStatusListAttribute.PreProcess; act.Format = BodyFormat ?? EmailFormatListAttribute.Html; if (AttachmentsID != null) { foreach (NoteDoc doc in PXSelect <NoteDoc, Where <NoteDoc.noteID, Equal <Required <NoteDoc.noteID> > > > .Select(Graph, AttachmentsID)) { if (doc.FileID != null && !_attachmentLinks.Contains(doc.FileID.Value)) { _attachmentLinks.Add(doc.FileID.Value); } } } if (_attachmentLinks.Count > 0) { PXNoteAttribute.SetFileNotes(activityCache, act, _attachmentLinks.ToArray()); } act = (CRSMEmail)activityCache.Update(act); return(act); }
public static string Color(this string text, Color color) { return(TextUtils.TextWith(text, color)); }
/// <summary> /// Parses ACL entry from IMAP ACL response string. /// </summary> /// <param name="aclResponseString">IMAP ACL response string.</param> /// <returns></returns> internal static IMAP_Acl Parse(string aclResponseString) { string[] args = TextUtils.SplitQuotedString(aclResponseString, ' ', true); return(new IMAP_Acl(args[1], IMAP_Utils.ACL_From_String(args[2]))); }
public static unsafe JSModuleDef module_loader(JSContext ctx, string module_name, IntPtr opaque) { // Debug.LogFormat("module_loader: {0}", module_name); var runtime = ScriptEngine.GetRuntime(ctx); var fileSystem = runtime._fileSystem; if (!fileSystem.Exists(module_name)) { JSApi.JS_ThrowReferenceError(ctx, "module not found"); return(JSModuleDef.Null); } var source = fileSystem.ReadAllBytes(module_name); var tagValue = TryReadByteCodeTagValue(source); if (tagValue == BYTECODE_COMMONJS_MODULE_TAG) { JSApi.JS_ThrowReferenceError(ctx, "commonjs module can not be loaded by import"); return(JSModuleDef.Null); } if (tagValue == BYTECODE_ES6_MODULE_TAG) { // bytecode fixed(byte *intput_ptr = source) { var modObj = JSApi.JS_ReadObject(ctx, intput_ptr + sizeof(uint), source.Length - sizeof(uint), JSApi.JS_READ_OBJ_BYTECODE); if (!modObj.IsModule()) { JSApi.JS_FreeValue(ctx, modObj); JSApi.JS_ThrowReferenceError(ctx, "unsupported module object"); return(JSModuleDef.Null); } if (JSApi.JS_ResolveModule(ctx, modObj) < 0) { // fail JSApi.JS_FreeValue(ctx, modObj); JSApi.JS_ThrowReferenceError(ctx, "module resolve failed"); return(JSModuleDef.Null); } return(_NewModuleDef(ctx, modObj, module_name)); } } // source var input_bytes = TextUtils.GetNullTerminatedBytes(source); var fn_bytes = TextUtils.GetNullTerminatedBytes(module_name); fixed(byte *input_ptr = input_bytes) fixed(byte *fn_ptr = fn_bytes) { var input_len = (size_t)(input_bytes.Length - 1); var func_val = JSApi.JS_Eval(ctx, input_ptr, input_len, fn_ptr, JSEvalFlags.JS_EVAL_TYPE_MODULE | JSEvalFlags.JS_EVAL_FLAG_COMPILE_ONLY); if (JSApi.JS_IsException(func_val)) { ctx.print_exception(); JSApi.JS_ThrowReferenceError(ctx, "module error"); return(JSModuleDef.Null); } if (func_val.IsNullish()) { JSApi.JS_ThrowReferenceError(ctx, "module is null"); return(JSModuleDef.Null); } return(_NewModuleDef(ctx, func_val, module_name)); } }
private static void ConvertInAutoMode(DocumentModifier docMdf) { var texts = SelectTexts(docMdf); if (texts == null || texts.Length == 0) { return; } // 将选择的文字按Y坐标排序 var sortedTexts = new SortedDictionary <double, Entity>(); double maxWidth = 0; foreach (var txtId in texts) { double width = 0; var txt = txtId.GetObject(OpenMode.ForRead) as Entity; if (txt is DBText) { var dt = txt as DBText; if (!sortedTexts.ContainsKey(dt.Position.Y)) { // width = dt.TextString.Length * dt.Height * dt.WidthFactor * 1.05; // 1.1 为放大系数 maxWidth = Math.Max(maxWidth, width); sortedTexts.Add(dt.Position.Y, dt); } } else if (txt is MText) { var mt = txt as MText; if (!sortedTexts.ContainsKey(mt.Location.Y)) { width = mt.ActualWidth; maxWidth = Math.Max(maxWidth, width); sortedTexts.Add(mt.Location.Y, mt); } } } var sb = new StringBuilder(); var textsUd = sortedTexts.Reverse().ToArray(); // 第一个元素的Y坐标值最大,表示在最上方 foreach (var v in textsUd) { var txt = v.Value; if (txt is DBText) { sb.Append(TextUtils.ConvertDbTextSpecialSymbols((txt as DBText).TextString) + @"\P"); } else if (txt is MText) { sb.Append((txt as MText).Contents + @"\P"); } } // var txtHeight = 0.0; var location = new Point3d(); Entity topText = textsUd[0].Value; if (topText is DBText) { var dt = (topText as DBText); txtHeight = dt.Height; location = new Point3d(dt.Position.X, dt.Position.Y + dt.Height, dt.Position.Z); } else if (topText is MText) { txtHeight = (topText as MText).TextHeight; location = (topText as MText).Location; } // 以只读方式打开块表 Open the Block table for read var acBlkTbl = docMdf.acTransaction.GetObject(docMdf.acDataBase.BlockTableId, OpenMode.ForRead) as BlockTable; // 以写方式打开模型空间块表记录 Open the Block table record Model space for write var btr = docMdf.acTransaction.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; var mTxt = new MText() { Location = location, Width = maxWidth, TextHeight = txtHeight, LineSpacingFactor = 0.85, Contents = sb.ToString(), }; // 刷格式 mTxt.SetPropertiesFrom(topText); // btr.AppendEntity(mTxt); docMdf.acTransaction.AddNewlyCreatedDBObject(mTxt, true); // 删除原来的文字 foreach (var ent in sortedTexts.Values) { ent.UpgradeOpen(); ent.Erase(true); } }
/// <summary> /// Returns the current paragraph starting from the beginning /// of the para upto where the caret is positioned /// </summary> /// <param name="paragraph">the para text</param> /// <returns>offset of the paragraph</returns> public virtual int GetParagraphAtCaret(out String paragraph) { return(TextUtils.GetParagraphAtCaret(GetText(), GetCaretPos(), out paragraph)); }
public void WriteLine(string text) => _xUnitOutputHelper.WriteLine(TextUtils.PrefixEveryLine(text, _prefix));
/// <summary> /// Works backward from the caret position looking for whitespaces /// and stops when it encounters the first non-whitespace character. /// Returns the offset of the first whitespace character behind the /// cursor and also the number of whitespace characters /// </summary> /// <param name="offset">offset of the first white space</param> /// <param name="count">number of whitespace characters</param> public virtual void GetPrecedingWhiteSpaces(out int offset, out int count) { TextUtils.GetPrecedingWhiteSpaces(GetText(), GetCaretPos(), out offset, out count); }
/// <summary> /// Parses DIGEST-MD5 challenge from challenge-string. /// </summary> /// <param name="challenge">Challenge string.</param> /// <returns>Returns DIGEST-MD5 challenge.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>challenge</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when challenge parsing + validation fails.</exception> public static AUTH_SASL_DigestMD5_Challenge Parse(string challenge) { if (challenge == null) { throw new ArgumentNullException("challenge"); } AUTH_SASL_DigestMD5_Challenge retVal = new AUTH_SASL_DigestMD5_Challenge(); string[] parameters = TextUtils.SplitQuotedString(challenge, ','); foreach (string parameter in parameters) { string[] name_value = parameter.Split(new char[] { '=' }, 2); string name = name_value[0].Trim(); if (name_value.Length == 2) { if (name.ToLower() == "realm") { retVal.m_Realm = TextUtils.UnQuoteString(name_value[1]).Split(','); } else if (name.ToLower() == "nonce") { retVal.m_Nonce = TextUtils.UnQuoteString(name_value[1]); } else if (name.ToLower() == "qop") { retVal.m_QopOptions = TextUtils.UnQuoteString(name_value[1]).Split(','); } else if (name.ToLower() == "stale") { retVal.m_Stale = Convert.ToBoolean(TextUtils.UnQuoteString(name_value[1])); } else if (name.ToLower() == "maxbuf") { retVal.m_Maxbuf = Convert.ToInt32(TextUtils.UnQuoteString(name_value[1])); } else if (name.ToLower() == "charset") { retVal.m_Charset = TextUtils.UnQuoteString(name_value[1]); } else if (name.ToLower() == "algorithm") { retVal.m_Algorithm = TextUtils.UnQuoteString(name_value[1]); } else if (name.ToLower() == "cipher-opts") { retVal.m_CipherOpts = TextUtils.UnQuoteString(name_value[1]); } //else if(name.ToLower() == "auth-param"){ // retVal.m_AuthParam = TextUtils.UnQuoteString(name_value[1]); //} } } /* Validate required fields. * Per RFC 2831 2.1.1. Only [nonce algorithm] parameters are required. */ if (string.IsNullOrEmpty(retVal.Nonce)) { throw new ParseException("The challenge-string doesn't contain required parameter 'none' value."); } if (string.IsNullOrEmpty(retVal.Algorithm)) { throw new ParseException("The challenge-string doesn't contain required parameter 'algorithm' value."); } return(retVal); }
/// <summary> /// Returns the offset to the word previous to the word /// at the caret /// </summary> /// <param name="offset">return the offset</param> /// <param name="count">length of the previous word</param> /// <returns>true on success</returns> public virtual bool GetPrevWordOffset(out int offset, out int count) { return(TextUtils.GetPrevWordOffset(GetText(), GetCaretPos(), out offset, out count)); }
public int SetText(TextLabel label, string str) { if (label == null || str == null) { return(0); } // perform this operation to match the utf32 character used in native Dali. bool previousMarkup = label.EnableMarkup; label.EnableMarkup = false; label.Text = str; pageString = label.Text; label.EnableMarkup = previousMarkup; label.MultiLine = true; label.Ellipsis = false; int length = pageString.Length; int remainLength = length; int offset = 0; int cutOffIndex = 0; // init totalPageCnt = 0; pageList = new List <PageData>(); tagList = new List <TagData>(); characterList = new List <char>(); stream = new StringReader(pageString); RendererParameters textParameters = new RendererParameters(); textParameters.Text = pageString; textParameters.HorizontalAlignment = label.HorizontalAlignment; textParameters.VerticalAlignment = label.VerticalAlignment; textParameters.FontFamily = label.FontFamily; textParameters.FontWeight = ""; textParameters.FontWidth = ""; textParameters.FontSlant = ""; textParameters.Layout = TextLayout.MultiLine; textParameters.TextColor = Color.Black; textParameters.FontSize = label.PointSize; textParameters.TextWidth = (uint)label.Size.Width; textParameters.TextHeight = (uint)label.Size.Height; textParameters.EllipsisEnabled = true; textParameters.MarkupEnabled = previousMarkup; textParameters.MinLineSize = label.MinLineSize; textParameters.Padding = label.Padding; Tizen.NUI.PropertyArray cutOffIndexArray = TextUtils.GetLastCharacterIndex(textParameters); uint count = cutOffIndexArray.Count(); for (uint i = 0; i < count; i++) { var temp = cutOffIndexArray.GetElementAt(i); temp.Get(out cutOffIndex); // Gets the last index of text shown on the actual screen. temp.Dispose(); // If markup is enabled, It should parse markup if (label.EnableMarkup) { int preOffset = offset; offset = MarkupProcess(offset, cutOffIndex - preOffset); remainLength -= (offset - preOffset); } //If markup is not enabled, parsing is not required. else { PageData pageData = new PageData(); pageData.StartOffset = offset; int cnt = (cutOffIndex - offset) < remainLength ? (cutOffIndex - offset) : remainLength; remainLength -= cnt; offset += cnt; pageData.EndOffset = offset; pageList.Add(pageData); } totalPageCnt++; if (offset <= 0 || remainLength <= 0) { break; } } textParameters.Dispose(); cutOffIndexArray.Dispose(); stream = null; return(totalPageCnt); }
/// <summary> /// Override this to get current word at caret. /// </summary> /// <param name="word">return the word</param> public virtual void GetWordAtCaret(out String word) { TextUtils.GetWordAtCaret(GetText(), GetCaretPos(), out word); }
/// <summary> /// Parses <b>address-list</b> from specified string value. /// </summary> /// <param name="value">The <b>address-list</b> string value.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when <b>value</b> is not valid <b>address-list</b> value.</exception> public static Mail_t_AddressList Parse(string value) { if (value == null) { throw new ArgumentNullException("value"); } /* RFC 5322 3.4. * address = mailbox / group * mailbox = name-addr / addr-spec * name-addr = [display-name] angle-addr * angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr * group = display-name ":" [group-list] ";" [CFWS] * display-name = phrase * mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list * address-list = (address *("," address)) / obs-addr-list * group-list = mailbox-list / CFWS / obs-group-list */ MIME_Reader r = new MIME_Reader(value); Mail_t_AddressList retVal = new Mail_t_AddressList(); while (true) { string word = r.QuotedReadToDelimiter(new char[] { ',', '<', ':' }); // We processed all data. if (word == null && r.Available == 0) { break; } // group else if (r.Peek(true) == ':') { Mail_t_Group group = new Mail_t_Group(word != null ? MIME_Encoding_EncodedWord.DecodeS(TextUtils.UnQuoteString(word)) : null); // Consume ':' r.Char(true); while (true) { word = r.QuotedReadToDelimiter(new char[] { ',', '<', ':', ';' }); // We processed all data. if ((word == null && r.Available == 0) || r.Peek(false) == ';') { break; } // In valid address list value. else if (word == string.Empty) { throw new ParseException("Invalid address-list value '" + value + "'."); } // name-addr else if (r.Peek(true) == '<') { group.Members.Add(new Mail_t_Mailbox(word != null ? MIME_Encoding_EncodedWord.DecodeS(TextUtils.UnQuoteString(word)) : null, r.ReadParenthesized())); } // addr-spec else { group.Members.Add(new Mail_t_Mailbox(null, word)); } // We reached at the end of group. if (r.Peek(true) == ';') { r.Char(true); break; } // We have more addresses. if (r.Peek(true) == ',') { r.Char(false); } } retVal.Add(group); } // name-addr else if (r.Peek(true) == '<') { retVal.Add(new Mail_t_Mailbox(word != null ? MIME_Encoding_EncodedWord.DecodeS(TextUtils.UnQuoteString(word.Trim())) : null, r.ReadParenthesized())); } // addr-spec else { retVal.Add(new Mail_t_Mailbox(null, word)); } // We have more addresses. if (r.Peek(true) == ',') { r.Char(false); } } return(retVal); }
private void cmbUpperGraphic_SelectedIndexChanged(object sender, EventArgs e) { mEditorItem.Upper.Sprite = TextUtils.SanitizeNone(cmbUpperGraphic?.Text); }
/// <summary> /// Returns this as string. /// </summary> /// <returns>Returns this as string.</returns> public override string ToString() { return("FROM " + TextUtils.QuoteString(m_Value)); }