private Either <ProcessFailedResult, MetadataResult <TEmbyItem> > SetIdentity(ISourceData librarySourceData, MetadataResult <TEmbyItem> target, IPropertyMappingCollection propertyMappings, SourceName librarySourceName, ProcessResultContext resultContext) { return(SetIndexes(librarySourceData, target) .Bind(r => SetName(librarySourceData.Data, r, propertyMappings, librarySourceName, resultContext))); }
private Either <ProcessFailedResult, MetadataResult <TEmbyItem> > SetName(object source, MetadataResult <TEmbyItem> target, IPropertyMappingCollection propertyMappings, SourceName librarySourceName, ProcessResultContext resultContext) { return(Option <IPropertyMapping> .Some(propertyMappings.FirstOrDefault(m => m.CanApply(source, target) && m.TargetPropertyName == nameof(target.Item.Name))) .Map(m => { m.Apply(source, target); return target; }) .ToEither(resultContext.Failed("No value for Name property mapped from library source"))); }