BetterMembership.Web.BetterProfileProvider.GetPropertyValues C# (CSharp) Метод

GetPropertyValues() публичный Метод

public GetPropertyValues ( SettingsContext context, SettingsPropertyCollection collection ) : SettingsPropertyValueCollection
context System.Configuration.SettingsContext
collection System.Configuration.SettingsPropertyCollection
Результат System.Configuration.SettingsPropertyValueCollection
        public override SettingsPropertyValueCollection GetPropertyValues(
            SettingsContext context, SettingsPropertyCollection collection)
        {
            Condition.Requires(context, "context").IsNotNull();
            Condition.Requires(collection, "collection").IsNotNull();

            var userName = context[UserNameKey] as string;
            var values = new SettingsPropertyValueCollection();
            if (string.IsNullOrWhiteSpace(userName))
            {
                return values;
            }

            this.EnsureSupportedColumns();

            if (this.databaseColumns.Count == 0 && this.DoesNotContainDefaultColumns(collection))
            {
                return values;
            }

            var profile = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
            using (var db = this.ConnectToDatabase())
            {
                var row = db.QuerySingle(this.sqlQueryBuilder.GetUserProfile, userName);
                if (row != null)
                {
                    for (var i = 0; i < row.Columns.Count; i++)
                    {
                        var key = row.Columns[i];
                        var value = row[key];
                        profile.Add(key, value);
                    }
                }
            }

            foreach (SettingsProperty property in collection)
            {
                var valueProperty = new SettingsPropertyValue(property);
                if (profile.ContainsKey(property.Name))
                {
                    valueProperty.PropertyValue = profile[property.Name];
                    valueProperty.Deserialized = true;
                    valueProperty.IsDirty = false;
                }
                else if (!property.PropertyType.IsValueType)
                {
                    valueProperty.PropertyValue = property.DefaultValue;
                    valueProperty.IsDirty = false;
                }

                values.Add(valueProperty);
            }

            return values;
        }