Example #1
0
        void PullPlaylists(Item root)
        {
            var playLists = YoutubeApisProcessor.Current.GetAllPlaylists();
            var topics    = root.Subtree().OfType <LectureWrap>().ToList();

            var playListHandler = new Matching.MatchItemHandler <YoutubePlaylist>(
                z => z.PlaylistTitle,
                z => z.PlaylistTitle,
                z => { }
                );

            var topicHandler = new Matching.MatchItemHandler <LectureWrap>(
                z => z.Caption,
                z => z.Caption,
                z => { }
                );

            var updaters = new Matching.MatchUpdater <LectureWrap, YoutubePlaylist>(
                (wrap, list) => wrap.Store <YoutubePlaylist>(list),
                (list, wrap) => {},
                wrap => wrap.Store <YoutubePlaylist>(null),
                list => {}
                );


            Matching.MatchingAlgorithm.RunWeakAlgorithm(
                topics,
                playLists,
                new Matching.MatchHandlers <LectureWrap, YoutubePlaylist>(topicHandler, playListHandler),
                updaters);
        }
Example #2
0
 public ManualMatchItem(T item, MatchStatus status, MatchItemHandler <T> handler)
 {
     Name         = handler.Name(item);
     Open         = new RelayCommand(() => handler.Open(item));
     Caption      = handler.Caption(item);
     OriginalItem = item;
     Status       = status;
 }
Example #3
0
 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));
 }
Example #4
0
        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);
        }
Example #5
0
 public MatchHandlers(MatchItemHandler <TInternal> internalHandler, MatchItemHandler <TExternal> externalHandler)
 {
     InternalHandler = internalHandler;
     ExternalHandler = externalHandler;
 }