public NameMatch(MatchingPendingData <TInternal, TExternal> pendingData, MatchHandlers <TInternal, TExternal> handlers) { this.internals = pendingData.Internals.ToArray(); this.externals = pendingData.Externals.ToArray(); this.internalSelector = handlers.InternalHandler.Name; this.externalSelector = handlers.ExternalHandler.Name; result = new MatchDataContainer <TInternal, TExternal>(internals, externals); }
public MatchHandlersAndKeys( MatchHandlers <TInternal, TExternal> handlers, MatchKeySet <TInternal, TExternal, TInternalKey, TExternalKey> keySet, MatchUpdater <TInternal, TExternal> updaters) { Handlers = handlers; KeySet = keySet; Updaters = updaters; }
public ManualMatchViewModel(MatchHandlers <TInternal, TExternal> handlers) { this.InternalHandler = handlers.InternalHandler; this.ExternalHandler = handlers.ExternalHandler; UnmatchedInternals = new ObservableCollection <ManualMatchItem <TInternal> >(); UnmatchedExternals = new ObservableCollection <ManualMatchItem <TExternal> >(); Matched = new ObservableCollection <ManualMatchedPair <TInternal, TExternal> >(); MakeMatchCommand = new RelayCommand(MakeMatch, () => SelectedInternal != null && SelectedExternal != null); SortByNameCommand = new RelayCommand(() => Sort(z => z.Internal.Name)); SortByDistanceCommand = new RelayCommand(() => Sort(z => z.Distance)); SortByStatusCommand = new RelayCommand(() => Sort(z => (z.Internal.Status == MatchStatus.NewMatch || z.External.Status == MatchStatus.NewMatch) ? 0 : 1)); }
public static void RunWeakAlgorithm <TInternal, TExternal>( IEnumerable <TInternal> internals, IEnumerable <TExternal> externals, MatchHandlers <TInternal, TExternal> handlers, MatchUpdater <TInternal, TExternal> updates) { var pendingData = new MatchingPendingData <TInternal, TExternal>(internals, externals); var nameMatch = new NameMatch <TInternal, TExternal>(pendingData, handlers); var nameMatchResult = nameMatch.Run(); var model = new ManualMatchViewModel <TInternal, TExternal>(handlers); model.Pull(nameMatchResult); model.Pull(nameMatchResult.GetPendingData()); model.Push(updates); }
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); }