Пример #1
0
 List<Tuple<string, string>> GetUserDetail(FetchResponse fetch)
 {
     List<Tuple<string, string>> items = new List<Tuple<string, string>>();
     items.Add(new Tuple<string, string>("Email", fetch.GetAttributeValue(WellKnownAttributes.Contact.Email)));
     items.Add(new Tuple<string, string>("First Name", fetch.GetAttributeValue(WellKnownAttributes.Name.First)));
     items.Add(new Tuple<string, string>("Last Name", fetch.GetAttributeValue(WellKnownAttributes.Name.Last)));
     return items;
 }
		public void GetAttributeValue() {
			var response = new FetchResponse();

			// Verify that null is returned if the attribute is absent.
			Assert.IsNull(response.GetAttributeValue("http://someattribute"));

			// Now add an attribute with no values.
			response.Attributes.Add(new AttributeValues("http://someattribute2"));
			Assert.IsNull(response.GetAttributeValue("http://someattribute2"));

			// Now add an attribute with many values.
			response.Attributes.Add(new AttributeValues("http://someattribute3", "a", "b", "c"));
			Assert.AreEqual("a", response.GetAttributeValue("http://someattribute3"));
		}
 internal static LoginProfile ProfileFromOpenId(ClaimsResponse spprofile, FetchResponse fetchprofile, string claimedId, string realmUrlString)
 {
     var profile = new LoginProfile
     {
         Link = claimedId,
         Id = claimedId,
         Provider = ProviderConstants.OpenId,
     };
     if (spprofile != null)
     {
         //Fill
         profile.BirthDay = spprofile.BirthDateRaw;
         profile.DisplayName = spprofile.FullName;
         profile.EMail = spprofile.Email;
         profile.Name = spprofile.Nickname;
         profile.Gender = spprofile.Gender.HasValue ? spprofile.Gender.Value.ToString() : "";
         profile.TimeZone = spprofile.TimeZone;
         profile.Locale = spprofile.Language;
     }
     if (fetchprofile != null)
     {
         profile.Name = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Alias);
         profile.LastName = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Last);
         profile.FirstName = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.First);
         profile.DisplayName = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.FullName);
         profile.MiddleName = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Middle);
         profile.Salutation = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Prefix);
         profile.Avatar = fetchprofile.GetAttributeValue(WellKnownAttributes.Media.Images.Default);
         profile.EMail = fetchprofile.GetAttributeValue(WellKnownAttributes.Contact.Email);
         profile.Gender = fetchprofile.GetAttributeValue(WellKnownAttributes.Person.Gender);
         profile.BirthDay = fetchprofile.GetAttributeValue(WellKnownAttributes.BirthDate.WholeBirthDate);
     }
     profile.RealmUrl = realmUrlString;
     return profile;
 }