Exemple #1
0
        public override void Compile()
        {
            var cs = new List <DefBeanBase>();

            if (Children != null)
            {
                CollectHierarchyNotAbstractChildren(cs);
            }
            HierarchyNotAbstractChildren = cs;
            if (Id != 0)
            {
                throw new Exception($"bean:{FullName} beanid:{Id} should be 0!");
            }
            else
            {
                Id = TypeUtil.ComputCfgHashIdByName(FullName);
            }
            // 检查别名是否重复
            HashSet <string> nameOrAliasName = cs.Select(b => b.Name).ToHashSet();

            foreach (DefBean c in cs)
            {
                if (!string.IsNullOrWhiteSpace(c.Alias) && !nameOrAliasName.Add(c.Alias))
                {
                    throw new Exception($"bean:{FullName} alias:{c.Alias} 重复");
                }
            }
            DefField.CompileFields(this, HierarchyFields, false);
        }
        public override void Compile()
        {
            ResolveExternalType();

            var cs = new List <DefBeanBase>();

            if (Children != null)
            {
                CollectHierarchyNotAbstractChildren(cs);
            }
            HierarchyNotAbstractChildren = cs;
            if (Id != 0)
            {
                throw new Exception($"bean:'{FullName}' beanid:{Id} should be 0!");
            }
            else
            {
                Id = TypeUtil.ComputCfgHashIdByName(FullName);
            }
            // 检查别名是否重复
            HashSet <string> nameOrAliasName = cs.Select(b => b.Name).ToHashSet();

            foreach (DefBean c in cs)
            {
                if (!string.IsNullOrWhiteSpace(c.Alias) && !nameOrAliasName.Add(c.Alias))
                {
                    throw new Exception($"bean:'{FullName}' alias:{c.Alias} 重复");
                }
            }
            DefField.CompileFields(this, HierarchyFields, false);

            var allocAutoIds = this.HierarchyFields.Select(f => f.Id).ToHashSet();

            int nextAutoId = 1;

            foreach (var f in this.HierarchyFields)
            {
                while (!allocAutoIds.Add(nextAutoId))
                {
                    ++nextAutoId;
                }
                f.AutoId = nextAutoId;
            }
        }