2009-11-02 16 views
8

Tüm parametreleri örtülü olarak geçirmenin alternatif bir yolu var mı? Ya da başka avantajlar.Anonim Profili Geçmenin En İyi Yolu

MSDN itibaren

:

public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args) 
{ 
    ProfileCommon anonymousProfile = Profile.GetProfile(args.AnonymousID); 

    Profile.ZipCode = anonymousProfile.ZipCode; 
    Profile.CityAndState = anonymousProfile.CityAndState; 
    Profile.StockSymbols = anonymousProfile.StockSymbols; 

    //////// 
    // Delete the anonymous profile. If the anonymous ID is not 
    // needed in the rest of the site, remove the anonymous cookie. 

    ProfileManager.DeleteProfile(args.AnonymousID); 
    AnonymousIdentificationModule.ClearAnonymousIdentifier(); 

    // Delete the user row that was created for the anonymous user. 
    Membership.DeleteUser(args.AnonymousID, true); 

} 

Ya da bu en iyi/tek yol mu?

cevap

8

Oturum sırasında Profil Özellikler 'Geçirme. Ama bir genelleme önerebilirim. Her bir özelliği kodlamak yerine ProfileBase.Properties koleksiyonunu kullanabilirsiniz. Bu doğrultuda bir şey:

özellik grupları özellik adları bir parçası olarak temsil edilir yana
var anonymousProfile = Profile.GetProfile(args.AnonymousID); 
foreach(var property in anonymousProfile.PropertyValues) 
{ 
    Profile.SetPropertyValue(property.Name, property.PropertyValue); 
} 

yukarıda kodu da tesis grubu ile çalışır (örneğin "Settings.Theme" Ayarlar grup içindeki Oyun özelliği temsil eder).

+0

Bu özellik grupları da alabilir mi? –

İlgili konular