Esempio n. 1
0
        /// <summary>
        /// Given a current contact, re-fetch it from InSpire. This should be an inspire contact or
        /// very bad things will happen!
        /// </summary>
        /// <param name="contact">InSpriteContact instance</param>
        /// <param name="webAccess">How we can get at the web</param>
        /// <returns></returns>
        public static async Task <InSpireContact> UpdateContact(this InSpireContact contact, IWebInterface webAccess)
        {
            var val = (await FindContactFromHEPNamesAsync(contact.AsContactUri(), webAccess)).ToArray();

            if (val.Length != 1)
            {
                throw new InvalidOperationException("Request for single contact brought back more than one contact");
            }
            return(val[0] as InSpireContact);
        }
Esempio n. 2
0
 /// <summary>
 /// Return the Uri for the contact.
 /// </summary>
 /// <param name="contact"></param>
 /// <returns></returns>
 public static Uri AsContactUri(this InSpireContact contact)
 {
     return(new Uri($"http://inspirehep.net:80/record/{contact.InspireRecordID}?ln=en"));
 }
 /// <summary>
 /// Use the HEPNAMEs DB to refresh the data in this contact.
 /// </summary>
 /// <param name="contact"></param>
 /// <returns></returns>
 private Task <InSpireContact> RefreshContact(InSpireContact contact)
 {
     return(contact.UpdateContact(_webAccess));
 }