Beispiel #1
0
        public void ConnectLayout(IDomain domain, ref bool IsConnected)
        {
            if (AreaLayouts == null)
            {
                AreaLayouts = new Dictionary <IArea, ILayout>();

                foreach (KeyValuePair <IDeclarationSource, string> Entry in AreaLayoutPairs)
                {
                    IDeclarationSource AreaSource = Entry.Key;
                    string             LayoutName = Entry.Value;
                    IArea   EntryArea             = null;
                    ILayout EntryLayout           = null;

                    if (AreaSource.Name == Parser.Area.EmptyArea.Name)
                    {
                        EntryArea = Parser.Area.EmptyArea;
                    }
                    else
                    {
                        foreach (IArea Item in domain.Areas)
                        {
                            if (Item.Name == AreaSource.Name)
                            {
                                EntryArea = Item;
                                break;
                            }
                        }
                    }

                    if (LayoutName == Parser.Layout.EmptyLayout.Name)
                    {
                        EntryLayout = Parser.Layout.EmptyLayout;
                    }
                    else
                    {
                        foreach (ILayout Item in domain.Layouts)
                        {
                            if (Item.Name == LayoutName)
                            {
                                EntryLayout = Item;
                                break;
                            }
                        }
                    }

                    if (EntryArea == null)
                    {
                        throw new ParsingException(119, AreaSource.Source, $"Unknown area '{AreaSource.Name}'.");
                    }
                    else if (EntryLayout == null)
                    {
                        throw new ParsingException(120, AreaSource.Source, $"Unknown layout '{LayoutName}'.");
                    }
                    else if ((EntryArea == Parser.Area.EmptyArea && EntryLayout != Parser.Layout.EmptyLayout) || (EntryArea != Parser.Area.EmptyArea && EntryLayout == Parser.Layout.EmptyLayout))
                    {
                        if (EntryArea == Parser.Area.EmptyArea)
                        {
                            throw new ParsingException(0, AreaSource.Source, $"The empty area can only be associated to the empty layout.");
                        }
                        else
                        {
                            throw new ParsingException(0, AreaSource.Source, $"The empty layout can only be associated to the empty area.");
                        }
                    }

                    if (EntryArea != Parser.Area.EmptyArea && EntryLayout != Parser.Layout.EmptyLayout)
                    {
                        AreaLayouts.Add(EntryArea, EntryLayout.GetClone());
                        AreaLayoutBacktracks.Add(EntryArea, AreaSource);
                    }
                }

                foreach (KeyValuePair <IArea, ILayout> Entry in AreaLayouts)
                {
                    Entry.Value.ConnectComponents(domain, Dynamic, Entry.Key.Components);
                }

                IsConnected = true;
            }
        }