Exemple #1
0
 /// <summary>
 /// To instantiate a new instance of ProfileReader, you must supply an 
 /// instance of ProfileData or the individual ProfileData Properties. If PropertyNames or 
 /// PropertyValues is null, and exception will be thrown.
 /// </summary>
 /// <param name="names">Names of the properties</param>
 /// <param name="values">Values</param>
 /// <param name="binary">Any binary serlialized objects</param>
 public ProfileReader(string names, string values, byte[] binary)
 {
     ProfileData pd = new ProfileData();
     pd.PropertyNames = names;
     pd.PropertyValues = values;
     pd.PropertyValuesBinary = binary;
     _propertyValue = ProfileReader.Parse(pd);
 }
Exemple #2
0
 /// <summary>
 /// Creates a readonly instance of the strongly typed CommunityServer Profile
 /// </summary>
 /// <param name="pd"></param>
 public Profile(ProfileData pd)
 {
     reader = new ProfileReader(pd);
     state = ProfileState.Read;
 }
Exemple #3
0
 /// <summary>
 /// To instantiate a new instance of ProfileReader, you must supply an 
 /// instance of ProfileData or the individual ProfileData Properties. If PropertyNames or 
 /// PropertyValues is null, and exception will be thrown.
 /// </summary>
 /// <param name="pd">Object representing a users profile data</param>
 public ProfileReader(ProfileData pd)
 {
     _propertyValue = ProfileReader.Parse(pd);
 }
Exemple #4
0
        /// <summary>
        /// Parses the ProfileData object and populates the SettingsPropertyValueCollection with the values
        /// </summary>
        /// <param name="pd">Data to parse</param>
        /// <param name="properties">Data result container</param>
        internal static void ParseProfileData(ProfileData pd, SettingsPropertyValueCollection properties)
        {
            if(pd.PropertyNames == null)
                return;

            string[] names = pd.PropertyNames.Split(':');
            for (int i = 0; i < (names.Length / 4); i++)
            {
                string propName = names[i * 4];
                SettingsPropertyValue spv = properties[propName];
                if (spv == null)
                {
                    continue;
                }
                int index = int.Parse(names[(i * 4) + 2], CultureInfo.InvariantCulture);
                int len = int.Parse(names[(i * 4) + 3], CultureInfo.InvariantCulture);
                if (len == -1)
                {
                    if (!spv.Property.PropertyType.IsValueType)
                    {
                        spv.PropertyValue = null;
                        spv.IsDirty = false;
                        spv.Deserialized = true;
                    }
                    continue;
                }
                if (((names[(i * 4) + 1] == "S") && (index >= 0)) && (len > 0) && (pd.PropertyValues != null) && (pd.PropertyValues.Length >= (index + len)))
                {
                    spv.SerializedValue = pd.PropertyValues.Substring(index, len);
                }
                if (((names[(i * 4) + 1] == "B") && (index >= 0)) && (len > 0) && (pd.PropertyValuesBinary != null) && (pd.PropertyValuesBinary.Length >= (index + len)))
                {
                    byte[] buffer = new byte[len];
                    Buffer.BlockCopy(pd.PropertyValuesBinary, index, buffer, 0, len);
                    spv.SerializedValue = buffer;
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Generates a SettingsPropertyValueCollection for the specified ProfileData.
        /// </summary>
        internal static SettingsPropertyValueCollection GetPropertyValues(ProfileData pd)
        {
            //NOTE: Can we cache/clone/copy this collection. Chances are when we use it, we will
            //access it many times in a row.
            SettingsPropertyValueCollection spvc = new SettingsPropertyValueCollection();

            foreach (SettingsProperty p in ProfileBase.Properties)
            {
                if (p.SerializeAs == SettingsSerializeAs.ProviderSpecific)
                {
                    if (p.PropertyType.IsPrimitive || (p.PropertyType == typeof(string)))
                    {
                        p.SerializeAs = SettingsSerializeAs.String;
                    }
                    else
                    {
                        p.SerializeAs = SettingsSerializeAs.Xml;
                    }
                }
                spvc.Add(new SettingsPropertyValue(p));
            }

            try
            {
                ParseProfileData(pd, spvc);
            }
            catch (Exception)
            {
            }
            return spvc;
        }
Exemple #6
0
 /// <summary>
 /// Generates an instance of SettingsPropertyValueCollection containing a users property values.
 /// </summary>
 public static SettingsPropertyValueCollection Parse(ProfileData pd)
 {
     SettingsPropertyValueCollection spvc = GetPropertyValues(pd);
         return spvc;
 }
Exemple #7
0
 public static ProfileData PopulateProfileDataFromIReader(IDataReader reader)
 {
     ProfileData pd = new ProfileData();
     pd.PropertyNames = reader["ProfileNames"] as string;
     pd.PropertyValues = reader["PropertyValuesString"] as string;
     pd.PropertyValuesBinary = reader["PropertyValuesBinary"] as byte[];
     return pd;
 }
Exemple #8
0
Fichier : User.cs Projet : pcstx/OA
 public User(MembershipUser mu, ProfileData pd)
     : this(mu,new Profile(pd))
 {
 }