예제 #1
0
        public AppConfigCollection FindValues(AppConfigVersion version, params string[] names)
        {
            IEnumerable <AppConfigParameter> enumerable = this.Find(version, names);
            AppConfigCollection appConfigCollection     = new AppConfigCollection();

            foreach (AppConfigParameter appConfigParameter in enumerable)
            {
                appConfigCollection.Add(appConfigParameter.Name, appConfigParameter.Value);
            }
            return(appConfigCollection);
        }
예제 #2
0
        public IEnumerable <AppConfigParameter> Find(AppConfigVersion version, params string[] names)
        {
            ComparisonFilter comparisonFilter = new ComparisonFilter(ComparisonOperator.Equal, AppConfigSchema.ParamVersionProp, version.ToInt64());

            IConfigurable[] source;
            if (names == null || names.Length == 0)
            {
                source = this.DataProvider.Find <AppConfigSchema.AppConfigByVersion>(comparisonFilter, null, false, null);
            }
            else
            {
                HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                for (int i = 0; i < names.Length; i++)
                {
                    string text = names[i];
                    if (text == null)
                    {
                        throw new ArgumentNullException("names", string.Format("Parameter name at index {0} is null.", i));
                    }
                    if (text.Length > 255)
                    {
                        throw new ArgumentOutOfRangeException("names", string.Format("Parameter name at index {0} is too long.", i));
                    }
                    if (!hashSet.Add(text))
                    {
                        throw new ArgumentException(string.Format("Duplicate parameter name is found at index {0}.", i), "names");
                    }
                }
                DataTable dataTable = new DataTable();
                dataTable.TableName = "AppConfigNamesTableType";
                dataTable.Columns.Add("nvc_ParamNames", typeof(string));
                for (int j = 0; j < names.Length; j++)
                {
                    dataTable.Rows.Add(new object[]
                    {
                        names[j]
                    });
                }
                ComparisonFilter comparisonFilter2 = new ComparisonFilter(ComparisonOperator.Equal, AppConfigSchema.ParamNamesTableProp, dataTable);
                source = this.DataProvider.Find <AppConfigSchema.AppConfigByName>(new AndFilter(new QueryFilter[]
                {
                    comparisonFilter,
                    comparisonFilter2
                }), null, false, null);
            }
            return(source.Cast <AppConfigParameter>());
        }