示例#1
0
 /// <summary>
 /// Initializes inner controls.
 /// </summary>
 private void InitializeControl()
 {
     FieldLabel.Text = ResHelper.LocalizeString(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver));
     AttributeDropDownList.Items.Add(new ListItem());
     foreach (EntityAttributeModel attributeModel in UserProfileModel.Items)
     {
         EntityAttributeValueConverterBase attributeValueConverter = AttributeValueConverterFactory.CreateConverter(attributeModel);
         if (attributeValueConverter != null && attributeValueConverter.IsCompatibleWithFormField(FieldInfo))
         {
             ListItem item = new ListItem
             {
                 Value = String.Format("{0}-{1}", GetAttributeTypeName(attributeModel), attributeModel.Name),
                 Text  = ResHelper.LocalizeString(attributeModel.DisplayName)
             };
             AttributeDropDownList.Items.Add(item);
         }
     }
     if (SourceMappingItem != null)
     {
         EntityAttributeModel attributeModel = UserProfileModel.GetAttributeModel(SourceMappingItem.AttributeName);
         if (attributeModel != null)
         {
             AttributeDropDownList.SelectedValue = String.Format("{0}-{1}", GetAttributeTypeName(attributeModel), SourceMappingItem.AttributeName);
         }
     }
 }
示例#2
0
    /// <summary>
    /// Updates the mapping depending on user selection.
    /// </summary>
    /// <param name="mapping">The mapping to update.</param>
    public void UpdateMapping(EntityMapping mapping)
    {
        string value = AttributeDropDownList.SelectedValue;

        if (!String.IsNullOrEmpty(value))
        {
            string[] tokens = value.Split('-');
            if (tokens[0] == "Attribute" || tokens[0] == "RestrictedAttribute")
            {
                string attributeName = tokens[1];
                EntityAttributeModel attributeModel = UserProfileModel.GetAttributeModel(attributeName);
                if (attributeModel != null)
                {
                    mapping.Add(attributeModel, FieldInfo, FieldScope);
                }
            }
        }
    }