コード例 #1
0
        private object GetPropertyValue(object source, ConfigurationCollectionPropertyDefinition propertyModel)
        {
            var collection = propertyModel.GetPropertyValue(source) as IEnumerable ?? new List <object>();

            var result = new List <object>();

            foreach (var item in collection)
            {
                var itemValue = BuildObject(item, propertyModel.ConfigurationProperties);
                result.Add(itemValue);
            }

            return(result);
        }
コード例 #2
0
        private void UpdateOptions(object source, ConfigurationCollectionPropertyDefinition model)
        {
            var items = model.GetPropertyValue(source) as IEnumerable;

            if (items == null)
            {
                var collectionBuilder = model.GetCollectionBuilder();
                model.SetPropertyValue(source, collectionBuilder.Collection);
                return;
            }
            foreach (var item in items)
            {
                UpdateOptions(item, model.ConfigurationProperties);
            }
        }