private void Load(IList <UserOptionPropertyDefinition> properties) { using (UserConfiguration userConfiguration = this.GetUserConfiguration()) { if (userConfiguration != null) { IDictionary dictionary = userConfiguration.GetDictionary(); for (int i = 0; i < properties.Count; i++) { UserOptionPropertyDefinition userOptionPropertyDefinition = properties[i]; string propertyName = userOptionPropertyDefinition.PropertyName; object originalValue = dictionary[userOptionPropertyDefinition.PropertyName]; this.optionProperties[userOptionPropertyDefinition] = new UserOptions.UserOptionPropertyValue(userOptionPropertyDefinition.GetValidatedProperty(originalValue), false); ExTraceGlobals.UserOptionsDataTracer.TraceDebug((long)this.GetHashCode(), "Loaded property: {0}", new object[] { this.optionProperties[userOptionPropertyDefinition].Value }); } } else { string value = WebPartUtilities.TryGetLocalMachineTimeZone(); UserOptionPropertyDefinition propertyDefinition = UserOptionPropertySchema.GetPropertyDefinition(UserOptionPropertySchema.UserOptionPropertyID.TimeZone); this.optionProperties[propertyDefinition] = new UserOptions.UserOptionPropertyValue(value, false); } } }
private void CreateOptionsProperties() { this.optionProperties = new Dictionary <UserOptionPropertyDefinition, UserOptions.UserOptionPropertyValue>(); for (int i = 0; i < UserOptionPropertySchema.Count; i++) { this.optionProperties.Add(UserOptionPropertySchema.GetPropertyDefinition(i), null); } }
private object this[UserOptionPropertySchema.UserOptionPropertyID propertyID] { get { UserOptionPropertyDefinition propertyDefinition = UserOptionPropertySchema.GetPropertyDefinition(propertyID); object obj; if (this.optionProperties.ContainsKey(propertyDefinition) && this.optionProperties[propertyDefinition] != null) { obj = this.optionProperties[propertyDefinition].Value; } else { obj = propertyDefinition.GetValidatedProperty(null); } ExTraceGlobals.UserOptionsDataTracer.TraceDebug <string, object>((long)this.GetHashCode(), "Get property: '{0}'; value: '{1}'", propertyDefinition.PropertyName, obj); return(obj); } set { UserOptionPropertyDefinition propertyDefinition = UserOptionPropertySchema.GetPropertyDefinition(propertyID); UserOptions.UserOptionPropertyValue userOptionPropertyValue = new UserOptions.UserOptionPropertyValue(propertyDefinition.GetValidatedProperty(value), true); if (!this.optionProperties.ContainsKey(propertyDefinition)) { this.optionProperties.Add(propertyDefinition, userOptionPropertyValue); this.isSynced = false; ExTraceGlobals.UserOptionsDataTracer.TraceDebug <string, object>((long)this.GetHashCode(), "Set property: '{0}'; value: '{1}'", propertyDefinition.PropertyName, this.optionProperties[propertyDefinition].Value); return; } if (this.optionProperties[propertyDefinition] == null || !userOptionPropertyValue.Value.Equals(this.optionProperties[propertyDefinition].Value)) { this.optionProperties[propertyDefinition] = userOptionPropertyValue; this.isSynced = false; ExTraceGlobals.UserOptionsDataTracer.TraceDebug <string, object>((long)this.GetHashCode(), "Set property: '{0}'; value: '{1}'", propertyDefinition.PropertyName, this.optionProperties[propertyDefinition].Value); } } }
internal static UserOptionPropertyDefinition GetPropertyDefinition(UserOptionPropertySchema.UserOptionPropertyID id) { return(UserOptionPropertySchema.GetPropertyDefinition((int)id)); }