Esempio n. 1
0
        public virtual IMappingStorage Add(Type @interface, object value)
        {
            if (@interface == null)
            {
                throw new ArgumentNullException(nameof(@interface));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (!IsValueValid(@interface, value))
            {
                throw new InterfaceNotImplementedException(@interface, value);
            }

            var mappgin = new Mapping(@interface, value);

            if (!Mappings.Any(a => a.CompareTo(mappgin) >= 2))
            {
                OnBeforeAdd?.Invoke(@interface, value, null);
                Mappings.Add(mappgin);
            }

            return(this);
        }
Esempio n. 2
0
        public virtual IMappingStorage Add(Type @interface, object value, string target)
        {
            if (@interface == null)
            {
                throw new ArgumentNullException(nameof(@interface));
            }

            if (string.IsNullOrEmpty(target))
            {
                throw new ArgumentException("message", nameof(target));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (!IsValueValid(@interface, value))
            {
                throw new InterfaceNotImplementedException(@interface, value);
            }

            var Add = new Mapping(@interface, value, target);

            if (!Mappings.Any(a => a.CompareTo(Add) >= 2))
            {
                OnBeforeAdd?.Invoke(@interface, value, target);
                Mappings.Add(Add);
            }

            return(this);
        }