Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a dynamic type generated by the framework. On runtime the type 'ProfileCommon' exists.</p> <p>If you can use the C# 4.0 language features you can wrap the behavior of ProfileCommon in a dynamic object. </p> <p>I have the following extended properties </p> <pre><code>&lt;profile enabled="true" &gt; &lt;properties&gt; &lt;add name="FirstName" type="String" /&gt; &lt;add name="LastName" type="String" /&gt; &lt;/properties&gt; &lt;/profile&gt; </code></pre> <p>The code example to use the dynamic object is</p> <pre><code>dynamic profile = new ProfileData(); var name = profile.FirstName + ' ' + profile.LastName; </code></pre> <p>The implementation of ProfileData:</p> <pre><code>public class ProfileData: DynamicObject { private readonly ProfileBase profileBase; /// &lt;summary&gt; /// Profile Data for the current user. /// &lt;/summary&gt; public ProfileData() { profileBase = HttpContext.Current.Profile; } /// &lt;summary&gt; /// Profile data for user with name &lt;paramref name="userName"/&gt; /// &lt;/summary&gt; /// &lt;param name="userName"&gt;&lt;/param&gt; public ProfileData(string userName) { profileBase = ProfileBase.Create(userName); } // If you try to get a value of a property // not defined in the class, this method is called. public override bool TryGetMember(GetMemberBinder binder, out object result) { try { result = profileBase.GetPropertyValue(binder.Name); } catch(SettingsPropertyNotFoundException) { result = null; return false; } return true; } // If you try to set a value of a property that is // not defined in the class, this method is called. public override bool TrySetMember(SetMemberBinder binder, object value) { try { profileBase.SetPropertyValue(binder.Name, value); return true; } catch (SettingsPropertyNotFoundException) { return false; } } /// &lt;summary&gt; /// Persist the profile data. /// &lt;/summary&gt; public void Save() { profileBase.Save(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload