ClearCanvas.Common.Configuration.SettingsStoreSettingsProvider.GetPreviousSettingsValues C# (CSharp) Method

GetPreviousSettingsValues() private method

private GetPreviousSettingsValues ( SettingsGroupDescriptor group, string user, string settingsKey ) : string>.Dictionary
group SettingsGroupDescriptor
user string
settingsKey string
return string>.Dictionary
		private Dictionary<string, string> GetPreviousSettingsValues(SettingsGroupDescriptor group, string user, string settingsKey)
		{
			var allGroups = _store.ListSettingsGroups();
			var lessEqualGroups = CollectionUtils.Select(allGroups, 
				other => other.AssemblyQualifiedTypeName == group.AssemblyQualifiedTypeName && other.Version < group.Version);

			// sort descending
			lessEqualGroups.Sort((other1, other2) => other2.Version.CompareTo(other1.Version));
			if (lessEqualGroups.Count == 0)
				return null;

			foreach (var g in lessEqualGroups)
			{
				Dictionary<string, string> userValues = null;
				if (!String.IsNullOrEmpty(user))
				{
					userValues = _store.GetSettingsValues(g, user, settingsKey);
					if (userValues == null || userValues.Count == 0)
						continue;
				}

				var values = new Dictionary<string, string>();
				foreach (var binaryDefault in _store.ListSettingsProperties(group))
					values[binaryDefault.Name] = binaryDefault.DefaultValue;

				foreach (var userDefault in _store.GetSettingsValues(group, null, settingsKey))
					values[userDefault.Key] = userDefault.Value;

				if (userValues != null)
				{
					foreach (var userValue in userValues)
						values[userValue.Key] = userValue.Value;
				}

				return values;
			}

			return null;
		}