private string DescriptionForValidationType(ValidationType validationType) { if (this._validationTypeDescriptions.ContainsKey(validationType)) { return(this._validationTypeDescriptions[validationType]); } return(validationType.ToString()); }
public override string _0001() { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 ValidationType threadList = m_ThreadList; if (threadList == ValidationType.Pcm || threadList == ValidationType.Extensible) { return($"{m_EventInstance} bit PCM: {comparatorList / 1000}kHz {_ConsumerList} channels"); } return(m_ThreadList.ToString()); }
/// <summary> /// /// </summary> public async Task SaveLog(int appId, string content, ValidationType type, string phone, string ip, bool isSuccess, string code, int expiresMinute, string smsMsgId, string smsMsg) { var smsRecordEntity = new SmsRecordEntity { SendTime = DateTime.Now, ClientId = appId, Content = content, SendType = type.ToString(), Receiver = phone, IpAddress = ip, SendResult = isSuccess, Remark = isSuccess ? $"发送成功,msg_id:{smsMsgId}" : $"发送失败,错误描述:{smsMsg},msg_id:{smsMsgId}" }; await _smsRecordRepository.InsertAsync(smsRecordEntity); await _unitOfWork.SaveChangesAsync(); }
public static MvcHtmlString SubmitLink(this HtmlHelper helper, string title, string formId, string actionName, string controllerName, ValidationType validationType = ValidationType.All, object htmlAttributes = null, object submitParams = null) { var url = GetActionUrl(helper.ViewContext.RequestContext, actionName, controllerName); var paramsDictionary = new RouteValueDictionary(submitParams); var linkTag = GetSubmitTag("a", title, htmlAttributes); linkTag.Attributes.Add("href", "#"); if (paramsDictionary.Count > 0) { var key = paramsDictionary.GetHashCode(); var scriptTag = GetWrapperScriptTag(paramsDictionary, key); var script = String.Format("submitFormWithParams_{3}(this, event, '#{0}', '{1}', '{2}'); return false;", formId, url, validationType.ToString(), key); linkTag.Attributes.Add("onclick", script); return MvcHtmlString.Create(scriptTag.ToString(TagRenderMode.Normal) + linkTag.ToString(TagRenderMode.Normal)); } else { var script = String.Format("submitFormWithoutParams(this, event, '#{0}', '{1}', '{2}'); return false;", formId, url, validationType.ToString()); linkTag.Attributes.Add("onclick", script); return MvcHtmlString.Create(linkTag.ToString(TagRenderMode.Normal)); } }
// // Public Methods and Properties // public virtual bool Load(XmlReader rXmlReader) { //Hook up your reader as my reader _rXmlReader = rXmlReader; if (rXmlReader is XmlTextReader) { _eWhitespaceMode = ((XmlTextReader)rXmlReader).WhitespaceHandling; _fNamespaces = ((XmlTextReader)rXmlReader).Namespaces; _eValidationMode = ValidationType.None; } #pragma warning disable 0618 if (rXmlReader is XmlValidatingReader) { if (((XmlValidatingReader)rXmlReader).Reader is XmlTextReader) { _eWhitespaceMode = ((XmlTextReader)((XmlValidatingReader)rXmlReader).Reader).WhitespaceHandling; } else { _eWhitespaceMode = WhitespaceHandling.None; } _fNamespaces = ((XmlValidatingReader)rXmlReader).Namespaces; _eValidationMode = ((XmlValidatingReader)rXmlReader).ValidationType; _eEntityMode = ((XmlValidatingReader)rXmlReader).EntityHandling; } #pragma warning restore 0618 DebugTrace("Setting ValidationMode=" + _eValidationMode.ToString()); DebugTrace("Setting EntityMode=" + _eEntityMode.ToString()); DebugTrace("Setting WhitespaceMode=" + _eWhitespaceMode.ToString()); //Process the Document try { _rDocumentRootNode = new CXmlNode("", "", XmlNodeType.Element); _rDocumentRootNode._eFlags = NodeFlags.DocumentRoot | NodeFlags.Indent; Process(_rDocumentRootNode); for (_rRootNode = _rDocumentRootNode.FirstChild; _rRootNode != null && _rRootNode.NodeType != XmlNodeType.Element; _rRootNode = _rRootNode.NextNode) { ; } } catch (Exception e) { //Unhook your reader _rXmlReader = null; _strParseError = e.ToString(); if (_fThrow) { throw (e); } if (_hr == 0) { _hr = -1; } return(false); } //Unhook your reader _rXmlReader = null; return(true); }
public static void Validate <TDbEntity>(TDbEntity entity, TUnitOfWork uow, ValidationType validationType) where TDbEntity : class { if (!_isConfigured) { throw new DomainModelValidatorConfigurationException($"DomainModelValidator for {typeof(TUnitOfWork).Name} data source was not configured"); } if (entity == null) { throw new ArgumentNullException("entity", "Cannot validate null!"); } if (uow == null) { throw new ArgumentNullException("uow", $"{typeof(TUnitOfWork)} object must be sent as a parameter"); } var validationAttribute = entity.GetType().GetCustomAttribute <ValidateDomainConstraintsAttribute>(); if (validationAttribute == null) { return; } if ((validationAttribute.GetValidationType() & validationType) != validationType) { return; } if (!_isConfigured) { throw new DomainModelValidatorConfigurationException($"DomainModelValidator for {typeof(TUnitOfWork).Name} is not configured. Configure it in Configure() method"); } RulesSet <TUnitOfWork> rulesSet = null; switch (validationType) { case ValidationType.OnUpdate: rulesSet = _onUpdateRulesSet; break; case ValidationType.OnCreate: rulesSet = _onCreateRulesSet; break; case ValidationType.OnDelete: rulesSet = _onDeleteRulesSet; break; default: break; } if (rulesSet == null) { throw new RulesSetNotSpecifiedException( $"RulesSet for {validationType.ToString("g")} validation type is not specified. Reconfigure validator"); } var rule = rulesSet.GetValidationRule <TDbEntity>(); if (rule == null) { throw new ValidationRuleUnregisteredException( $"Validation rule for {typeof(TDbEntity).Name} entity ({validationType.ToString("g")} validation type) is not registered. Reconfigure validator"); } rule.ValidateRule(entity, uow); }
protected override void Render(HtmlTextWriter writer) { if (DefaultButtonID.IsNotEmpty()) { writer.AddAttribute("onkeyup", string.Format("defaultButtonClick('{0}', event)", DefaultButtonID)); } writer.AddAttribute(HtmlTextWriterAttribute.Class, string.Format("{0}{1}{2}", CssClass.IsNotEmpty() ? CssClass : string.Empty, ValidationType != eValidationType.None ? " valid-" + ValidationType.ToString().ToLower() : string.Empty, ValidationGroup.IsNotEmpty() ? " group-" + ValidationGroup : string.Empty)); base.Render(writer); }
private static MvcHtmlString SubmitButton(HtmlHelper helper, string title, string formId, string actionName, string controllerName, ValidationType validationType, object htmlAttributes, RouteValueDictionary submitParams, bool addIcon, bool isIconFirst, string iconClass, string additionalScript) { if (addIcon) { var devider = !String.IsNullOrWhiteSpace(title) ? " " : string.Empty; var iconTemplate = String.Format("<i class='{0}'></i>", iconClass); if (isIconFirst) { title = String.Format("{0}{2}{1}", iconTemplate, title, devider); } else { title = String.Format("{0}{2}{1}", title, iconTemplate, devider); } } var routes = new RouteValueDictionary(); foreach (var submitParam in submitParams) { routes.Add(submitParam.Key, submitParam.Value); } if (!routes.ContainsKey("controller")) { routes.Add("controller", controllerName); } if (!routes.ContainsKey("action")) { routes.Add("action", actionName); } var url = GetRouteUrl(helper.ViewContext.RequestContext, routes); var paramsDictionary = submitParams; var buttonTag = GetSubmitTag("button", title, htmlAttributes); buttonTag.Attributes.Add("type", "button"); if (paramsDictionary.Count > 0) { var key = paramsDictionary.GetHashCode(); var scriptTag = GetWrapperScriptTag(paramsDictionary, key); var script = String.Format("submitFormWithParams_{3}(this, event, '#{0}', '{1}', '{2}');", formId, url, validationType.ToString(), key); script = additionalScript == null ? script : String.Format("{0} {1}", additionalScript, script); buttonTag.Attributes.Add("onclick", script); return MvcHtmlString.Create(scriptTag.ToString(TagRenderMode.Normal) + buttonTag.ToString(TagRenderMode.Normal)); } else { var script = String.Format("submitFormWithoutParams(this, event, '#{0}', '{1}', '{2}');", formId, url, validationType.ToString()); script = additionalScript == null ? script : String.Format("{0} {1}", additionalScript, script); buttonTag.Attributes.Add("onclick", script); return MvcHtmlString.Create(buttonTag.ToString(TagRenderMode.Normal)); } }
protected override void Render(HtmlTextWriter writer) { if (IsWrap) { var cssClassWrapDefault = TextMode == eTextMode.Multiline ? "textarea-wrap" : "input-wrap"; writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClassWrapDefault + (CssClassWrap.IsNotEmpty() ? " " + CssClassWrap : "")); writer.RenderBeginTag(HtmlTextWriterTag.Div); } if (Placeholder.IsNotEmpty()) { writer.AddAttribute("placeholder", Placeholder); } if (DefaultButtonID.IsNotEmpty()) { writer.AddAttribute("onkeyup", string.Format("defaultButtonClick('{0}', event)", DefaultButtonID)); } if (ReadOnly) { writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly"); } if (Disabled) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } if (MaxLength != 0) { writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, MaxLength.ToString()); } writer.AddAttribute(HtmlTextWriterAttribute.Id, ID); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); writer.AddAttribute(HtmlTextWriterAttribute.Class, string.Format("{0}{1}{2}", CssClass.IsNotEmpty() ? CssClass : string.Empty, ValidationType != eValidationType.None ? " valid-" + ValidationType.ToString().ToLower() : string.Empty, ValidationGroup.IsNotEmpty() ? " group-" + ValidationGroup : string.Empty)); if (TextMode == eTextMode.Text || TextMode == eTextMode.Password) { writer.AddAttribute(HtmlTextWriterAttribute.Type, TextMode.ToString().ToLower()); } if (TextMode == eTextMode.Multiline) { writer.RenderBeginTag(HtmlTextWriterTag.Textarea); writer.Write(Text); } else { writer.AddAttribute(HtmlTextWriterAttribute.Value, Text ?? string.Empty); writer.RenderBeginTag(HtmlTextWriterTag.Input); } writer.RenderEndTag(); if (IsWrap) { writer.RenderEndTag(); } }