Today's documentationless experiment: Writing a ProfileProvider
Writing a Membership provider sure was easy, but wow is the documentation a bit thin for writing a Profile provider. I've started with the GetPropertyValues() method. So far I've got this bit working in a class called PopForumsProfileProvider, which inherits the abstract base class ProfileProvider:
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection ppc)
string s = ppc.ToString();
SettingsPropertyValueCollection settings = new SettingsPropertyValueCollection();
People p = new People(context["UserName"].ToString(), PeopleLookupType.Name);
SettingsPropertyValue list = new SettingsPropertyValue(ppc["PopForums.List"]);
list.PropertyValue = p.List;
else throw new Exception("PopForums Profile provider: User is not currently authenticated.");
And in web.config...
<add name="PopForums" type="PopForums.Security.PopForumsProfileProvider, PopForums" />
<add name="List" type="System.Boolean" provider="PopForums" />
People is a class from my forum that manages user data. So far, this works like a champ. It took some debugging and poking around to figure out what the hell those two parameters were because the docs don't actually say at the moment.
The trick now is figuring out where in the page's event life cycle the SetPropertyValues() method of the provider is called. I guess it's not essential to know, but I would like to.
The other thing that I'm curious to know is how the default provider (which will be SqlProfileProvider in beta 2) iterates through the property collection. In the above code, I couldn't figure out exactly how to figure out what the property names were in ppc.