public WithField ( string fieldName ) : |
||
fieldName | string | |
return |
public void Merge(XElement source, ContentPartDefinitionBuilder builder) { builder.Named(XmlConvert.DecodeName(source.Name.LocalName)); foreach (var setting in _settingsReader.Map(source)) { builder.WithSetting(setting.Key, setting.Value); } foreach (var iter in source.Elements()) { var fieldElement = iter; var fieldParameters = XmlConvert.DecodeName(fieldElement.Name.LocalName).Split(new[] { '.' }, 2); var fieldName = fieldParameters.FirstOrDefault(); var fieldType = fieldParameters.Skip(1).FirstOrDefault(); if (fieldName == "remove") { var nameAttribute = fieldElement.Attribute("name"); if (nameAttribute != null) { builder.RemoveField(nameAttribute.Value); } } else { builder.WithField( fieldName, fieldBuilder => { fieldBuilder.OfType(fieldType); foreach (var setting in _settingsReader.Map(fieldElement)) { fieldBuilder.WithSetting(setting.Key, setting.Value); } }); } } }
/// <summary> /// Merges a given content part definition provided in a XML format into a content part definition builder. /// </summary> /// <param name="element">The XML content type definition.</param> /// <param name="contentPartDefinitionBuilder">The content part definition builder.</param> public void Merge(XElement element, ContentPartDefinitionBuilder contentPartDefinitionBuilder) { Argument.ThrowIfNull(element, "element"); Argument.ThrowIfNull(contentPartDefinitionBuilder, "contentPartDefinitionBuilder"); // Merge name contentPartDefinitionBuilder.Named(XmlConvert.DecodeName(element.Name.LocalName)); // Merge settings foreach (var setting in _settingsFormatter.Map(element)) { contentPartDefinitionBuilder.WithSetting(setting.Key, setting.Value); } // Merge fields foreach (var iter in element.Elements()) { var fieldElement = iter; var fieldParameters = XmlConvert.DecodeName(fieldElement.Name.LocalName).Split(new[] { '.' }, 2); var fieldName = fieldParameters.FirstOrDefault(); var fieldType = fieldParameters.Skip(1).FirstOrDefault(); if (fieldName == "remove") { var nameAttribute = fieldElement.Attribute("name"); if (nameAttribute != null) { contentPartDefinitionBuilder.RemoveField(nameAttribute.Value); } } else { contentPartDefinitionBuilder.WithField( fieldName, fieldBuilder => { fieldBuilder.OfType(fieldType); foreach (var setting in _settingsFormatter.Map(fieldElement)) { fieldBuilder.WithSetting(setting.Key, setting.Value); } }); } } }