private FWInputElement CreateInput() { var input = new FWInputElement(Name, FWInputType.Textbox); input.AddCssClass("form-control"); input.Attributes.Add("data-thousands", CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator); input.Attributes.Add("data-decimal", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); input.Attributes.Add("data-allownegative", _allowNegative ? "true" : "false"); input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); if (IsReadOnly) { input.Attributes.Add("readonly", "readonly"); } if (_displayCurrency) { input.Attributes.Add("data-prefix", CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol); } if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.CURRENCY); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = Model.ToString(); } return(input); }
public void IsRequiredTest_WithValue() { var isReq = new IsRequired(); var result = isReq.IsValid("This has a value", "Temp"); Assert.IsTrue(result); }
public override int GetHashCode() { return(Text.GetHashCode() + IsSelected.GetHashCode() + IsRequired.GetHashCode() + (Value != null ? Value.GetHashCode() : 0)); }
public void IsRequiredTest_Empty() { var isReq = new IsRequired(); var result = isReq.IsValid("", "Temp"); Assert.IsFalse(result); }
private FWLabelElement CreateRadiobutton(string key, string value, string id) { var label = new FWLabelElement(); label.AddCssClass("m-radio"); var radiobutton = new FWRadiobuttonElement(Name) { Id = id, IsChecked = _selected.ToLower() == key.ToLower(), Value = key }; radiobutton.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); radiobutton.Attributes.Add("data-msg-required", ViewResources.Validation_Required_Selection); if (IsDisabled) { label.AddCssClass("m-radio--disabled"); radiobutton.Attributes.Add("disabled", "disabled"); } if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.CHECKED); radiobutton.DataBind = DataBind.CreateBind(); } label.Add(radiobutton); label.Add(value); label.Add(new FWSpanElement()); return(label); }
public ListViewItem ToListViewItem() { return(new ListViewItem(new [] { FieldName, IsRequired.ToString(), IsMultiField.ToString(), RangeAddress }) { Tag = this }); }
public void UpdateModel(Models.ProjectCustomAttributeType projectCustomAttributeType, Person currentPerson) { projectCustomAttributeType.ProjectCustomAttributeTypeName = ProjectCustomAttributeTypeName; projectCustomAttributeType.ProjectCustomAttributeDataTypeID = ProjectCustomAttributeDataTypeID ?? ModelObjectHelpers.NotYetAssignedID; projectCustomAttributeType.MeasurementUnitTypeID = MeasurementUnitTypeID; projectCustomAttributeType.IsRequired = IsRequired.GetValueOrDefault(); projectCustomAttributeType.ProjectCustomAttributeTypeDescription = ProjectCustomAttributeTypeDesription; projectCustomAttributeType.ApplyToAllProjectTypes = ApplyToAllProjectTypes ?? false; var projectCustomAttributeDataType = ProjectCustomAttributeDataTypeID != null ? ProjectCustomAttributeDataType.AllLookupDictionary[ProjectCustomAttributeDataTypeID.Value] : null; if (projectCustomAttributeDataType != null && projectCustomAttributeDataType.HasOptions()) { projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema = ProjectCustomAttributeTypeOptionsSchema; } else { projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema = null; } var existingProjectTypeProjectCustomAttributeTypes = projectCustomAttributeType.ProjectTypeProjectCustomAttributeTypes.ToList(); if (!projectCustomAttributeType.ApplyToAllProjectTypes) { foreach (var projectTypeJson in ProjectTypeJsonList) { if (!projectTypeJson.Selected) { var existingToDelete = existingProjectTypeProjectCustomAttributeTypes.SingleOrDefault(x => x.ProjectTypeID == projectTypeJson.ProjectTypeID); if (existingToDelete != null) { existingProjectTypeProjectCustomAttributeTypes.Remove(existingToDelete); existingToDelete.DeleteFull(HttpRequestStorage.DatabaseEntities); } } if (projectTypeJson.Selected) { if (!existingProjectTypeProjectCustomAttributeTypes.Any(x => x.ProjectTypeID == projectTypeJson.ProjectTypeID)) { var projectTypeProjectCustomAttributeType = new ProjectTypeProjectCustomAttributeType(projectTypeJson.ProjectTypeID, projectCustomAttributeType.ProjectCustomAttributeTypeID); existingProjectTypeProjectCustomAttributeTypes.Add(projectTypeProjectCustomAttributeType); } } } projectCustomAttributeType.ProjectTypeProjectCustomAttributeTypes = existingProjectTypeProjectCustomAttributeTypes; } else { existingProjectTypeProjectCustomAttributeTypes.ForEach(x => x.DeleteFull(HttpRequestStorage.DatabaseEntities)); projectCustomAttributeType.ProjectTypeProjectCustomAttributeTypes = null; } }
private FWLabelElement CreateCheckbox(string key, string value, string id) { var label = new FWLabelElement(); label.AddCssClass("m-checkbox m-checkbox--square"); var checkbox = new FWCheckboxElement(Name) { Id = TagBuilder.CreateSanitizedId(id, "_"), IsChecked = _selected.Contains(key), Value = key }; checkbox.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); checkbox.Attributes.Add("data-rule-minlength", _minimumOptions.ToString()); checkbox.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required_Min, _minimumOptions)); if (IsDisabled) { label.AddCssClass("m-checkbox--disabled"); checkbox.Attributes.Add("disabled", "disabled"); } if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.CHECKED); checkbox.DataBind = DataBind.CreateBind(); } label.Add(checkbox); label.Add(value); label.Add(new FWSpanElement()); return(label); }
public override int GetHashCode() { var hashCode = -1067145431; hashCode = hashCode * -1521134295 + base.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(CustomizedType); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FieldFormat); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Regexp); hashCode = hashCode * -1521134295 + EqualityComparer <int?> .Default.GetHashCode(MinLength); hashCode = hashCode * -1521134295 + EqualityComparer <int?> .Default.GetHashCode(MaxLength); hashCode = hashCode * -1521134295 + IsRequired.GetHashCode(); hashCode = hashCode * -1521134295 + IsFilter.GetHashCode(); hashCode = hashCode * -1521134295 + Searchable.GetHashCode(); hashCode = hashCode * -1521134295 + Multiple.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DefaultValue); hashCode = hashCode * -1521134295 + Visible.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <IList <CustomFieldPossibleValue> > .Default.GetHashCode(PossibleValues); hashCode = hashCode * -1521134295 + EqualityComparer <IList <TrackerCustomField> > .Default.GetHashCode(Trackers); hashCode = hashCode * -1521134295 + EqualityComparer <IList <CustomFieldRole> > .Default.GetHashCode(Roles); return(hashCode); }
private FWInputElement CreateDatepickerInput(FWDivElement element) { FWInputElement input = CreateInput(element); input.AddCssClass("form-control datetimepicker-input"); if (!string.IsNullOrWhiteSpace(_placeholder)) { input.Attributes.Add("placeholder", _placeholder); } input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.DATEPICKER); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = (!_hasTimePicker) ? ((DateTime)Model).ToString("yyyy-MM-dd") : ((DateTime)Model).ToString("yyyy-MM-ddTHH:mm:ss"); } if (IsReadOnly) { input.Attributes.Add("readonly", "readonly"); } return(input); }
private FWInputElement CreateInput() { var input = new FWInputElement(Name, (!_isPassword) ? FWInputType.Textbox : FWInputType.Password); input.AddCssClass("form-control"); if (!string.IsNullOrWhiteSpace(_placeholder)) { input.Attributes.Add("placeholder", _placeholder); } input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); if (IsReadOnly) { input.Attributes.Add("readonly", "readonly"); } if (IsDisabled) { input.Attributes.Add("disabled", "disabled"); } if (_maxLength > 0) { input.Attributes.Add("maxlength", _maxLength.ToString()); } if (_minLength > 0) { input.Attributes.Add("data-rule-minlength", _minLength.ToString()); input.Attributes.Add("data-msg-minlength", string.Format(ViewResources.Validation_MinLength, DisplayName, _minLength)); } if (_regexPattern != null) { input.Attributes.Add("data-rule-pattern", _regexPattern); input.Attributes.Add("data-msg-pattern", string.Format(ViewResources.Validation_Regex, DisplayName)); } if (_targetValidationField != null) { input.Attributes.Add("data-rule-passwordmatch", _targetValidationField); input.Attributes.Add("data-msg-passwordmatch", ViewResources.Validation_PasswordMismatch); } if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.VALUE); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = Model.ToString(); } return(input); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (RenderUplevel) { writer.AddAttribute("isRequired", IsRequired.ToString(CultureInfo.InvariantCulture)); writer.AddAttribute("maxLength", MaximumLength.ToString(CultureInfo.InvariantCulture)); } }
public override int GetHashCode() { int hashCode = 0; unchecked { if (ModifierType != null) { hashCode += 1000000007 * ModifierType.GetHashCode(); } hashCode += 1000000009 * IsRequired.GetHashCode(); } return(hashCode); }
public void UpdateModel(ProjectFirmaModels.Models.FundingSourceCustomAttributeType fundingSourceCustomAttributeType, FirmaSession currentFirmaSession) { fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeName = FundingSourceCustomAttributeTypeName; fundingSourceCustomAttributeType.FundingSourceCustomAttributeDataTypeID = FundingSourceCustomAttributeDataTypeID ?? ModelObjectHelpers.NotYetAssignedID; fundingSourceCustomAttributeType.MeasurementUnitTypeID = MeasurementUnitTypeID; fundingSourceCustomAttributeType.IsRequired = IsRequired.GetValueOrDefault(); fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeDescription = FundingSourceCustomAttributeTypeDesription; fundingSourceCustomAttributeType.IncludeInFundingSourceGrid = FundingSourceCustomAttributeIncludeInGridSpec; var fundingSourceCustomAttributeDataType = FundingSourceCustomAttributeDataTypeID != null ? FundingSourceCustomAttributeDataType.AllLookupDictionary[FundingSourceCustomAttributeDataTypeID.Value] : null; if (fundingSourceCustomAttributeDataType != null && fundingSourceCustomAttributeDataType.HasOptions()) { fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeOptionsSchema = FundingSourceCustomAttributeTypeOptionsSchema; } else { fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeOptionsSchema = null; } var newFundingSourceCustomAttributeTypeRoles = new List <FundingSourceCustomAttributeTypeRole>(); if (this.EditableByNormal == true) { newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.Normal.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.Edit.FundingSourceCustomAttributeTypeRolePermissionTypeID)); } if (this.EditableByProjectSteward == true) { newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.ProjectSteward.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.Edit.FundingSourceCustomAttributeTypeRolePermissionTypeID)); } if (this.ViewableByUnassigned == true) { newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.Unassigned.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.View.FundingSourceCustomAttributeTypeRolePermissionTypeID)); } if (this.ViewableByNormal == true) { newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.Normal.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.View.FundingSourceCustomAttributeTypeRolePermissionTypeID)); } if (this.ViewableByProjectSteward == true) { newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.ProjectSteward.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.View.FundingSourceCustomAttributeTypeRolePermissionTypeID)); } fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Merge(newFundingSourceCustomAttributeTypeRoles, HttpRequestStorage.DatabaseEntities.AllFundingSourceCustomAttributeTypeRoles.Local, (x, y) => x.FundingSourceCustomAttributeTypeID == y.FundingSourceCustomAttributeTypeID && x.RoleID == y.RoleID && x.FundingSourceCustomAttributeTypeRolePermissionTypeID == y.FundingSourceCustomAttributeTypeRolePermissionTypeID, HttpRequestStorage.DatabaseEntities); }
private FWSelectElement CreateSelect() { var select = new FWSelectElement(Name); select.AddCssClass("m-select2 form-control"); select.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); select.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); select.Attributes.Add("data-minimumresultsforsearch", _minimumResultsForSearch.ToString()); //Adds a width 100% to the select to make select2 pluging use all available space select.Attributes.Add("style", "width:100%"); if (IsReadOnly) { select.Attributes.Add("readonly", "readonly"); } if (_multiple) { select.Attributes.Add("multiple", "multiple"); } if (!IsRequired) { string placeholder = GetModelResource("Placeholder", out bool resourceNotFound); select.Attributes.Add("data-placeholder", resourceNotFound ? ViewResources.Select_SelectOption : placeholder); } if (DataBind) { DataBind.Add("options", $"ds{_datasourceName}", true); DataBind.Add("optionsValue", "'id'"); DataBind.Add("optionsText", "'value'"); DataBind.AddMainBind(!_multiple ? FWBindConfiguration.VALUE : FWBindConfiguration.SELECTED_OPTIONS); select.DataBind = DataBind.CreateBind(); } else if (_datasource != null) { foreach (var item in _datasource) { var isSelected = _selected != null && item.Id == _selected.ToString(); select.Add(item, isSelected); } } select.Attributes.Add("data-allowclear", _allowClear.ToString().ToLower()); return(select); }
public void Should_be_able_to_Clone_a_validation_results_from_an_other_validation_results() { var isRequired = new IsRequired<TestViewModel>(x => x.Valid_Email); var validationResultsSource = new ValidationResults<TestViewModel>(); validationResultsSource.AddInvalidField("test", isRequired); var validationResultsTarget = new ValidationResults<TestViewModel>(); validationResultsTarget.CloneFrom(validationResultsSource); validationResultsTarget.GetInvalidFields().Count().ShouldEqual(1); validationResultsTarget.GetInvalidFields().First().ShouldEqual("test"); validationResultsTarget.GetBrokenRulesFor("test").Count().ShouldEqual(1); validationResultsTarget.GetBrokenRulesFor("test").First().PropertyFilter.ShouldEqual(isRequired.PropertyFilter); }
public void Should_be_able_to_Clone_a_validation_results_from_an_other_different_validation_results() { var isRequired = new IsRequired <TestViewModel1>(x => x.Valid_Email); var validationResultsSource = new ValidationResults <TestViewModel1>(); validationResultsSource.AddInvalidField("test", isRequired); var validationResultsTarget = new ValidationResults <TestViewModel>(); validationResultsTarget.CloneFrom(validationResultsSource); validationResultsTarget.GetInvalidFields().Count().ShouldEqual(1); validationResultsTarget.GetInvalidFields().First().ShouldEqual("test"); validationResultsTarget.GetBrokenRulesFor("test").Count().ShouldEqual(1); validationResultsTarget.GetBrokenRulesFor("test").First().PropertyFilter.ShouldEqual(isRequired.PropertyFilter); }
protected override void InternalSerializeToXml(XmlProxy xmlRoot) { var xmlEmitDefaultValue = xmlRoot.AddChild("emitDefaultValue"); EmitDefaultValue.SerializeToXml(xmlEmitDefaultValue); //xmlRoot.AddAttribute("emitDefaultValue", EmitDefaultValue); var xmlIsRequired = xmlRoot.AddChild("isRequired"); IsRequired.SerializeToXml(xmlIsRequired); //xmlRoot.AddAttribute("isRequired", IsRequired); var xmlOrder = xmlRoot.AddChild("order"); Order.SerializeToXml(xmlOrder); //xmlRoot.AddAttribute("order", Order); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (IsRequired != null) { hashCode = hashCode * 59 + IsRequired.GetHashCode(); } if (Validators != null) { hashCode = hashCode * 59 + Validators.GetHashCode(); } return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IsRequired.GetHashCode(); hashCode = (hashCode * 397) ^ Size.GetHashCode(); hashCode = (hashCode * 397) ^ ShowTime.GetHashCode(); hashCode = (hashCode * 397) ^ IsHtml.GetHashCode(); hashCode = (hashCode * 397) ^ IsIpAddress.GetHashCode(); hashCode = (hashCode * 397) ^ (ImageSource != null ? ImageSource.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Separator != null ? Separator.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (References != null ? References.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IsReference.GetHashCode(); hashCode = (hashCode * 397) ^ (Alias != null ? Alias.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Format != null ? Format.GetHashCode() : 0); return(hashCode); } }
private string LoadJson() { StringBuilder sb = new StringBuilder(); sb.Append("\"IsPrimary\":" + IsPrimary.ToString().ToLower() + ""); sb.Append(",\"IsAssociation\":" + IsAssociation.ToString().ToLower() + ""); Type eType = DataType.GetEntityType(); sb.Append(",\"Association\":{" + ((IsAssociation && eType != null) ? ( "\"FullName\":\"" + eType.FullName + "\"" + ",\"Type\":\"" + eType.Name + "\"" + ",\"Namespace\":\"" + eType.Namespace + "\"" ) : string.Empty) + "}"); sb.Append(",\"IsRequired\":" + IsRequired.ToString().ToLower() + ""); sb.Append(",\"IsSortable\":" + IsSortable.ToString().ToLower() + ""); sb.Append("," + base.Json); return(sb.ToString()); }
public void UpdateModel(Models.CustomAttributeType customAttributeType, Person currentPerson) { customAttributeType.CustomAttributeTypeName = CustomAttributeTypeName; customAttributeType.CustomAttributeDataTypeID = CustomAttributeDataTypeID.Value; customAttributeType.MeasurementUnitTypeID = MeasurementUnitTypeID; customAttributeType.IsRequired = IsRequired.GetValueOrDefault(); customAttributeType.CustomAttributeTypePurposeID = CustomAttributeTypePurposeID.GetValueOrDefault(); customAttributeType.CustomAttributeTypeDescription = CustomAttributeTypeDesription; var customAttributeDataType = CustomAttributeDataType.AllLookupDictionary[CustomAttributeDataTypeID.Value]; if (customAttributeDataType.HasOptions()) { customAttributeType.CustomAttributeTypeOptionsSchema = CustomAttributeTypeOptionsSchema; } else { customAttributeType.CustomAttributeTypeOptionsSchema = null; } }
/// <summary> /// Returns true if PaymentProductFieldDataRestrictions instances are equal /// </summary> /// <param name="other">Instance of PaymentProductFieldDataRestrictions to be compared</param> /// <returns>Boolean</returns> public bool Equals(PaymentProductFieldDataRestrictions other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( IsRequired == other.IsRequired || IsRequired != null && IsRequired.Equals(other.IsRequired) ) && ( Validators == other.Validators || Validators != null && Validators.Equals(other.Validators) )); }
/// <summary> /// LUA结构支持 /// </summary> /// <returns></returns> public override void GetLuaStruct(StringBuilder code) { base.GetLuaStruct(code); int idx; if (!string.IsNullOrWhiteSpace(PropertyName)) { code.AppendLine($@"['PropertyName'] = '{PropertyName.ToLuaString()}',"); } else { code.AppendLine($@"['PropertyName'] = nil,"); } code.AppendLine($@"['IsCaption'] ={(IsCaption.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Alias)) { code.AppendLine($@"['Alias'] = '{Alias.ToLuaString()}',"); } else { code.AppendLine($@"['Alias'] = nil,"); } if (!string.IsNullOrWhiteSpace(Group)) { code.AppendLine($@"['Group'] = '{Group.ToLuaString()}',"); } else { code.AppendLine($@"['Group'] = nil,"); } code.AppendLine($@"['CreateIndex'] ={(CreateIndex.ToString().ToLower())},"); code.AppendLine($@"['IsPrimaryKey'] ={(IsPrimaryKey.ToString().ToLower())},"); code.AppendLine($@"['IsExtendKey'] ={(IsExtendKey.ToString().ToLower())},"); code.AppendLine($@"['IsIdentity'] ={(IsIdentity.ToString().ToLower())},"); code.AppendLine($@"['IsGlobalKey'] ={(IsGlobalKey.ToString().ToLower())},"); code.AppendLine($@"['UniqueIndex'] ={UniqueIndex},"); code.AppendLine($@"['IsRequired'] ={(IsRequired.ToString().ToLower())},"); code.AppendLine($@"['IsUserReadOnly'] ={(IsUserReadOnly.ToString().ToLower())},"); code.AppendLine($@"['IsMemo'] ={(IsMemo.ToString().ToLower())},"); code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Prefix)) { code.AppendLine($@"['Prefix'] = '{Prefix.ToLuaString()}',"); } else { code.AppendLine($@"['Prefix'] = nil,"); } if (!string.IsNullOrWhiteSpace(Suffix)) { code.AppendLine($@"['Suffix'] = '{Suffix.ToLuaString()}',"); } else { code.AppendLine($@"['Suffix'] = nil,"); } if (!string.IsNullOrWhiteSpace(InputType)) { code.AppendLine($@"['InputType'] = '{InputType.ToLuaString()}',"); } else { code.AppendLine($@"['InputType'] = nil,"); } if (!string.IsNullOrWhiteSpace(ComboBoxUrl)) { code.AppendLine($@"['ComboBoxUrl'] = '{ComboBoxUrl.ToLuaString()}',"); } else { code.AppendLine($@"['ComboBoxUrl'] = nil,"); } code.AppendLine($@"['IsMoney'] ={(IsMoney.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(GridAlign)) { code.AppendLine($@"['GridAlign'] = '{GridAlign.ToLuaString()}',"); } else { code.AppendLine($@"['GridAlign'] = nil,"); } if (!string.IsNullOrWhiteSpace(DataFormater)) { code.AppendLine($@"['DataFormater'] = '{DataFormater.ToLuaString()}',"); } else { code.AppendLine($@"['DataFormater'] = nil,"); } code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},"); code.AppendLine($@"['GridDetails'] ={(GridDetails.ToString().ToLower())},"); code.AppendLine($@"['NoneGrid'] ={(NoneGrid.ToString().ToLower())},"); code.AppendLine($@"['NoneDetails'] ={(NoneDetails.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(GridDetailsCode)) { code.AppendLine($@"['GridDetailsCode'] = '{GridDetailsCode.ToLuaString()}',"); } else { code.AppendLine($@"['GridDetailsCode'] = nil,"); } if (!string.IsNullOrWhiteSpace(CppType)) { code.AppendLine($@"['CppType'] = '{CppType.ToLuaString()}',"); } else { code.AppendLine($@"['CppType'] = nil,"); } if (CppTypeObject != null) { code.AppendLine($@"['CppTypeObject'] ='{CppTypeObject}',"); } if (!string.IsNullOrWhiteSpace(CppName)) { code.AppendLine($@"['CppName'] = '{CppName.ToLuaString()}',"); } else { code.AppendLine($@"['CppName'] = nil,"); } if (!string.IsNullOrWhiteSpace(CppLastType)) { code.AppendLine($@"['CppLastType'] = '{CppLastType.ToLuaString()}',"); } else { code.AppendLine($@"['CppLastType'] = nil,"); } code.AppendLine($@"['IsIntDecimal'] ={(IsIntDecimal.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(CsType)) { code.AppendLine($@"['CsType'] = '{CsType.ToLuaString()}',"); } else { code.AppendLine($@"['CsType'] = nil,"); } if (!string.IsNullOrWhiteSpace(CustomType)) { code.AppendLine($@"['CustomType'] = '{CustomType.ToLuaString()}',"); } else { code.AppendLine($@"['CustomType'] = nil,"); } if (!string.IsNullOrWhiteSpace(LastCsType)) { code.AppendLine($@"['LastCsType'] = '{LastCsType.ToLuaString()}',"); } else { code.AppendLine($@"['LastCsType'] = nil,"); } if (EnumConfig != null) { code.AppendLine($@"['EnumConfig'] = {EnumConfig.GetLuaStruct()},"); } code.AppendLine($@"['IsCompute'] ={(IsCompute.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ComputeGetCode)) { code.AppendLine($@"['ComputeGetCode'] = '{ComputeGetCode.ToLuaString()}',"); } else { code.AppendLine($@"['ComputeGetCode'] = nil,"); } if (!string.IsNullOrWhiteSpace(ComputeSetCode)) { code.AppendLine($@"['ComputeSetCode'] = '{ComputeSetCode.ToLuaString()}',"); } else { code.AppendLine($@"['ComputeSetCode'] = nil,"); } code.AppendLine($@"['IsMiddleField'] ={(IsMiddleField.ToString().ToLower())},"); code.AppendLine($@"['InnerField'] ={(InnerField.ToString().ToLower())},"); code.AppendLine($@"['IsSystemField'] ={(IsSystemField.ToString().ToLower())},"); code.AppendLine($@"['IsInterfaceField'] ={(IsInterfaceField.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Initialization)) { code.AppendLine($@"['Initialization'] = '{Initialization.ToLuaString()}',"); } else { code.AppendLine($@"['Initialization'] = nil,"); } if (!string.IsNullOrWhiteSpace(EmptyValue)) { code.AppendLine($@"['EmptyValue'] = '{EmptyValue.ToLuaString()}',"); } else { code.AppendLine($@"['EmptyValue'] = nil,"); } code.AppendLine($@"['DenyScope'] ='{DenyScope}',"); code.AppendLine($@"['Nullable'] ={(Nullable.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Max)) { code.AppendLine($@"['Max'] = '{Max.ToLuaString()}',"); } else { code.AppendLine($@"['Max'] = nil,"); } if (!string.IsNullOrWhiteSpace(Min)) { code.AppendLine($@"['Min'] = '{Min.ToLuaString()}',"); } else { code.AppendLine($@"['Min'] = nil,"); } code.AppendLine($@"['UniqueString'] ={(UniqueString.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ColumnName)) { code.AppendLine($@"['ColumnName'] = '{ColumnName.ToLuaString()}',"); } else { code.AppendLine($@"['ColumnName'] = nil,"); } code.AppendLine($@"['DbNullable'] ={(DbNullable.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(DbType)) { code.AppendLine($@"['DbType'] = '{DbType.ToLuaString()}',"); } else { code.AppendLine($@"['DbType'] = nil,"); } code.AppendLine($@"['Precision'] ={Datalen},"); if (!string.IsNullOrWhiteSpace(ArrayLen)) { code.AppendLine($@"['ArrayLen'] = '{ArrayLen.ToLuaString()}',"); } else { code.AppendLine($@"['ArrayLen'] = nil,"); } code.AppendLine($@"['Scale'] ={Scale},"); code.AppendLine($@"['DbIndex'] ={DbIndex},"); code.AppendLine($@"['Unicode'] ={(Unicode.ToString().ToLower())},"); code.AppendLine($@"['FixedLength'] ={(FixedLength.ToString().ToLower())},"); code.AppendLine($@"['IsBlob'] ={(IsBlob.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(StorageProperty)) { code.AppendLine($@"['StorageProperty'] = '{StorageProperty.ToLuaString()}',"); } else { code.AppendLine($@"['StorageProperty'] = nil,"); } code.AppendLine($@"['DbInnerField'] ={(DbInnerField.ToString().ToLower())},"); code.AppendLine($@"['NoStorage'] ={(NoStorage.ToString().ToLower())},"); code.AppendLine($@"['KeepStorageScreen'] ='{KeepStorageScreen}',"); code.AppendLine($@"['CustomWrite'] ={(CustomWrite.ToString().ToLower())},"); code.AppendLine($@"['IsLinkField'] ={(IsLinkField.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(LinkTable)) { code.AppendLine($@"['LinkTable'] = '{LinkTable.ToLuaString()}',"); } else { code.AppendLine($@"['LinkTable'] = nil,"); } code.AppendLine($@"['IsLinkKey'] ={(IsLinkKey.ToString().ToLower())},"); code.AppendLine($@"['IsLinkCaption'] ={(IsLinkCaption.ToString().ToLower())},"); code.AppendLine($@"['IsUserId'] ={(IsUserId.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(LinkField)) { code.AppendLine($@"['LinkField'] = '{LinkField.ToLuaString()}',"); } else { code.AppendLine($@"['LinkField'] = nil,"); } code.AppendLine($@"['IsCustomCompute'] ={(IsCustomCompute.ToString().ToLower())},"); code.AppendLine($@"['CanGet'] ={(CanGet.ToString().ToLower())},"); code.AppendLine($@"['CanSet'] ={(CanSet.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(AccessType)) { code.AppendLine($@"['AccessType'] = '{AccessType.ToLuaString()}',"); } else { code.AppendLine($@"['AccessType'] = nil,"); } code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},"); code.AppendLine($@"['CanInput'] ={(CanUserInput.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ExtendRole)) { code.AppendLine($@"['ExtendRole'] = '{ExtendRole.ToLuaString()}',"); } else { code.AppendLine($@"['ExtendRole'] = nil,"); } if (!string.IsNullOrWhiteSpace(ValueSeparate)) { code.AppendLine($@"['ValueSeparate'] = '{ValueSeparate.ToLuaString()}',"); } else { code.AppendLine($@"['ValueSeparate'] = nil,"); } if (!string.IsNullOrWhiteSpace(ArraySeparate)) { code.AppendLine($@"['ArraySeparate'] = '{ArraySeparate.ToLuaString()}',"); } else { code.AppendLine($@"['ArraySeparate'] = nil,"); } code.AppendLine($@"['ExtendArray'] ={(ExtendArray.ToString().ToLower())},"); code.AppendLine($@"['IsKeyValueArray'] ={(IsKeyValueArray.ToString().ToLower())},"); code.AppendLine($@"['IsRelation'] ={(IsRelation.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ExtendPropertyName)) { code.AppendLine($@"['ExtendPropertyName'] = '{ExtendPropertyName.ToLuaString()}',"); } else { code.AppendLine($@"['ExtendPropertyName'] = nil,"); } if (!string.IsNullOrWhiteSpace(ExtendClassName)) { code.AppendLine($@"['ExtendClassName'] = '{ExtendClassName.ToLuaString()}',"); } else { code.AppendLine($@"['ExtendClassName'] = nil,"); } code.AppendLine($@"['ExtendClassIsPredestinate'] ={(ExtendClassIsPredestinate.ToString().ToLower())},"); code.AppendLine($@"['IsRelationField'] ={(IsRelationField.ToString().ToLower())},"); code.AppendLine($@"['IsRelationValue'] ={(IsRelationValue.ToString().ToLower())},"); code.AppendLine($@"['IsRelationArray'] ={(IsRelationArray.ToString().ToLower())},"); code.AppendLine($@"['IsExtendArray'] ={(IsExtendArray.ToString().ToLower())},"); code.AppendLine($@"['IsExtendValue'] ={(IsExtendValue.ToString().ToLower())},"); }
/// <summary> /// Determines whether the specified Object is equal to the current Object. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(false); } if (Object.ReferenceEquals(this, obj)) { return(true); } if (this.GetType() != obj.GetType()) { return(false); } var other = (VLLibraryQuestion)obj; //reference types if (!Object.Equals(ValidationField1, other.ValidationField1)) { return(false); } if (!Object.Equals(ValidationField2, other.ValidationField2)) { return(false); } if (!Object.Equals(ValidationField3, other.ValidationField3)) { return(false); } if (!Object.Equals(RegularExpression, other.RegularExpression)) { return(false); } if (!Object.Equals(QuestionText, other.QuestionText)) { return(false); } if (!Object.Equals(Description, other.Description)) { return(false); } if (!Object.Equals(HelpText, other.HelpText)) { return(false); } if (!Object.Equals(FrontLabelText, other.FrontLabelText)) { return(false); } if (!Object.Equals(AfterLabelText, other.AfterLabelText)) { return(false); } if (!Object.Equals(InsideText, other.InsideText)) { return(false); } if (!Object.Equals(RequiredMessage, other.RequiredMessage)) { return(false); } if (!Object.Equals(ValidationMessage, other.ValidationMessage)) { return(false); } if (!Object.Equals(OtherFieldLabel, other.OtherFieldLabel)) { return(false); } //value types if (!QuestionId.Equals(other.QuestionId)) { return(false); } if (!m_category.Equals(other.m_category)) { return(false); } if (!QuestionType.Equals(other.QuestionType)) { return(false); } if (!IsRequired.Equals(other.IsRequired)) { return(false); } if (!RequiredBehavior.Equals(other.RequiredBehavior)) { return(false); } if (!RequiredMinLimit.Equals(other.RequiredMinLimit)) { return(false); } if (!RequiredMaxLimit.Equals(other.RequiredMaxLimit)) { return(false); } if (!AttributeFlags.Equals(other.AttributeFlags)) { return(false); } if (!ValidationBehavior.Equals(other.ValidationBehavior)) { return(false); } if (!RandomBehavior.Equals(other.RandomBehavior)) { return(false); } if (!OtherFieldType.Equals(other.OtherFieldType)) { return(false); } if (!OtherFieldRows.Equals(other.OtherFieldRows)) { return(false); } if (!OtherFieldChars.Equals(other.OtherFieldChars)) { return(false); } if (!OptionsSequence.Equals(other.OptionsSequence)) { return(false); } if (!ColumnsSequence.Equals(other.ColumnsSequence)) { return(false); } if (!RangeStart.Equals(other.RangeStart)) { return(false); } if (!RangeEnd.Equals(other.RangeEnd)) { return(false); } return(true); }
/// <summary> /// Return a serialized string of values for the pre value editor model /// </summary> /// <returns></returns> public override string GetSerializedValue() { var xml = new XElement("preValues", new XElement("preValue", new XAttribute("name", "Type"), new XCData(Type.ToString())), new XElement("preValue", new XAttribute("name", "IsRequired"), new XCData(IsRequired.ToString()))); return(xml.ToString()); }
public void UpdateModel(ProjectFirmaModels.Models.ProjectCustomAttributeType projectCustomAttributeType, FirmaSession currentFirmaSession) { projectCustomAttributeType.ProjectCustomAttributeTypeName = ProjectCustomAttributeTypeName; projectCustomAttributeType.ProjectCustomAttributeDataTypeID = ProjectCustomAttributeDataTypeID ?? ModelObjectHelpers.NotYetAssignedID; projectCustomAttributeType.MeasurementUnitTypeID = MeasurementUnitTypeID; projectCustomAttributeType.IsRequired = IsRequired.GetValueOrDefault(); projectCustomAttributeType.ProjectCustomAttributeTypeDescription = ProjectCustomAttributeTypeDesription; projectCustomAttributeType.IsViewableOnFactSheet = IsViewableOnFactSheet.GetValueOrDefault(); projectCustomAttributeType.ProjectCustomAttributeGroupID = ProjectCustomAttributeGroupID; var projectCustomAttributeDataType = ProjectCustomAttributeDataTypeID != null ? ProjectCustomAttributeDataType.AllLookupDictionary[ProjectCustomAttributeDataTypeID.Value] : null; if (projectCustomAttributeDataType != null && projectCustomAttributeDataType.HasOptions()) { projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema = ProjectCustomAttributeTypeOptionsSchema; } else { projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema = null; } var newProjectCustomAttributeTypeRoles = new List <ProjectCustomAttributeTypeRole>(); if (EditableByNormal) { newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.Edit.ProjectCustomAttributeTypeRolePermissionTypeID) { RoleID = ProjectFirmaModels.Models.Role.Normal.RoleID }); } if (EditableByProjectSteward) { newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.Edit.ProjectCustomAttributeTypeRolePermissionTypeID) { RoleID = ProjectFirmaModels.Models.Role.ProjectSteward.RoleID }); } if (ViewableByUnassigned) { newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID) { RoleID = ProjectFirmaModels.Models.Role.Unassigned.RoleID }); } if (ViewableByNormal) { newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID) { RoleID = ProjectFirmaModels.Models.Role.Normal.RoleID }); } if (ViewableByProjectSteward) { newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID) { RoleID = ProjectFirmaModels.Models.Role.ProjectSteward.RoleID }); } if (ViewableByAnonymous) { newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID)); } projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Merge(newProjectCustomAttributeTypeRoles, HttpRequestStorage.DatabaseEntities.AllProjectCustomAttributeTypeRoles.Local, (x, y) => x.ProjectCustomAttributeTypeID == y.ProjectCustomAttributeTypeID && x.RoleID == y.RoleID && x.ProjectCustomAttributeTypeRolePermissionTypeID == y.ProjectCustomAttributeTypeRolePermissionTypeID, HttpRequestStorage.DatabaseEntities); }