Exemplo n.º 1
0
        void EditorUpdateDeclaration(DeclarationUI ui, IStructDeclarer declarer, string newName, string newFields)
        {
            var oldDecl = declarer.Declaration;

            if (oldDecl.Name != newName && FDeclarationFactory.Get(newName) != null)
            {
                ui.AppendError($"Declaration named '{newName}' already exists");
                return;
            }
            else if (!FDeclarationFactory.WellformedDeclarationName(newName))
            {
                ui.AppendError($"Declaration name malformed");
                return;
            }
            var d = FDeclarationFactory.Create(newName, newFields);

            if (!d.Equals(oldDecl))
            {
                FDeclarationFactory.Update(oldDecl.Name, d);
                SetDescriptiveName(declarer, d.Name);
            }
        }
Exemplo n.º 2
0
        void EditorCreateDeclaration(DeclarationUI ui, IStructDeclarer declarer, string newName, string newFields)
        {
            if (!FDeclarationFactory.WellformedDeclarationName(newName))
            {
                ui.AppendError($"Declaration name malformed");
                return;
            }
            Declaration d = FDeclarationFactory.Get(newName);

            if (d == null)
            {
                d = FDeclarationFactory.Create(newName, newFields);
                FDeclarationFactory.Add(d);
                declarer.Declaration = d;
                (declarer.IOManager as IOManager).UpdateFromDeclaration(d);
                SetDescriptiveName(declarer, d.Name);
            }
            else
            {
                ui.AppendError($"Declaration named '{newName}' already exists");
            }
        }