private void ChooseDefaultSource() { if (SourceMappingItem != null) { switch (SourceMappingItem.SourceType) { case MappingItemSourceTypeEnum.Field: SourceDropDownList.SelectedValue = String.Format("Field-{0}", SourceMappingItem.SourceName); break; case MappingItemSourceTypeEnum.MetaField: SourceDropDownList.SelectedValue = String.Format("MetaField-{0}", SourceMappingItem.SourceName); break; case MappingItemSourceTypeEnum.PicklistEntry: SourceDropDownList.SelectedValue = String.Format("PicklistEntry-{0}", SourceMappingItem.SourceName); break; } } if (String.IsNullOrEmpty(SourceDropDownList.SelectedValue)) { if (EntityAttributeModel.Type == EntityAttributeValueType.Picklist || EntityAttributeModel.Type == EntityAttributeValueType.MultiPicklist) { PicklistEntry defaultEntry = EntityAttributeModel.PicklistEntries.FirstOrDefault(x => x.IsActive && x.IsDefault); if (defaultEntry != null) { SourceDropDownList.SelectedValue = String.Format("PicklistEntry-{0}", defaultEntry.Value); } } } }
private MappingItem GetMappingItem() { string name = SourceDropDownList.SelectedValue; if (!String.IsNullOrEmpty(name)) { if (name.StartsWithCSafe("Field-")) { name = name.Remove(0, "Field-".Length); FormFieldInfo fieldInfo = FormInfo.GetFormField(name); if (fieldInfo != null) { return(new MappingItem(EntityAttributeModel, name, ResHelper.LocalizeString(fieldInfo.GetDisplayName(MacroContext.CurrentResolver)), MappingItemSourceTypeEnum.Field)); } } else if (name.StartsWithCSafe("MetaField-")) { name = name.Remove(0, "MetaField-".Length); switch (name) { case "CompanyName": return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.companyname"), MappingItemSourceTypeEnum.MetaField)); case "Description": return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.description"), MappingItemSourceTypeEnum.MetaField)); case "Country": return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.country"), MappingItemSourceTypeEnum.MetaField)); case "State": return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.state"), MappingItemSourceTypeEnum.MetaField)); } } else if (name.StartsWithCSafe("PicklistEntry-")) { name = name.Remove(0, "PicklistEntry-".Length); PicklistEntry entry = EntityAttributeModel.PicklistEntries.SingleOrDefault(x => x.IsActive && x.Value == name); if (entry != null) { return(new MappingItem(EntityAttributeModel, name, entry.Label, MappingItemSourceTypeEnum.PicklistEntry)); } } } return(null); }
public void PicklistEntryClass_Properties_TestGetterAndSetter() { // Arrange var testEntity = new PicklistEntry(); var privateObject = new PrivateObject(testEntity); var propertiesDictionary = new Dictionary <string, object>() { ["active"] = true, ["defaultValue"] = true, ["label"] = DummyString, ["validFor"] = new byte[] { }, ["value"] = DummyString, }; // Act SetProperties(privateObject, propertiesDictionary); // Assert AssertProperties(privateObject, propertiesDictionary); }