Created
March 31, 2017 09:04
-
-
Save Dheer-Rajpoot/4c5abc789f93cc5404714cf178fa51ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class XMLElementValueAccessorConverter : ValueAccessorConverter | |
{ | |
//the id from the value accessor template you created named XML Element Value Accessor. | |
private static readonly Guid TemplateId = Guid.Parse("{9B88A6C5-C38E-4A41-9798-17AC92F3BD20}"); | |
public XMLElementValueAccessorConverter(IItemModelRepository repository) : base(repository) | |
{ | |
this.SupportedTemplateIds.Add(TemplateId); | |
} | |
public override IValueAccessor Convert(ItemModel source) | |
{ | |
var accessor = base.Convert(source); | |
if (accessor == null) | |
{ | |
return null; | |
} | |
var elementName = base.GetStringValue(source, XMLElementValueAccessorItemModel.ElementName); | |
if (String.IsNullOrEmpty(elementName)) | |
{ | |
return null; | |
} | |
if (accessor.ValueReader == null) | |
{ | |
accessor.ValueReader = new XMLElementValueReader(elementName); | |
} | |
if (accessor.ValueWriter == null) | |
{ | |
accessor.ValueWriter = new PropertyValueWriter(elementName); | |
} | |
return accessor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment