コード例 #1
0
        public void Execute(CelebFinderContext context)
        {
            var resource = context.WikipediaUrl.Substring(context.WikipediaUrl.LastIndexOf('/') + 1);
            var type = _typesRepository.GetResourceType(resource);

            if (string.IsNullOrEmpty(type))
                throw new InvalidCelebrityException(string.Format("The celeb {0} is not a valid type", context.Name));

            context.Celebrity = new Celebrity {Type = type};
        }
コード例 #2
0
        public void Execute(CelebFinderContext context)
        {
            const string appId = "AnAkWUfV34G9T5uEFFZ6ffBa6wWhoaFdyVFGOWnBVA9L4zW4OsR1aSJVPm8pCDZQEk5774aOmuTz5V53owQ-";

            var query = string.Format("{0} site:http://www.wikipedia.org", context.Name);
            var result = new WebSearch(appId).Query(query).Get();

            if(result.Count > 1)
                throw new Exception("Dunno which result to choose, there are " + result.TotalHits);

            if(result.Count == 0)
                throw new Exception("Could not find anyone with that name");

            context.WikipediaUrl = result.First().Url;
        }
コード例 #3
0
ファイル: DbFinder.cs プロジェクト: developerdame/Sarabi
 public void Execute(CelebFinderContext context)
 {
     context.Celebrity = _celebrityRepository.GetCelebrityByName(context.Name);
 }