Exemple #1
0
        private void AddChildofFixedNodeinFlow(int[] childIndex, NamedElement ne)
        {
            // Create a fake FixedNode to help binary search.
            FixedNode fn = FixedNode.Create(((FixedNode)_fixedNodes[0]).Page, childIndex);
            // Launch the binary search to find the matching FixedNode
            int index = _fixedNodes.BinarySearch(fn);

            if (index >= 0)
            {
                int startIndex;
                // Search backward for the first Node in this scope
                for (startIndex = index - 1; startIndex >= 0; startIndex--)
                {
                    fn = (FixedNode)_fixedNodes[startIndex];
                    if (fn.ComparetoIndex(childIndex) != 0)
                    {
                        break;
                    }
                }

                // Search forward to add all the nodes in order.
                for (int i = startIndex + 1; i < _fixedNodes.Count; i++)
                {
                    fn = (FixedNode)_fixedNodes[i];
                    if (fn.ComparetoIndex(childIndex) == 0)
                    {
                        AddFixedNodeInFlow(i, null);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinDesignerEventArgs e)
        {
            try
            {
                StringBuilder messages = new StringBuilder();

                // Get the selected element as a base type "NamedElement". Maybe you don't need to know the specific
                // type, because you just want to dump element names, for example. You still can check the type later
                // and run any type-specific logic.
                NamedElement namedElement = e.SelectedElement as NamedElement;
                if (namedElement != null)
                {
                    messages.AppendLine($"You selected {namedElement.GetType().Name} named {namedElement.Name}.");
                }

                // If you're looking for a specific type, try to cast the selected item directly to the type.
                ClassItem c = e.SelectedElement as ClassItem;
                if (c != null)
                {
                    int methodCount = c.Methods.Cast <IMethod>().Count(); // Calculating number of methods
                    messages.AppendLine($"The class has {methodCount} method(s).");
                }

                // Show messages in a dialog box.
                CoreUtility.DisplayInfo(messages.ToString());
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
Exemple #3
0
        public void UnicleNameTest()
        {
            var t = new NamedList <NamedElement>();

            var el = new NamedElement();

            el.Rename("dsa");

            var el2 = new NamedElement();

            el2.Rename("dsa");

            t.Add(el);

            try
            {
                t.Add(el);
            }
            catch (InvalidOperationException)
            {
                try
                {
                    t[0] = el2;
                }
                catch (InvalidOperationException)
                {
                    return;
                }
            }

            throw new Exception("Exception has not throwed by NamedList");
        }
Exemple #4
0
        private void ConstructSomElement(NamedElement ne)
        {
            NameHashFixedNode fen;

            if (_nameHashTable.TryGetValue(ne.NameReference, out fen) == true)
            {
                if (fen.uiElement is Glyphs || fen.uiElement is Path ||
                    fen.uiElement is Image)
                {
                    // Elements that can't have childrent
                    AddFixedNodeInFlow(fen.index, fen.uiElement);
                }
                else
                {
                    if (fen.uiElement is Canvas)
                    {
                        // We need to find all the fixed nodes inside the scope of
                        // this grouping element, add all of them in the arraylist.
                        int[] childIndex = _fixedPage._CreateChildIndex(fen.uiElement);

                        AddChildofFixedNodeinFlow(childIndex, ne);
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Draws given root element and all its children and counts width of its subtree.
        /// </summary>
        /// <param name="diagram">Diagram to be layouted</param>
        /// <param name="root">Root element of layouted subtree</param>
        /// <param name="top">Location of the upper border of the root</param>
        /// <param name="left">Location of the left border of the entire subtree</param>
        /// <returns>Width of the subtree (root included)</returns>
        private static double DrawTree(XCaseCanvas diagram, NamedElement root, double top, double left)
        {
            if (!diagram.ElementRepresentations.IsElementPresent(root))
            {
                return(-horizontalSpace);
            }
            XCaseViewBase element = (diagram.ElementRepresentations[root] as XCaseViewBase);
            double        height  = element.ActualHeight;
            double        width   = element.ActualWidth;
            double        right   = left + TreeLayout.DrawSubtree(diagram, root, top + height + verticalSpace, left);

            if (right == left)
            {
                right = left + width;
            }
            else
            {
                if (right < left + width)
                {
                    double subtreeWidth = right - left;
                    TreeLayout.DrawSubtree(diagram, root, top + height + verticalSpace, left + (width - subtreeWidth) / 2);
                    right = left + width;
                }
            }
            element.X            = Math.Round((right + left) / 2 - width / 2);
            element.ViewHelper.X = element.X;
            element.Y            = Math.Round(top);
            element.ViewHelper.Y = element.Y;
            return(right - left);
        }
        public void CreateWithNamedIdentityAndOneElement()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity , aelement}, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            table.SetValue(aelement, aelement, identity);

            Assert.IsTrue(table.HasIdentity);
            Assert.IsTrue(table.IsAssociative);
            Assert.IsTrue(table.IsClosed);
            Assert.IsTrue(table.IsCommutative);

            Assert.AreEqual(2, table.Elements.Count);

            Assert.AreEqual(identity, table.GetValue(identity, identity));
            Assert.AreEqual(aelement, table.GetValue(aelement, identity));
            Assert.AreEqual(aelement, table.GetValue(identity, aelement));
            Assert.AreEqual(identity, table.GetValue(aelement, aelement));

            Assert.AreEqual(1, identity.Order);
            Assert.AreEqual(2, aelement.Order);
        }
        // Token: 0x06002D18 RID: 11544 RVA: 0x000CB7CC File Offset: 0x000C99CC
        private void _CreateFlowNodes(BlockElement be)
        {
            NamedElement namedElement = be as NamedElement;

            if (namedElement != null)
            {
                this.ConstructSomElement(namedElement);
                return;
            }
            SemanticBasicElement semanticBasicElement = be as SemanticBasicElement;

            if (semanticBasicElement != null)
            {
                this._flowBuilder.AddStartNode(be.ElementType);
                XmlLanguage value = (XmlLanguage)this._fixedPage.GetValue(FrameworkElement.LanguageProperty);
                this._flowBuilder.FixedElement.SetValue(FixedElement.LanguageProperty, value);
                this.SpecialProcessing(semanticBasicElement);
                List <BlockElement> blockElementList = semanticBasicElement.BlockElementList;
                foreach (BlockElement be2 in blockElementList)
                {
                    this._CreateFlowNodes(be2);
                }
                this._flowBuilder.AddEndNode();
            }
        }
Exemple #8
0
        /// <summary>
        /// Validates a specified name according to the GraphQL <see href="http://spec.graphql.org/June2018/#sec-Names">specification</see>.
        /// </summary>
        /// <param name="name">GraphQL name.</param>
        /// <param name="type">Type of element: field, type, argument, enum or directive.</param>
        public static void ValidateDefault(string name, NamedElement type)
        {
            ValidateNameNotNull(name, type);

            if (name.Length > 1 && name[0] == '_' && name[1] == '_')
            {
                throw new ArgumentOutOfRangeException(nameof(name),
                                                      $"A {type.ToString().ToLower()} name: '{name}' must not begin with __, which is reserved by GraphQL introspection.");
            }

            var c = name[0];

            if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_')
            {
                ThrowMatchError();
            }

            for (int i = 1; i < name.Length; ++i)
            {
                c = name[i];
                if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_')
                {
                    ThrowMatchError();
                }
            }

            void ThrowMatchError()
            {
                throw new ArgumentOutOfRangeException(nameof(name),
                                                      $"A {type.ToString().ToLower()} name must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but '{name}' does not.");
            }
        }
Exemple #9
0
        public void CreateWithNamedIdentityAndOneElement()
        {
            NamedElement   identity = new NamedElement('e');
            NamedElement   aelement = new NamedElement('a');
            OperationTable table    = new OperationTable(new List <IElement>()
            {
                identity, aelement
            }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            table.SetValue(aelement, aelement, identity);

            Assert.IsTrue(table.HasIdentity);
            Assert.IsTrue(table.IsAssociative);
            Assert.IsTrue(table.IsClosed);
            Assert.IsTrue(table.IsCommutative);

            Assert.AreEqual(2, table.Elements.Count);

            Assert.AreEqual(identity, table.GetValue(identity, identity));
            Assert.AreEqual(aelement, table.GetValue(aelement, identity));
            Assert.AreEqual(aelement, table.GetValue(identity, aelement));
            Assert.AreEqual(identity, table.GetValue(aelement, aelement));

            Assert.AreEqual(1, identity.Order);
            Assert.AreEqual(2, aelement.Order);
        }
Exemple #10
0
        public void GetGroupsOfOrderFour()
        {
            NamedElement   identity = new NamedElement('e');
            NamedElement   aelement = new NamedElement('a');
            NamedElement   belement = new NamedElement('b');
            NamedElement   celement = new NamedElement('c');
            OperationTable table    = new OperationTable(new List <IElement>()
            {
                identity, aelement, belement, celement
            }, true);

            IList <OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(4, solutions.Count);

            foreach (OperationTable solution in solutions)
            {
                Assert.IsTrue(solution.IsClosed);
                Assert.IsTrue(solution.IsCommutative);
            }

            IList <IGroup> groups = new List <IGroup>();

            foreach (OperationTable ot in solutions)
            {
                groups.Add(new TableGroup(ot));
            }

            IList <IGroup> dgroups = GroupUtilities.GetNonIsomorphic(groups);

            Assert.IsNotNull(dgroups);
            Assert.AreEqual(2, dgroups.Count);
        }
Exemple #11
0
        /// <summary>
        /// Contructs a classes based on the element type
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        static public CreateLabels construct(NamedElement element)
        {
            // TODO: Add here new elements constructors
            switch (element.GetType().Name)
            {
            case "Table":
                return(new CreateLabels_Table(element as Table));

            case "View":
                return(new CreateLabels_View(element as View));

            case "EdtBase":
            case "EdtString":
            case "EdtContainer":
            case "EdtDate":
            case "EdtEnum":
            case "EdtDateTime":
            case "EdtGuid":
            case "EdtReal":
            case "EdtInt":
            case "EdtInt64":
                return(new CreateLabels_Edt(element as EdtBase));

            case "BaseEnum":
                return(new CreateLabels_BaseEnum(element as BaseEnum));

            case "BaseEnumExtension":
                return(new CreateLabels_BaseEnumExtension(element as BaseEnumExtension));

            case "MenuItem":
            case "MenuItemAction":
            case "MenuItemDisplay":
            case "MenuItemOutput":
                return(new CreateLabels_MenuItem(element as MenuItem));

            case "Form":
                return(new CreateLabels_Form(element as Form));

            case "SecurityPrivilege":
                return(new CreateLabels_SecurityPrivilege(element as SecurityPrivilege));

            case "WorkflowHierarchyAssignmentProvider":
                return(new CreateLabels_WorkflowHierarchyAssignmentProvider(element as WorkflowHierarchyAssignmentProvider));

            case "WorkflowApproval":
                return(new CreateLabels_WorkflowApproval(element as WorkflowApproval));

            case "WorkflowCategory":
                return(new CreateLabels_WorkflowCategory(element as WorkflowCategory));

            case "WorkflowTask":
                return(new CreateLabels_WorkflowTask(element as WorkflowTask));

            case "WorkflowTemplate":    //WorkflowType Object
                return(new CreateLabels_WorkflowType(element as WorkflowTemplate));

            default:
                throw new NotImplementedException($"The type {element.GetType().Name} is not implemented.");
            }
        }
Exemple #12
0
 //TODO: maybe remove after
 internal static void ValidateNameNotNull(string name, NamedElement type)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentOutOfRangeException(nameof(name),
                                               $"A {type.ToString().ToLower()} name can not be null or empty.");
     }
 }
Exemple #13
0
        public void DifferentNameAreNotEqual()
        {
            NamedElement element1 = new NamedElement('a');
            NamedElement element2 = new NamedElement('b');

            Assert.AreNotEqual(element1, element2);
            Assert.AreNotEqual(element1.GetHashCode(), element2.GetHashCode());
        }
Exemple #14
0
        public void DifferentNameAreNotEqual()
        {
            NamedElement element1 = new NamedElement('a');
            NamedElement element2 = new NamedElement('b');

            Assert.AreNotEqual(element1, element2);
            Assert.AreNotEqual(element1.GetHashCode(), element2.GetHashCode());
        }
        public static void ChangeOntologyEquivalent(NamedElement element, string newOntoEquiv, ModelController controller)
        {
            ChangeOntologyEquivalentCommand command = ChangeOntologyEquivalentCommandFactory.Factory().Create(controller) as ChangeOntologyEquivalentCommand;

            command.Element      = element;
            command.NewOntoEquiv = newOntoEquiv;
            command.Execute();
        }
Exemple #16
0
        public void SameNameAreEqual()
        {
            NamedElement element1 = new NamedElement('a');
            NamedElement element2 = new NamedElement('a');

            Assert.AreEqual(element1, element2);
            Assert.AreEqual(element1.GetHashCode(), element2.GetHashCode());
        }
Exemple #17
0
        public void SameNameAreEqual()
        {
            NamedElement element1 = new NamedElement('a');
            NamedElement element2 = new NamedElement('a');

            Assert.AreEqual(element1, element2);
            Assert.AreEqual(element1.GetHashCode(), element2.GetHashCode());
        }
Exemple #18
0
 protected MappingNode(NamedElement source, MappingNode parent, MappingSettings settings, MP.ModelStructure structure, NamedElement virtualOwner)
 {
     this.source   = source;
     this.parent   = parent;
     this.settings = settings;
     this.parent?.addChildNode(this);
     this.structure    = structure;
     this.virtualOwner = virtualOwner;
 }
Exemple #19
0
        public string Visit(NamedElement value)
        {
            IEnumerable <string> textList = value.Attributes.Where(o => o.Attribute == "text").Select(o => o.Accept(valueVisitor));
            IEnumerable <string> attrList = value.Attributes.Where(o => o.Attribute != "text").Select(o => o.Accept(valueVisitor));

            // Get values that could only be attributes in html
            IEnumerable <string> objList = ResolveChildElementsOptions(value.Children).Select(o => o.Accept(this));

            return(HtmlGenerator.CreateHtmlTag(value.Identifier, textList, attrList, objList));
        }
Exemple #20
0
        public void ModifiedElementMatches()
        {
            var element = new NamedElement {
                Name = "new item"
            };
            var vm = new TestElementViewModel(new Mock <IAsyncServiceProvider> ().Object, new Mock <ISyncService>().Object, element);

            Assert.That(vm.Element, Is.EqualTo(element));
            Assert.That(vm.ModifiedElement, Is.EqualTo(element));
        }
Exemple #21
0
 string GetName(NamedElement E)
 {
     if (E.OntologyEquivalent == null || E.OntologyEquivalent.Length == 0)
     {
         return(E.OntologyEquivalent = nsproject.NamespaceName + '#' + E.Name);
     }
     else
     {
         return(E.OntologyEquivalent);
     }
 }
Exemple #22
0
        private static void ProcessVariable(ApiContainer apiContainer, XmlNode memberNode, string namespaceName, bool isClassMember)
        {
            NamedElement namedElement = GetNamedElement(memberNode);

            if (namedElement != null)
            {
                apiContainer.Variables.Add(new Variable(namespaceName, namedElement.Name, namedElement.Type,
                                                        namedElement.TypeInfo, Xml.GetIsStatic(memberNode), isClassMember, namedElement.IsConstant, namedElement.IsReference,
                                                        namedElement.IsRawPointer, namedElement.IsSharedPointer, namedElement.IsUniquePointer));
            }
        }
Exemple #23
0
        /// <summary>
        /// load only the mappings for the given source element
        /// </summary>
        /// <param name="sourceElement">the element to start from</param>
        public void loadMappings(NamedElement sourceElement)
        {
            var mappingNode = MappingFactory.getMappingNode(sourceElement, (MappingNode)this.source);

            mappingNode.getMappings();
            //if we are showing a partial mapping then we show all elements
            if (!mappingNode.getOwnedMappings().Any())
            {
                this.showAll(this.source);
            }
        }
        private ElementBehavior <TInstance> Behaviour(NamedElement element)
        {
            var result = default(ElementBehavior <TInstance>);

            if (this.behaviours.TryGetValue(element, out result) == false)
            {
                this.behaviours.Add(element, result = new ElementBehavior <TInstance>());
            }

            return(result);
        }
        public void GetCompatibleOperationTable()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            OperationTable table2 = table.GetCompatibleTable(aelement, aelement, identity);
            Assert.IsNotNull(table2);
            Assert.AreNotSame(table2, table);
        }
Exemple #26
0
        /// <summary>
        /// Searches the collection for an element having given qualified name.
        /// The qualified name has to be rooted at the level of the elements in the searched collection.
        /// </summary>
        /// <typeparam name="T">Type of the collection items</typeparam>
        /// <param name="col">Collection to be searched for the element</param>
        /// <param name="qName">Qualified name of the element being searched</param>
        /// <returns>Reference to the searched element if found, null otherwise</returns>
        public static NamedElement GetByQualifiedName <T>(this IEnumerable <T> col, string qName) where T : NamedElement
        {
            foreach (T item in col)
            {
                NamedElement ne = item.GetChildByQualifiedName(qName);
                if (ne != null)
                {
                    return(ne);
                }
            }

            return(null);
        }
Exemple #27
0
        public static bool IsValidName(this string?name, NamedElement type)
        {
            try
            {
                NameValidator.ValidateDefault(name !, type);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #28
0
        public NewFieldEngine(Addin.Controlling controller, NamedElement namedElement)
        {
            this.controller   = controller;
            this.namedElement = namedElement;

            Enum.TryParse <FieldType>(this.controller.comboBoxFieldType.SelectedValue.ToString(), out fieldType);

            this.fieldName    = this.controller.textBoxFieldName.Text;
            this.edtIndex     = this.controller.comboBoxEDTName.SelectedIndex;
            this.edtText      = this.controller.comboBoxEDTName.Text;
            this.extendsIndex = this.controller.comboBoxExtends.SelectedIndex;
            this.extendsText  = this.controller.comboBoxExtends.Text;
        }
        static public IElement construct(NamedElement namedElement)
        {
            IElement element = null;

            #region Chose element by type
            switch (namedElement.GetType().Name)
            {
            case "Table":
                element = new ElementTable(namedElement);
                break;

            case "TableExtension":
                element = new ElementTableExtension(namedElement);
                break;

            case "View":
                element = new ElementView(namedElement);
                break;

            case "ClassItem":
                element = new ElementClassItem(namedElement);
                break;

            case "SimpleQuery":
                element = new ElementSimpleQuery(namedElement);
                break;

            case "CompositeQuery":
                element = new ElementCompositeQuery(namedElement);
                break;

            case "Form":
                element = new ElementForm(namedElement);
                break;

            case "FormExtension":
                element = new ElementFormExtension(namedElement);
                break;

            case "DataEntityView":
                element = new ElementDataEntityView(namedElement);
                break;

            default:
                throw new NotImplementedException($"Not implemented type: {namedElement.GetType().Name}");
            }
            #endregion

            return(element);
        }
Exemple #30
0
        public void SaveEnabledOnNewItem()
        {
            var sync = new Mock <ISyncService> ();

            sync.Setup(s => s.SaveElementAsync(It.IsAny <NamedElement> ()))
            .Returns <NamedElement> (ne => Task.FromResult(ne));

            var element = new NamedElement {
                Name = "new item"
            };
            var vm = new TestElementViewModel(new Mock <IAsyncServiceProvider> ().Object, sync.Object, element);

            Assert.That(vm.SaveCommand.CanExecute(null), Is.True);
        }
Exemple #31
0
        public override void eSet(int featureID, object newValue)
        {
            switch (featureID)
            {
            case Java_PackageImpl.IMPORTDECLARATION_STATIC:
                static_ = (bool)newValue;
                return;

            case Java_PackageImpl.IMPORTDECLARATION_IMPORTEDELEMENT:
                importedElement = (NamedElement)newValue;
                return;
            }
            base.eSet(featureID, newValue);
        }
Exemple #32
0
        public void GetIncompatibleOperationTableIfValueIsAlreadyInRowOrColumn()
        {
            NamedElement   identity = new NamedElement('e');
            NamedElement   aelement = new NamedElement('a');
            OperationTable table    = new OperationTable(new List <IElement>()
            {
                identity, aelement
            }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            Assert.IsNull(table.GetCompatibleTable(aelement, aelement, aelement));
        }
Exemple #33
0
        public NewFieldEngine(Addin.Controlling controller, NamedElement namedElement)
        {
            this.controller   = controller;
            this.namedElement = namedElement;

            Enum.TryParse <FieldType>(this.controller.comboBoxFieldType.SelectedValue.ToString(), out fieldType);

            this.fieldName    = this.controller.textBoxFieldName.Text;
            this.edtText      = this.controller.comboBoxEDTName.Text;
            this.extendsText  = this.controller.comboBoxExtends.Text;
            this.labelText    = this.controller.textBoxLabel.Text;
            this.helpTextText = this.controller.textBoxHelpText.Text;

            int.TryParse(this.controller.textBoxStrLen.Text, out newStrEDTLen);
        }
        public void CreateWithNamedIdentity()
        {
            NamedElement identity = new NamedElement('e');
            OperationTable table = new OperationTable(new List<IElement>() { identity }, true);

            identity.OperationTable = table;

            Assert.IsTrue(table.HasIdentity);
            Assert.IsTrue(table.IsAssociative);
            Assert.IsTrue(table.IsClosed);
            Assert.IsTrue(table.IsCommutative);

            Assert.AreEqual(identity, table.GetValue(identity, identity));

            Assert.AreEqual(1, identity.Order);
        }
Exemple #35
0
        public void GetGroupsOfOrderThree()
        {
            NamedElement   identity = new NamedElement('e');
            NamedElement   aelement = new NamedElement('a');
            NamedElement   belement = new NamedElement('b');
            OperationTable table    = new OperationTable(new List <IElement>()
            {
                identity, aelement, belement
            }, true);

            IList <OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(1, solutions.Count);
            Assert.IsTrue(solutions[0].IsClosed);
        }
Exemple #36
0
		internal NamedElement (string name, NamedElement parent) {
			this.Name = name;
			this.QualifiedName = parent != null ? (parent.QualifiedName + NamespaceSeparator + name) : name;
		}
        public void GetGroupsOfOrderTwo()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement }, true);

            IList<OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(1, solutions.Count);
            Assert.IsTrue(solutions[0].IsClosed);
            Assert.IsTrue(solutions[0].IsAssociative);
        }
        public void GetIncompatibleOperationTableIfValueIsAlreadyInRowOrColumn()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            Assert.IsNull(table.GetCompatibleTable(aelement, aelement, aelement));
        }
        public void GetCompatibleOperationTableUsingAssociationExpansion()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            NamedElement belement = new NamedElement('b');
            NamedElement celement = new NamedElement('c');

            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement, belement, celement }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;
            belement.OperationTable = table;
            celement.OperationTable = table;

            table = table.GetCompatibleTable(aelement, belement, celement);
            Assert.IsNotNull(table);

            table = table.GetCompatibleTable(belement, aelement, celement);
            Assert.IsNotNull(table);

            // bc undefined
            Assert.IsNull(table.GetValue(belement, celement));

            table = table.GetCompatibleTable(belement, celement, identity);

            Assert.IsNotNull(table);

            // bc = e, ba = c = ab -> cb = e
            Assert.AreEqual(identity, table.GetValue(celement, belement));

            // but is not complete, yet
            Assert.IsFalse(table.IsClosed);

            IList<OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(1, solutions.Count);
            Assert.IsTrue(solutions[0].IsClosed);
        }
Exemple #40
0
 /// <summary>
 /// Implements the constructor: NamedElement()
 /// </summary>
 public virtual void NamedElement(NamedElement @this)
 {
 }
        public void GetGroupsOfOrderFour()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            NamedElement belement = new NamedElement('b');
            NamedElement celement = new NamedElement('c');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement, belement, celement }, true);

            IList<OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(4, solutions.Count);

            foreach (OperationTable solution in solutions)
            {
                Assert.IsTrue(solution.IsClosed);
                Assert.IsTrue(solution.IsCommutative);
            }

            IList<IGroup> groups = new List<IGroup>();

            foreach (OperationTable ot in solutions)
                groups.Add(new TableGroup(ot));

            IList<IGroup> dgroups = GroupUtilities.GetNonIsomorphic(groups);

            Assert.IsNotNull(dgroups);
            Assert.AreEqual(2, dgroups.Count);
        }