Пример #1
0
        private static FileGroup FgFromClass(PersistentModel model, IBSharpClass fgd, Dictionary <string, FileGroup> fgs)
        {
            if (fgs.ContainsKey(fgd.Name))
            {
                return(fgs[fgd.Name.ToUpper()]);
            }
            var fg = new FileGroup();

            fg.Setup(model, null, fgd, fgd.Compiled);
            fg.Name = fg.Name.ToUpper();
            fgs[fg.Name.ToUpper()] = fg;
            return(fg);
        }
Пример #2
0
        private static IEnumerable <SqlObject> GenerateFileGroups(PersistentModel model)
        {
            var fgs = new Dictionary <string, FileGroup>();

            foreach (IBSharpClass fgd in model.Context.ResolveAll(model.FileGroupPrototype))
            {
                FgFromClass(model, fgd, fgs);
            }
            foreach (PersistentClass pcls in model.Classes.Values)
            {
                IBSharpClass _pcls = model.Context.Get(pcls.AllocationInfo.FileGroupName);
                pcls.AllocationInfo.FileGroupName = pcls.AllocationInfo.FileGroupName.ToUpper();

                if (null != _pcls)
                {
                    pcls.AllocationInfo.FileGroup = FgFromClass(model, _pcls, fgs);
                }
                else
                {
                    if (!fgs.ContainsKey(pcls.AllocationInfo.FileGroupName))
                    {
                        fgs[pcls.AllocationInfo.FileGroupName] = new FileGroup {
                            Name = pcls.AllocationInfo.FileGroupName
                        };
                    }
                    pcls.AllocationInfo.FileGroup = fgs[pcls.AllocationInfo.FileGroupName];
                }
            }
            if (!fgs.ContainsKey("SECONDARY"))
            {
                fgs["SECONDARY"] = new FileGroup {
                    Name = "SECONDARY"
                };
            }
            bool hasdef = fgs.Values.Any(_ => _.IsDefault);

            if (!hasdef)
            {
                fgs["SECONDARY"].IsDefault = true;
            }
            return(fgs.Values);
        }