Пример #1
0
        public Domain AddDomain(Authentication authentication, DomainInfo domainInfo)
        {
            var domainType = domainInfo.DomainType;
            var domain     = null as Domain;

            if (domainType == typeof(TableContentDomain).Name)
            {
                domain = new TableContentDomain(domainInfo, this.CremaHost.Dispatcher);
            }
            else if (domainType == typeof(TypeDomain).Name)
            {
                domain = new TypeDomain(domainInfo, this.CremaHost.Dispatcher);
            }
            else if (domainType == typeof(TableTemplateDomain).Name)
            {
                domain = new TableTemplateDomain(domainInfo, this.CremaHost.Dispatcher);
            }
            if (domain != null)
            {
                domain.Category = this.Context.Categories.Prepare(domainInfo.CategoryPath);

                foreach (var item in this.CremaHost.DataBases)
                {
                    var isLoaded = item.Service != null;
                    if (domain.DataBaseID == item.ID && isLoaded == true && item.IsResetting == false)
                    {
                        var target = item.FindDomainHost(domain);
                        if (target != null)
                        {
                            target.Restore(domain);
                            domain.Host = target;
                        }
                    }
                }
                if (authentication != null)
                {
                    this.InvokeDomainCreatedEvent(authentication, domain);
                }
            }
            return(domain);
        }