Ejemplo n.º 1
0
        public IEnumerable <CompanyWrapper> GetAllParents()
        {
            CompanyWrapper parentCompany = this.ParentCompany;

            while (parentCompany != null)
            {
                yield return(parentCompany);

                parentCompany = parentCompany.ParentCompany;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Реакция на событие изменения головной компании
        /// </summary>
        /// <param name="oldPropVal"></param>
        /// <param name="newPropVal"></param>
        /// <param name="propertyName"></param>
        private void OnParentCompanyChanged(object oldPropVal, object newPropVal, string propertyName)
        {
            if (propertyName != nameof(ParentCompany))
            {
                return;
            }

            CompanyWrapper oldParent = oldPropVal as CompanyWrapper;

            if (oldParent != null && oldParent.ChildCompanies.Contains(this))
            {
                oldParent.ChildCompanies.Remove(this);
            }

            CompanyWrapper newParent = newPropVal as CompanyWrapper;

            if (newParent != null && !newParent.ChildCompanies.Contains(this))
            {
                newParent.ChildCompanies.Add(this);
            }
        }