Пример #1
0
        public Domain Create(Authentication authentication, DomainMetaData metaData)
        {
            var domain = this[metaData.DomainID];

            if (domain == null)
            {
                if (metaData.DomainInfo.DomainType == typeof(TableContentDomain).Name)
                {
                    domain = new TableContentDomain(metaData.DomainInfo, this.Context.CremaHost.Dispatcher);
                }
                else if (metaData.DomainInfo.DomainType == typeof(TableTemplateDomain).Name)
                {
                    domain = new TableTemplateDomain(metaData.DomainInfo, this.Context.CremaHost.Dispatcher);
                }
                else if (metaData.DomainInfo.DomainType == typeof(TypeDomain).Name)
                {
                    domain = new TypeDomain(metaData.DomainInfo, this.Context.CremaHost.Dispatcher);
                }

                this.Add(domain);
                domain.Category = this.Context.Categories.Prepare(metaData.DomainInfo.CategoryPath);
                domain.Initialize(authentication, metaData);
                this.InvokeDomainCreatedEvent(authentication, domain);
            }
            else
            {
                domain.Initialize(authentication, metaData);
            }

            return(domain);
        }
Пример #2
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);
        }