示例#1
0
        /// <inheritdoc/>
        void ICloneable.CopyFrom(ICloneable source)
        {
            var src = (InterfaceTypeDictionary <V>)source.ThrowIfNull(nameof(source));

            _dictionary.Clear();
            _interfaces.Clear();
            foreach (var pair in src._dictionary)
            {
                Add(pair.Key, pair.Value);
            }
        }
示例#2
0
        /// <inheritdoc/>
        void ICloneable.CopyFrom(ICloneable source)
        {
            var src = (InheritedTypeDictionary <V>)source.ThrowIfNull(nameof(source));

            _dictionary.Clear();
            _values.Clear();
            foreach (var pair in src._dictionary)
            {
                if (pair.Value.IsDirect)
                {
                    Add(pair.Key, pair.Value.Value);
                }
            }
        }
        /// <summary>
        /// Copies the contents of one interface to this one.
        /// </summary>
        /// <param name="source">The source parameter.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown if <paramref name="source"/> does not have the same type.</exception>
        protected virtual void CopyFrom(ICloneable source)
        {
            source.ThrowIfNull(nameof(source));
            if (!source.GetType().Equals(GetType()))
            {
                throw new ArgumentException(Properties.Resources.Reflection_NotMatchingType);
            }
            var src = (EntityCollection)source;

            _entities.Clear();
            foreach (var entity in src._entities.Values)
            {
                Add(entity);
            }
        }
 /// <summary>
 /// Copies the contents of one interface to this one.
 /// </summary>
 /// <param name="source">The source parameter.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown if <paramref name="source"/> does not have the same type.</exception>
 protected virtual void CopyFrom(ICloneable source)
 {
     source.ThrowIfNull(nameof(source));
     ReflectionHelper.CopyPropertiesAndFields(source, this);
 }