Beispiel #1
0
        private void SetCollectionMemberValue(object instance, IEnumerable values)
        {
            Assumes.NotNull(values);

            ICollection <object> collection = null;
            Type itemType = CollectionServices.GetCollectionElementType(this.ImportType.ActualType);

            if (itemType != null)
            {
                collection = GetNormalizedCollection(itemType, instance);
            }

            EnsureCollectionIsWritable(collection);
            PopulateCollection(collection, values);
        }
Beispiel #2
0
        private void SetCollectionMemberValue(object?instance, IEnumerable values)
        {
            ArgumentNullException.ThrowIfNull(values);

            ICollection <object>?collection = null;
            Type?itemType = CollectionServices.GetCollectionElementType(ImportType.ActualType);

            if (itemType != null)
            {
                collection = GetNormalizedCollection(itemType, instance);
            }

            EnsureCollectionIsWritable(collection);
            PopulateCollection(collection !, values);
        }
        private void SetCollectionMemberValue(object instance, IEnumerable values)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            ICollection <object> collection = null;
            Type itemType = CollectionServices.GetCollectionElementType(ImportType.ActualType);

            if (itemType != null)
            {
                collection = GetNormalizedCollection(itemType, instance);
            }

            EnsureCollectionIsWritable(collection);
            PopulateCollection(collection, values);
        }
Beispiel #4
0
        private void SetCollectionMemberValue(object instance, IEnumerable values)
        {
            Assumes.NotNull(values);

            ICollection <object> collection = null;
            Type itemType = CollectionServices.GetCollectionElementType(this.ImportType.ActualType);

            if (itemType != null)
            {
                collection = GetNormalizedCollection(itemType, instance);
            }

            //ICollection<object> collection = new List<object>();
            ////foreach (var item in values)
            ////{
            ////    collection.Add(item);
            ////}
            //var collectionObject = this._member.GetValue(instance);
            //SetSingleMemberValue(instance, collectionObject);

            EnsureCollectionIsWritable(collection);
            PopulateCollection(collection, values);
        }