/// <summary> /// Adds the given fields to the given type. /// </summary> /// <param name="type">The entity to add the fields to.</param> /// <param name="fields">A list of fields to add.</param> private void AddFields(SingleInharitanceType type, IEnumerable <NRField> fields) { foreach (NRField nrField in fields) { type.AddField().InitFromString(nrField.Declaration()); } }
/// <summary> /// Adds the given operators to the given type. /// </summary> /// <param name="type">The entity to add the operators to.</param> /// <param name="operators">A list of operators to add.</param> private void AddOperators(SingleInharitanceType type, IEnumerable <NROperator> operators) { foreach (var nrOperator in operators) { type.AddMethod().InitFromString(nrOperator.Declaration()); } }
/// <summary> /// Adds the given constructors to the given type. /// </summary> /// <param name="type">The entity to add the constructors to.</param> /// <param name="constructors">A list of constructors to add.</param> private void AddConstructors(SingleInharitanceType type, IEnumerable <NRConstructor> constructors) { foreach (var nrConstructor in constructors) { type.AddConstructor().InitFromString(nrConstructor.Declaration()); } }
public DialogResult ShowDialog(SingleInharitanceType inheritedClass) { if (inheritedClass == null) { return(DialogResult.None); } OperationTree.Nodes.Clear(); AddOperations(inheritedClass, inheritedClass.Base); RemoveEmptyNodes(); return(ShowDialog()); }
/// <summary> /// Adds the given fields to the given type. /// </summary> /// <param name="type">The entity to add the fields to.</param> /// <param name="tp">.</param> private void AddFields(SingleInharitanceType type, TypeDeclaration tp) { foreach (FieldDeclaration fp in tp.Descendants.OfType <FieldDeclaration>()) { var variable = fp.Variables.First(); if (variable == null) { continue; } Field fld = type.AddField(); fld.Name = variable.Name; fld.AccessModifier = fp.Modifiers.ToEnClass(); fld.Type = fp.ReturnType.ToString(); fld.InitialValue = variable.LastChild.ToString(); } }
private void toolOverrideList_Click(object sender, EventArgs e) { SingleInharitanceType type = Shape.CompositeType as SingleInharitanceType; if (type != null) { using (OverrideDialog dialog = new OverrideDialog()) { if (dialog.ShowDialog(type) == DialogResult.OK) { foreach (Operation operation in dialog.GetSelectedOperations()) { type.Override(operation); } } } } }
private void toolOverrideList_Click(object sender, EventArgs e) { if (parent is SingleInharitanceType) { SingleInharitanceType derivedType = (SingleInharitanceType)parent; using (OverrideDialog dialog = new OverrideDialog()) { if (dialog.ShowDialog(derivedType) == DialogResult.OK) { foreach (Operation operation in dialog.GetSelectedOperations()) { Operation overridden = (derivedType).Override(operation); AddOperationToList(overridden); } OnContentsChanged(EventArgs.Empty); } } } }
private void AddOperations(SingleInharitanceType derivedClass, SingleInharitanceType baseClass) { if ((derivedClass == null) || (baseClass == null)) { return; } AddOperations(derivedClass, baseClass.Base); TreeNode node = CreateClassNode(baseClass.Name); foreach (Operation operation in baseClass.OverridableOperations) { if (derivedClass.GetDefinedOperation(operation) != null) { continue; } RemoveSimilarNode(operation); CreateOperationNode(node, operation); } }