private Constant(Constant iiToCopyFrom) : base(null) { iiToCopyFrom.CloneInto(this); DataType = iiToCopyFrom.DataType.Clone(); Expression = iiToCopyFrom.Expression; Modifiers = new List<string>(iiToCopyFrom.Modifiers); }
public void Constant() { Constant inter = new Constant(controller); inter.DataType = new DataType(controller,"int"); inter.Modifiers.Add("public"); inter.Name = "CONSTANT1"; Assert.That(inter.IsTheSame(inter.Clone(), ComparisonDepth.Outer), Is.True); }
public void Constant() { Constant con = new Constant(controller, "VALUE_1", new DataType(controller, "int")); Assert.That(con.FullyQualifiedDisplayName, Is.EqualTo("VALUE_1")); Class cl = new Class(controller, "Class1"); cl.AddChild(con); Assert.That(con.FullyQualifiedDisplayName, Is.EqualTo("Class1.VALUE_1")); }
public VBConstantPrinter(Constant obj) { this.obj = obj; }
public void Constant_Changed_Type_And_Expression() { const string constName = "MyConstName1"; const string expresssion1 = "MyExpression1"; const string expresssion2 = "MyExpression2"; DataType type1 = new DataType(controller, DataType1); DataType type2 = new DataType(controller, DataType2); string expectedResult = String.Format("const {0} {1} = {2}", DataType2, constName, expresssion2); Constant merged1 = new Constant(controller); Constant merged2 = new Constant(controller); Constant merged3 = new Constant(controller); Constant changing = new Constant(controller, constName, type2, expresssion2); Constant unchanging = new Constant(controller, constName, type1, expresssion1); Merge_And_Assert(merged1, merged2, merged3, changing, unchanging, expectedResult); }
public void Constant_Added_Modifier() { const string constName = "MyConstName1"; const string expresssion = "MyExpression1"; DataType type1 = new DataType(controller, DataType1); string expectedResult = String.Format("{0} const {1} {2} = {3}", Modifier1, DataType1, constName, expresssion); Constant merged1 = new Constant(controller); Constant merged2 = new Constant(controller); Constant merged3 = new Constant(controller); Constant changing = new Constant(controller, constName, type1, expresssion); changing.Modifiers.Add(Modifier1); Constant unchanging = new Constant(controller, constName, type1, expresssion); Merge_And_Assert(merged1, merged2, merged3, changing, unchanging, expectedResult); }
private bool IsTheSame(Constant comparisonConstant, ComparisonDepth depth) { if (comparisonConstant == null) return false; if (Name == comparisonConstant.Name) { // Function names are the same, so now compare the class names //bool parentClassesTheSame = false; //if (ParentObject == null) //{ // parentClassesTheSame = comparisonConstant.ParentObject == null; //} //else if (comparisonConstant.ParentObject == null) //{ // // thisParentClass is obviously not null, because we checked above, so the classes are different //} //else //{ // parentClassesTheSame = ParentObject.IsTheSame(comparisonConstant.ParentObject); //} //if (parentClassesTheSame) //{ if (depth == ComparisonDepth.Signature) { return true; } if (DataType != comparisonConstant.DataType) return false; if (!base.IsTheSame(comparisonConstant, depth)) { return false; } if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.StringCollectionsAreTheSame(Modifiers, comparisonConstant.Modifiers)) { ComparisonDifference += GetType().Name + ".Modifiers"; return false; } if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.BaseContructCollectionsAreTheSame(Attributes.ToArray(), comparisonConstant.Attributes.ToArray())) { ComparisonDifference += GetType().Name + ".Attributes"; return false; } //} return true; } return false; }
private bool IsTheSame(Constant comparisonConstant) { return IsTheSame(comparisonConstant, ComparisonDepth.Signature); }
public void Constant() { Constant con = new Constant(controller); con.DataType = new DataType(controller,"int"); con.Modifiers.Add("public"); con.Name = "CONSTANT1"; con.Expression = "5"; CodeRoot root = CreateClassAndNamespace(con); CodeRootMap map = new CodeRootMap(); map.AddCodeRoot(root, Version.User); map.AddCodeRoot(root, Version.NewGen); map.AddCodeRoot(root, Version.PrevGen); string result = map.GetMergedCodeRoot().ToString(); Assert.That(result, Is.EqualTo(root.ToString())); Assertions.StringContains(result, "class Class1"); Assertions.StringContains(result, "[Serializable(true)]"); Assertions.StringContains(result, "namespace ArchAngel.Tests"); Assertions.StringContains(result, "public const int CONSTANT1 = 5;"); }
public void AddConstant(Constant con) { Constant existingConst = FindConstant(con.Name); if (existingConst == null) { Constant[] newConstants = new Constant[Constants.Length + 1]; Array.Copy(Constants, newConstants, Constants.Length); newConstants[newConstants.Length - 1] = con; Constants = newConstants; SortConstants(); IsDirty = true; } else { // Make sure the existing user option and the new user option match if (con != existingConst) { throw new Exception("A Constant with the same name as an existing Constant has attempted to be added, but it's values are different. Not added."); } } }