public Line Discretize(bool adaptive = true) { if (ElementA != null && ElementB != null) { return(new Line( ElementA.GetConnectionPoint(ParameterA), ElementB.GetConnectionPoint(ParameterB))); } return(Line.Unset); }
public static void Main(string[] args) { IVisitor visitor = new VisitorA(); IElement element; element = new ElementA(); element.Accept(visitor); element = new ElementB(); element.Accept(visitor); }
public void DependencyPropertyAmbiguityTest() { ElementB element = new ElementB(); element.SetValue(ElementA.Value0Property, 1); element.SetValue(ElementB.Value0Property2, 2); Assert.AreEqual(1, element.GetValue(ElementA.Value0Property)); Assert.AreEqual(2, element.GetValue(ElementB.Value0Property2)); Assert.AreEqual(ElementA.Value0Property, DependencyProperty.GetProperty(typeof(ElementA), "Value0")); Assert.AreEqual(ElementB.Value0Property2, DependencyProperty.GetProperty(typeof(ElementB), "Value0")); }
public void OverrideMetadataDefaultValueTest() { ElementA element1 = new ElementA(); ElementB element2 = new ElementB(); ElementC element3 = new ElementC(); ElementD element4 = new ElementD(); int propertyChangedCount = 0; element1.PropertyChanged += (sender, e) => propertyChangedCount++; element2.PropertyChanged += (sender, e) => propertyChangedCount++; element3.PropertyChanged += (sender, e) => propertyChangedCount++; element4.PropertyChanged += (sender, e) => propertyChangedCount++; Assert.AreEqual(1, element1.GetValue(ElementA.Value1Property)); Assert.AreEqual(2, element2.GetValue(ElementA.Value1Property)); Assert.AreEqual(3, element3.GetValue(ElementA.Value1Property)); Assert.AreEqual(4, element4.GetValue(ElementA.Value1Property)); Assert.AreEqual(1, element1.GetValue(ElementA.Value2Property)); Assert.AreEqual(2, element2.GetValue(ElementA.Value2Property)); Assert.AreEqual(3, element3.GetValue(ElementA.Value2Property)); Assert.AreEqual(4, element4.GetValue(ElementA.Value2Property)); element1.SetValue(ElementA.Value1Property, 1); element2.SetValue(ElementA.Value1Property, 2); element3.SetValue(ElementA.Value1Property, 3); element4.SetValue(ElementA.Value1Property, 4); Assert.AreEqual(0, propertyChangedCount); element1.SetValue(ElementA.Value1Property, 100); Assert.AreEqual(1, propertyChangedCount); element1.SetValue(ElementA.Value2Property, 1); element2.SetValue(ElementA.Value2Property, 2); element3.SetValue(ElementA.Value2Property, 3); element4.SetValue(ElementA.Value2Property, 4); Assert.AreEqual(1, propertyChangedCount); element1.SetValue(ElementA.Value2Property, 100); Assert.AreEqual(2, propertyChangedCount); }
public void AttachedOverrideMetadataCallbackTest() { ElementA element1 = new ElementA(); ElementB element2 = new ElementB(); ElementC element3 = new ElementC(); ElementD element4 = new ElementD(); int changeIndex = 1; int value2AChangedIndex = 0; int value2BChangedIndex = 0; int value2CChangedIndex = 0; int value2DChangedIndex = 0; ElementA.Value2ChangedA += (sender, e) => value2AChangedIndex = changeIndex++; ElementB.Value2ChangedB += (sender, e) => value2BChangedIndex = changeIndex++; ElementC.Value2ChangedC += (sender, e) => value2CChangedIndex = changeIndex++; ElementD.Value2ChangedD += (sender, e) => value2DChangedIndex = changeIndex++; element1.SetValue(ElementA.Value2Property, 100); Assert.AreEqual(1, value2AChangedIndex); Assert.AreEqual(0, value2BChangedIndex); Assert.AreEqual(0, value2CChangedIndex); Assert.AreEqual(0, value2DChangedIndex); element2.SetValue(ElementA.Value2Property, 100); Assert.AreEqual(2, value2AChangedIndex); Assert.AreEqual(3, value2BChangedIndex); Assert.AreEqual(0, value2CChangedIndex); Assert.AreEqual(0, value2DChangedIndex); element3.SetValue(ElementA.Value2Property, 100); Assert.AreEqual(4, value2AChangedIndex); Assert.AreEqual(5, value2BChangedIndex); Assert.AreEqual(6, value2CChangedIndex); Assert.AreEqual(0, value2DChangedIndex); element4.SetValue(ElementA.Value2Property, 100); Assert.AreEqual(7, value2AChangedIndex); Assert.AreEqual(5, value2BChangedIndex); Assert.AreEqual(6, value2CChangedIndex); Assert.AreEqual(8, value2DChangedIndex); }
public void VisitorsTest() { IVisitor visitorA = new VisitorA(); IVisitor visitorB = new VisitorB(); Element elementA = new ElementA(); Element elementB = new ElementB(); elementA.Accept(visitorA); Assert.Equal("Visitor A For Element A", elementA.ProcessElement()); elementA.Accept(visitorB); Assert.Equal("Visitor B For Element A", elementA.ProcessElement()); elementB.Accept(visitorA); Assert.Equal("Visitor A For Element B", elementB.ProcessElement()); elementB.Accept(visitorB); Assert.Equal("Visitor B For Element B", elementB.ProcessElement()); }
public void DependencyPropertyAmbiguityTest() { ElementB element = new ElementB(); element.SetValue(ElementA.Value0Property, 1); element.SetValue(ElementB.Value0Property2, 2); Assert.AreEqual(1, element.GetValue(ElementA.Value0Property)); Assert.AreEqual(2, element.GetValue(ElementB.Value0Property2)); Assert.AreEqual(ElementA.Value0Property, DependencyProperty.GetOwnedProperty(typeof(ElementA), "Value0")); Assert.AreEqual(ElementB.Value0Property2, DependencyProperty.GetOwnedProperty(typeof(ElementB), "Value0")); DependencyProperty[] elementAProperties = new [] { ElementA.Value0Property, ElementA.Value1Property, ElementA.Value2Property, ElementA.Value3Property }; DependencyProperty[] elementBProperties = new [] { ElementB.Value0Property2 }; CollectionAssert.AreEqual(elementAProperties, DependencyProperty.GetProperties(typeof(ElementA)).ToArray()); CollectionAssert.AreEqual(elementBProperties, DependencyProperty.GetProperties(typeof(ElementB)).ToArray()); CollectionAssert.AreEqual(elementAProperties.Concat(elementBProperties).Cast <object>().ToArray(), DependencyProperty.GetFlattenedProperties(typeof(ElementB)).ToArray()); try { DependencyProperty.GetSingleProperty(typeof(ElementB), "Value0"); Assert.Fail(); } catch { // } try { ElementA.Value0Property.AddOwner(typeof(ElementB)); Assert.Fail(); } catch { // } }
/// <summary> /// Vérifie que le lien est cohérent /// </summary> /// <returns></returns> public CResultAErreur ControleCoherenceLien() { CResultAErreur result = CResultAErreur.True; if (ProjetA != null && ProjetB != null) { if (ProjetA.IsChildOf(ProjetB)) { result.EmpileErreur(I.T("Link between @1 and @2 is invalide, because @1 is parent of @2|20072", ProjetB.Libelle, ProjetA.Libelle)); } if (result && ProjetB.IsChildOf(ProjetA)) { result.EmpileErreur(I.T("Link between @1 and @2 is invalide, because @1 is parent of @2|20072", ProjetA.Libelle, ProjetB.Libelle)); } } if (ElementA != null && ElementB != null && result) { HashSet <IElementDeProjetPlanifiable> set = new HashSet <IElementDeProjetPlanifiable>(); ElementA.FillDicPredecesseurs(set); if (set.Contains(ElementB)) { result.EmpileErreur(I.T("Link between @1 and @2 provokes a cyclic dependence|20073", ElementA.DescriptionElement, ElementB.DescriptionElement)); } if (result) { set.Clear(); ElementB.FillDicSuccesseurs(set); if (set.Contains(ElementA)) { result.EmpileErreur(I.T("Link between @1 and @2 provokes a cyclic dependence|20073", ElementA.DescriptionElement, ElementB.DescriptionElement)); } } } return(result); }
public override void VisitElementB(ElementB elementB) { elementB.OperationB(); }
public void Visit(ElementB b) { b.Print(); }
public abstract void VisitElementB(ElementB elemB);
public void VisitElementB(ElementB element) { element.OperationB(); }