public void Calculates_hash_code_based_on_criterion() { CriterionSet set1 = new CriterionSet(); Criterion criterion1 = new Criterion("A1", "V1", ComparisonOperator.Equal); Criterion criterion2 = new Criterion("A2", "V2", ComparisonOperator.Equal); set1.AddCriterion(criterion1); set1.AddCriterion(criterion2); Assert.That(set1.GetHashCode(), Is.EqualTo(criterion1.GetHashCode() + criterion2.GetHashCode())); }
public CriterionRow(IGraphElementModel graphElementModel, CriteriaModel criteriaModel, Criterion criterion, Stencil stencil, Store store, ExpandedContainer parentElement, Action <EventBase> onDeleteCriterion) : base(string.Empty, graphElementModel as ComponentQueryDeclarationModel, store, parentElement, null, null) { GraphElementModel = graphElementModel; CriteriaModel = criteriaModel; Criterion = criterion ?? throw new ArgumentNullException(nameof(criterion), "criterion should not be null"); ClearClassList(); AddToClassList("criterionRow"); capabilities |= Capabilities.Selectable | Capabilities.Deletable; styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UnityEditor.VisualScripting.Editor.UICreationHelper.templatePath + "PropertyField.uss")); var deleteCriterionButton = new Button { name = "deleteCriterionIcon" }; deleteCriterionButton.clickable.clickedWithEventInfo += onDeleteCriterion; ExpandableRowTitleContainer.Insert(0, deleteCriterionButton); userData = criterion.GetHashCode(); var criterionContainer = new VisualElement { name = "rowCriterionContainer" }; string criterionNamespace = criterion.ObjectType.GetMetadata(stencil).Namespace; string criterionName = criterion.ObjectType.ToTypeSyntax(stencil).ToString().Replace(criterionNamespace + ".", ""); var criterionStr = new StringBuilder(criterionName); if (criterion.Member.Path.Any()) { criterionStr.Append(" > "); criterionStr.Append(string.Join(" > ", criterion.Member.Path)); } var criterionPillContainer = new VisualElement { name = "rowPillContainer" }; var criterionPill = new Pill { text = criterionStr.ToString() }; criterionPillContainer.Add(criterionPill); criterionPillContainer.Add(new Label() { name = "criterionOperatorKind", text = criterion.Operator.NicifyBinaryOperationKindName(OperatorExtensions.NicifyBinaryOperationKindType.String) }); // TODO SERIALIZATION // if (criterion.Value.NodeAssetReference != null) // m_WatchedObject = new SerializedObject(criterion.Value.NodeAssetReference); m_EditorElement = SetupConstantEditor(criterion.Value); var label = m_EditorElement.Q <Label>(); if (label != null && !EditorNeedsLabel) { label.style.width = 0; } criterionPillContainer.Add(m_EditorElement); criterionContainer.Add(criterionPillContainer); ExpandableRowTitleContainer.Add(criterionContainer); // CriterionRow's are NOT expandable (for now, until we find a reason to) but since we need everything // else that is provided by SortableExpandableRow, we'll just disable expansion altogether ExpandedButton.style.display = DisplayStyle.None; RegisterCallback <AttachToPanelEvent>(OnAttachToPanel); RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel); this.AddManipulator(new ContextualMenuManipulator(OnContextualMenuEvent)); }
public override int GetHashCode() => Criterion?.GetHashCode() ?? 0;