public MatchHandlersAndKeys( MatchHandlers <TInternal, TExternal> handlers, MatchKeySet <TInternal, TExternal, TInternalKey, TExternalKey> keySet, MatchUpdater <TInternal, TExternal> updaters) { Handlers = handlers; KeySet = keySet; Updaters = updaters; }
public TwoDirectionalIdMatch( MatchingPendingData <TInternal, TExternal> pendingData, MatchKeySet <TInternal, TExternal, TInternalKey, TExternalKey> KeySet) { this.Internal = pendingData.Internals.ToList(); this.External = pendingData.Externals.ToList(); this.intToInt = KeySet.IntToInt; this.intToExt = KeySet.IntToExt; this.extToInt = KeySet.ExtToInt; this.extToExt = KeySet.ExtToExt; this.emptyExternal = KeySet.EmptyExternal; this.emptyInternal = KeySet.EmptyInternal; result = new MatchDataContainer <TInternal, TExternal>(Internal, External); }
void PullClips(Item root) { var clips = GetYoutubeClips(); if (clips == null) { return; } var lectures = root.Subtree().OfType <VideoWrap>(); var clipHandler = new Matching.MatchItemHandler <YoutubeClip>(z => z.GetProperName(), z => z.Name, z => Process.Start(z.VideoURLFull)); var lectureHandler = new Matching.MatchItemHandler <VideoWrap>(z => z.Caption, z => z.Caption, z => { }); var updaters = new Matching.MatchUpdater <VideoWrap, YoutubeClip>( (wrap, clip) => wrap.Store <YoutubeClip>(clip), (clip, wrap) => { clip.UpdateGuid(wrap.Guid); YoutubeApisProcessor.Current.UpdateVideo(clip); }, wrap => wrap.Store <YoutubeClip>(null), clip => { clip.UpdateGuid(null); YoutubeApisProcessor.Current.UpdateVideo(clip); } ); var handlers = new Matching.MatchHandlers <VideoWrap, YoutubeClip>(lectureHandler, clipHandler); var keys = new Matching.MatchKeySet <VideoWrap, YoutubeClip, Guid?, string>( wrap => wrap.Guid, wrap => { var c = wrap.Get <YoutubeClip>(); if (c != null) { return(c.Id); } return(null); }, clip => clip.GetGuid(), clip => clip.Id, guid => !guid.HasValue, id => id == null ); var allData = new Matching.MatchHandlersAndKeys <VideoWrap, YoutubeClip, Guid?, string>(handlers, keys, updaters); Matching.MatchingAlgorithm.RunStrongAlgorithm(lectures, clips, allData); }