Esempio n. 1
0
    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);
                }
            }
        }
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
        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);
        }