public void AttachToComponent(PCComponent component)
        {
            Argument.NotNull(component);
            if (Component != null)
            {
                throw new InvalidOperationException();
            }

            Component   = component;
            ComponentId = component.Id;
        }
        /// <summary>
        ///     Adds component to configuration
        /// </summary>
        public PCConfiguration WithComponent(PCComponent component)
        {
            Argument.NotNull(component);
            if (ContainedComponents.Any(x => x.SameIdentityAs(component)))
            {
                throw new DuplicateElementException("Component already added");
            }

            ContainedComponents.Add(component);

            return(this);
        }
Exemple #3
0
        public PCComponent WithContainedComponent(PCComponent childComponent)
        {
            Argument.NotNull(childComponent);

            if (SameIdentityAs(childComponent))
            {
                throw new ArgumentException("Cannot add component to itself");
            }
            if (Components.Any(x => x.SameIdentityAs(childComponent)))
            {
                throw new DuplicateElementException("Child component has been already added");
            }

            Components.Add(childComponent);
            return(this);
        }