/// <summary> /// Creates a single target /// </summary> /// <param name="start"></param> /// <param name="length"></param> /// <param name="speed"></param> /// <returns></returns> private StructureValue CreateTarget(double start, double length, double speed) { NameSpace defaultNameSpace = OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default"); Structure structureType = (Structure) EFSSystem.FindType( defaultNameSpace, "TargetStruct"); StructureValue value = new StructureValue(structureType); Field speedV = value.CreateField(value, "Speed", structureType); speedV.Value = new DoubleValue(EFSSystem.DoubleType, speed); Field location = value.CreateField(value, "Location", structureType); location.Value = new DoubleValue(EFSSystem.DoubleType, start); Field lengthV = value.CreateField(value, "Length", structureType); lengthV.Value = new DoubleValue(EFSSystem.DoubleType, length); Enum targetType = (Enum)EFSSystem.FindType(defaultNameSpace, "TargetTypeEnum"); Field type = value.CreateField(value, "Type", structureType); type.Value = targetType.DefaultValue; return(value); }
/// <summary> /// Creates a copy of the procedure in the designated dictionary. The namespace structure is copied over. /// The new procedure is set to update this one. /// </summary> /// <param name="dictionary">The target dictionary of the copy</param> /// <returns></returns> public Procedure CreateProcedureUpdate(Dictionary dictionary) { Procedure retVal = (Procedure)Duplicate(); retVal.SetUpdateInformation(this); retVal.ClearAllRequirements(); String[] names = FullName.Split('.'); names = names.Take(names.Count() - 1).ToArray(); if (Enclosing is NameSpace) { NameSpace nameSpace = dictionary.GetNameSpaceUpdate(names, Dictionary); nameSpace.appendProcedures(retVal); } else { String[] nameSpaceRef = names.Take(names.Count() - 1).ToArray(); if (Enclosing is Structure) { NameSpace nameSpace = dictionary.GetNameSpaceUpdate(nameSpaceRef, Dictionary); Structure structure = nameSpace.GetStructureUpdate(names.Last(), (NameSpace)nameSpace.Updates); structure.appendProcedures(retVal); } } return(retVal); }
/// <summary> /// Creates a function which gets the field named "fieldName" from one of the subfield of the structure provided as parameter /// </summary> /// <param name="nameSpace">The namespace in which the function should be created</param> /// <param name="structure">The structure which should be looked for</param> /// <param name="subField">The name of the subfield to look for</param> /// <param name="returnType">The function return type</param> private void AppendGetFunction(DataDictionary.Types.NameSpace nameSpace, DataDictionary.Types.Structure structure, string subField, string returnType) { DataDictionary.Functions.Function getFunction = (DataDictionary.Functions.Function)DataDictionary.Generated.acceptor.getFactory().createFunction(); getFunction.Name = subField; getFunction.setTypeName(returnType); DataDictionary.Parameter param = (DataDictionary.Parameter)DataDictionary.Generated.acceptor.getFactory().createParameter(); param.Name = "msg"; param.TypeName = structure.Name; getFunction.appendParameters(param); foreach (DataDictionary.Types.StructureElement element in structure.Elements) { DataDictionary.Functions.Case cas = (DataDictionary.Functions.Case)DataDictionary.Generated.acceptor.getFactory().createCase(); DataDictionary.Rules.PreCondition condition = (DataDictionary.Rules.PreCondition)DataDictionary.Generated.acceptor.getFactory().createPreCondition(); condition.Expression = "msg." + element.Name + " != EMPTY"; cas.appendPreConditions(condition); cas.ExpressionText = "msg." + element.Name + "." + subField; getFunction.appendCases(cas); } nameSpace.appendFunctions(getFunction); }
/// <summary> /// Creates a copy of the rule in the designated dictionary. The namespace structure is copied over. /// The new rule is set to update this one. /// </summary> /// <param name="dictionary">The target dictionary of the copy</param> /// <returns></returns> public Rule CreateRuleUpdate(Dictionary dictionary) { Rule retVal = (Rule)Duplicate(); retVal.SetUpdateInformation(this); retVal.ClearAllRequirements(); String[] names = FullName.Split('.'); names = names.Take(names.Count() - 1).ToArray(); if (Enclosing is NameSpace) { NameSpace nameSpace = dictionary.GetNameSpaceUpdate(names, Dictionary); nameSpace.appendRules(retVal); } else { String[] nameSpaceRef = names.Take(names.Count() - 1).ToArray(); if (EnclosingStateMachine != null) { StateMachine stateMachine = EnclosingStateMachine.CreateSubStateMachineUpdate(dictionary); stateMachine.appendRules(retVal); } else if (EnclosingStructure != null) { NameSpace nameSpace = dictionary.GetNameSpaceUpdate(nameSpaceRef, Dictionary); Structure structure = nameSpace.GetStructureUpdate(names.Last(), (NameSpace)nameSpace.Updates); structure.appendRules(retVal); } } return(retVal); }
/// <summary> /// Appends a new field group in the namespace /// </summary> /// <param name="nameSpace">The namespace in which the field group should be added</param> /// <param name="name">The name of the field group</param> /// <param name="fieldGroup">The field group to append</param> private void AppendFieldGroup(DataDictionary.Types.NameSpace nameSpace, string name, FieldGroup fieldGroup) { DataDictionary.Types.NameSpace enclosingNameSpace = GetNameSpaceBasedOnName(nameSpace, name); // create a structure for the field group DataDictionary.Types.Structure structure = (DataDictionary.Types.Structure)DataDictionary.Generated.acceptor.getFactory().createStructure(); structure.Name = "Message"; structure.Comment = fieldGroup.description; enclosingNameSpace.appendStructures(structure); numberOfSubStructures = 1; numberOfCollections = 1; RenameDuplicates(fieldGroup.field_sequence.Items); foreach (object obj in fieldGroup.field_sequence.Items) { AppendField(obj, structure, fieldGroup.discriminant_value.ToString()); } // Handles root elements if (!Utils.Utils.isEmpty(fieldGroup.main)) { DataDictionary.Variables.Variable variable = (DataDictionary.Variables.Variable)DataDictionary.Generated.acceptor.getFactory().createVariable(); variable.Name = fieldGroup.main; variable.setTypeName(structure.FullName); variable.Mode = DataDictionary.Generated.acceptor.VariableModeEnumType.aInOut; nameSpace.appendVariables(variable); } }
private void insertElement(DataDictionary.Types.ITypedElement element, StringBuilder text, int indent) { text.Append(TextualExplainUtilities.Pad(element.Name + " => ", indent)); DataDictionary.Types.Structure structure = element.Type as DataDictionary.Types.Structure; if (structure != null) { indent = indent + 4; text.Append(StripUseless(structure.FullName, EnclosingForm.Selected) + "{\n"); bool first = true; foreach (DataDictionary.Types.StructureElement subElement in structure.Elements) { if (!first) { text.Append(",\n"); } insertElement(subElement, text, indent); first = false; } indent -= 4; text.Append("\n" + TextualExplainUtilities.Pad("}", indent)); } else { text.Append(element.Default); } }
/// <summary> /// Executes the action requested by this tool strip button /// </summary> protected override void OnClick(EventArgs e) { Collection collectionType = (Collection)Variable.Type; Structure structureType = (Structure)collectionType.Type; StructureValue element = new StructureValue(structureType, false); if (structureType.Elements.Count == 1) { StructureElement subElement = (StructureElement)structureType.Elements[0]; Structure subElementStructureType = subElement.Type as Structure; if (subElementStructureType != null) { element.CreateField(subElement, structureType); } } ListValue value = Variable.Value.RightSide(Variable, false, true) as ListValue; Variable.Value = value; if (value != null) { value.Val.Add(element); element.Enclosing = value; } base.OnClick(e); }
private void displayType(int indent, Type type) { Structure structureType = type as Structure; if (structureType != null) { foreach (StructureElement element in structureType.Elements) { displayIndent(indent); Type subType = element.Type; Writer.WriteLine(element.Name + " : " + subType.FullName); displayType(indent + 1, subType); } } Range rangeType = type as Range; if (rangeType != null) { displayIndent(indent); Writer.WriteLine("RANGE " + rangeType.MinValueAsDouble + ".." + rangeType.MaxValueAsDouble + " DEFAULT VALUE = " + rangeType.DefaultValue.LiteralName); } Collection collectionType = type as Collection; if (collectionType != null) { displayIndent(indent); Type subType = collectionType.Type; Writer.WriteLine("COLLECTION [" + collectionType.getMaxSize() + "] OF " + subType.FullName); displayType(indent + 1, subType); } }
/// <summary> /// Converts the value provided as an EFS value /// </summary> /// <returns></returns> public override IValue ConvertBack(Type type) { DataDictionary.Values.StructureValue retVal = null; Structure structureType = type as Structure; if (structureType != null) { retVal = new DataDictionary.Values.StructureValue(structureType); foreach (KeyValuePair <string, Value> pair in Value) { if (pair.Value != null) { StructureElement element = structureType.FindStructureElement(pair.Key); if (element != null) { Field field = retVal.CreateField(element, structureType); field.Value = pair.Value.ConvertBack(element.Type); } else { throw new FaultException <EFSServiceFault>( new EFSServiceFault("Cannot find element named " + pair.Key + " in structure " + structureType.FullName)); } } } } CheckReturnValue(retVal, type); return(retVal); }
/// <summary> /// Accepts drop of a tree node, in a drag & drop operation /// </summary> /// <param name="SourceNode"></param> public override void AcceptDrop(BaseTreeNode SourceNode) { base.AcceptDrop(SourceNode); if (SourceNode is StructureTreeNode) { StructureTreeNode structureTreeNode = SourceNode as StructureTreeNode; DataDictionary.Types.Structure structure = structureTreeNode.Item; structureTreeNode.Delete(); AddStructure(structure); } else if (SourceNode is SpecificationView.ParagraphTreeNode) { SpecificationView.ParagraphTreeNode node = SourceNode as SpecificationView.ParagraphTreeNode; DataDictionary.Specification.Paragraph paragaph = node.Item; DataDictionary.Types.Structure structure = (DataDictionary.Types.Structure)DataDictionary.Generated.acceptor.getFactory().createStructure(); structure.Name = paragaph.Name; DataDictionary.ReqRef reqRef = (DataDictionary.ReqRef)DataDictionary.Generated.acceptor.getFactory().createReqRef(); reqRef.Name = paragaph.FullId; structure.appendRequirements(reqRef); AddStructure(structure); } }
/// <summary> /// Executes the action requested by this tool strip button /// </summary> protected override void OnClick(EventArgs e) { Structure elementStructureType = (Structure)Element.Type; StructureValue subValue = new StructureValue(elementStructureType, false); Field field = Value.CreateField(Element, elementStructureType); field.Value = subValue; base.OnClick(e); }
/// <summary> /// Creates a structure in the namespace provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected Structure CreateStructure(NameSpace enclosing, string name) { Structure retVal = (Structure)Factory.createStructure(); enclosing.appendStructures(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Creates a rule and a rule condition in the structure /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected RuleCondition CreateRuleAndCondition(Structure enclosing, string name) { Rule rule = (Rule)Factory.createRule(); enclosing.appendRules(rule); rule.Name = name; return(CreateRuleCondition(rule, name)); }
/// <summary> /// Creates a state machine in the structure provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected StateMachine CreateStateMachine(Structure enclosing, string name) { StateMachine retVal = (StateMachine)Factory.createStateMachine(); enclosing.appendStateMachines(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Constructor /// </summary> /// <param name="item"></param> public StructureElementsTreeNode(DataDictionary.Types.Structure item) : base(item, "Sub elements", true, false) { foreach (DataDictionary.Types.StructureElement structureElement in item.Elements) { Nodes.Add(new StructureElementTreeNode(structureElement)); } SortSubNodes(); }
/// <summary> /// Creates a function in the enclosing structure /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected Procedure CreateProcedure(Structure enclosing, string name) { Procedure retVal = (Procedure)Factory.createProcedure(); enclosing.appendProcedures(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Creates a structure in the namespace provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected StructureRef CreateStructureRef(Structure enclosing, string name) { StructureRef retVal = (StructureRef)Factory.createStructureRef(); enclosing.appendInterfaces(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Creates a structure element in the structure provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <param name="type"></param> /// <returns></returns> protected StructureElement CreateStructureElement(Structure enclosing, string name, string type) { StructureElement retVal = (StructureElement)Factory.createStructureElement(); enclosing.appendElements(retVal); retVal.Name = name; retVal.TypeName = type; return(retVal); }
/// <summary> /// Adds a structure in this collection of structures /// </summary> /// <param name="structure"></param> /// <returns></returns> public StructureTreeNode AddStructure(DataDictionary.Types.Structure structure) { Item.appendStructures(structure); StructureTreeNode retVal = new StructureTreeNode(structure); Nodes.Add(retVal); SortSubNodes(); return(retVal); }
/// <summary> /// Updates the names of model elements to ensure that they match the defined naming convention /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(DataDictionary.Generated.Namable obj, bool visitSubNodes) { DataDictionary.Namable namable = (DataDictionary.Namable)obj; string newName = ""; if (namable is Parameter) { newName = EnsurePrefix(namable.Name, ParameterPrefix); } else if (namable is DataDictionary.Types.Structure) { DataDictionary.Types.Structure structure = (DataDictionary.Types.Structure)namable; if (structure.IsAbstract) { newName = EnsurePrefix(namable.Name, InterfacePrefix); } else { newName = EnsureSuffix(namable.Name, StructureSuffix); } } else if (namable is DataDictionary.Types.Enum) { newName = EnsureSuffix(namable.Name, EnumSuffix); } else if (namable is DataDictionary.Types.Collection) { newName = EnsureSuffix(namable.Name, CollectionSuffix); } else if (namable is DataDictionary.Types.StateMachine) { if (namable.Enclosing is DataDictionary.Types.NameSpace) { newName = EnsureSuffix(namable.Name, StateMachineSuffix); } } else if (namable is DataDictionary.Tests.Step) { newName = RemoveStepNumber(namable.Name); } if (!string.IsNullOrEmpty(newName)) { EfsSystem.Instance.Compiler.Refactor(obj, newName); } base.visit(obj, visitSubNodes); }
/// <summary> /// Brings the model element from an update dictionary to the updated dictionary /// </summary> public virtual void Merge() { ModelElement target = Updates; if (target == null) { // Copy element to parent ModelElement parent = Enclosing as ModelElement; if (parent != null) { NameSpace parentNameSpace = parent.Updates as NameSpace; if (parentNameSpace != null) { parentNameSpace.AddModelElement(Duplicate()); } Paragraph parentParagraph = parent.Updates as Paragraph; if (parentParagraph != null) { parentParagraph.AddModelElement(Duplicate()); } Structure parentStructure = parent.Updates as Structure; if (parentStructure != null) { parentStructure.AddModelElement(Duplicate()); } StateMachine parentStateMachine = parent.Updates as StateMachine; if (parentStateMachine != null) { parentStateMachine.AddModelElement(Duplicate()); } } } else { if (!IsRemoved) { target.UpdateModelElementAccordingToSource(this); } else { target.Delete(); } } }
/// <summary> /// Constructor /// </summary> /// <param name="structureExpression"></param> /// <param name="context"></param> /// <param name="explain"></param> public StructureValue(StructExpression structureExpression, InterpretationContext context, ExplanationPart explain) : base(structureExpression.GetExpressionType() as Structure, new Dictionary <string, INamable>()) { Enclosing = Structure; try { HashSet <string> members = new HashSet <string>(); foreach (KeyValuePair <Designator, Expression> pair in structureExpression.Associations) { StructureElement structureElement = Structure.FindStructureElement(pair.Key.Image); if (structureElement != null) { IValue val = pair.Value.GetExpressionValue(new InterpretationContext(context), explain); if (val != null) { Field field = CreateField(structureElement, structureExpression.RootLog); field.Value = val; members.Add(field.Name); } else { structureExpression.AddError("Cannot evaluate value for " + pair.Value, RuleChecksEnum.ExecutionFailed); } } else { structureExpression.AddError("Cannot find structure element " + pair.Key.Image, RuleChecksEnum.ExecutionFailed); } } foreach (StructureElement element in Structure.Elements) { if (!members.Contains(element.Name)) { Field field = CreateField(element, structureExpression.RootLog); field.Value = element.DefaultValue; } } } finally { _depth -= 1; } }
/// <summary> /// Sets the value of a given association /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <param name="log">The element on which errors should be logged</param> /// <returns>the newly created field</returns> public Field CreateField(object enclosing, string name, ModelElement log) { Field retVal = null; StructureElement structureElement = Structure.FindStructureElement(name); if (structureElement != null) { retVal = CreateField(structureElement, log); } else { log.AddError("Cannot find structure element " + name); } return(retVal); }
/// <summary> /// Coputes targets from the function and adds them to the collection /// </summary> /// <param name="function">Function containing targets</param> /// <param name="collection">Collection to be filled with targets</param> private void ComputeTargets(Function function, ListValue collection) { if (function != null) { Graph graph = function.Graph; if (graph != null && graph.Segments.Count > 1) { NameSpace defaultNameSpace = OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default"); Structure structureType = (Structure) EFSSystem.FindType( defaultNameSpace, "TargetStruct" ); double prevSpeed = graph.Segments[0].Evaluate(graph.Segments[0].Start); for (int i = 1; i < graph.Segments.Count; i++) { Graph.Segment s = graph.Segments[i]; StructureValue value = new StructureValue(structureType); Field speed = value.CreateField(value, "Speed", structureType); speed.Value = new DoubleValue(EFSSystem.DoubleType, s.Evaluate(s.Start)); Field location = value.CreateField(value, "Location", structureType); location.Value = new DoubleValue(EFSSystem.DoubleType, s.Start); Field length = value.CreateField(value, "Length", structureType); length.Value = SegmentLength(s.End); Enum targetType = (Enum)EFSSystem.FindType(defaultNameSpace, "TargetTypeEnum"); Field type = value.CreateField(value, "Type", structureType); type.Value = targetType.DefaultValue; // Only add the target for the current segment to the collection if it brings a reduction in permitted speed if (s.Evaluate(s.Start) < prevSpeed) { collection.Val.Add(value); } // But even if it is not added to the collection of targets, this segment is now the reference speed prevSpeed = s.Evaluate(s.Start); } } } }
public void TestCollectionConcatenation() { Dictionary dictionary = CreateDictionary("Test"); NameSpace nameSpace = CreateNameSpace(dictionary, "NameSpace"); Structure structure = CreateStructure(nameSpace, "ModelElement"); StructureElement structElem = CreateStructureElement(structure, "Value", "Boolean"); structElem.setDefault("True"); Collection collection = CreateCollection(nameSpace, "Coll", "ModelElement", 10); collection.Type = structure; collection.setMaxSize(3); collection.Default = "[]"; Variable variable = CreateVariable(nameSpace, "V", "Coll"); RuleCondition ruleCondition = CreateRuleAndCondition(nameSpace, "Test"); Action action = CreateAction(ruleCondition, "V <- V + [ModelElement{Value => True}] "); RuleCheckerVisitor visitor = new RuleCheckerVisitor(dictionary); visitor.visit(nameSpace); Util.IsThereAnyError isThereAnyError = new Util.IsThereAnyError(); Assert.AreEqual(0, isThereAnyError.ErrorsFound.Count); Assert.AreEqual("[]", variable.Value.LiteralName); Runner runner = new Runner(false); runner.Cycle(); Assert.AreEqual("[" + structure.DefaultValue.LiteralName + "]", variable.Value.LiteralName); runner.Cycle(); Assert.AreEqual("[" + structure.DefaultValue.LiteralName + ", " + structure.DefaultValue.LiteralName + "]", variable.Value.LiteralName); runner.Cycle(); Assert.AreEqual("[" + structure.DefaultValue.LiteralName + ", " + structure.DefaultValue.LiteralName + ", " + structure.DefaultValue.LiteralName + "]", variable.Value.LiteralName); // In this case, the new collection cannot be placed in the variable runner.Cycle(); Assert.AreEqual(1, action.Messages.Count); Assert.AreEqual(ElementLog.LevelEnum.Error, action.Messages[0].Level); }
private void AddDMIOutStructure(CustomProcedure.DMIProcedureConfig aConfig) { DataDictionary.Types.Structure aStructure = (DataDictionary.Types.Structure)DataDictionary.Generated.acceptor.getFactory().createStructure(); aStructure.Name = aConfig.ProcedureName; aStructure.NeedsRequirement = true; Item.appendStructures(aStructure); StructureTreeNode aStructureTreeNode = new StructureTreeNode(aStructure); Nodes.Add(aStructureTreeNode); DataDictionary.Types.StructureElement structElemIn = (DataDictionary.Types.StructureElement)DataDictionary.Generated.acceptor.getFactory().createStructureElement(); structElemIn.Name = "OutputInformation"; structElemIn.TypeName = "DMI.OutputInformation"; structElemIn.Mode = DataDictionary.Generated.acceptor.VariableModeEnumType.aIncoming; aStructureTreeNode.AddStructureElement(structElemIn); SortSubNodes(); }
/// <summary> /// Called when the drop operation is performed on this text box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void DragDropHandler(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false)) { BaseTreeNode SourceNode = (BaseTreeNode)e.Data.GetData("WindowsForms10PersistentObject"); if (SourceNode != null) { DataDictionaryView.VariableTreeNode variableNode = SourceNode as DataDictionaryView.VariableTreeNode; if (variableNode != null) { StringBuilder text = new StringBuilder(); text.Append(StripUseless(SourceNode.Model.FullName, EnclosingForm.Selected) + " <- "); DataDictionary.Variables.Variable variable = variableNode.Item; DataDictionary.Types.Structure structure = variable.Type as DataDictionary.Types.Structure; if (structure != null) { text.Append(StripUseless(structure.FullName, EnclosingForm.Selected) + "{\n"); bool first = true; foreach (DataDictionary.Types.StructureElement element in structure.Elements) { if (!first) { text.Append(",\n"); } insertElement(element, text, 4); first = false; } text.Append("}\n"); } else { text.Append(variable.DefaultValue.FullName); } SelectedText = text.ToString(); } else { SelectedText = StripUseless(SourceNode.Model.FullName, EnclosingForm.Selected); } } } }
public void TestVariableAndTypeWithSameName() { Dictionary dictionary = CreateDictionary("Test"); NameSpace nameSpace = CreateNameSpace(dictionary, "NameSpace"); Structure structure = CreateStructure(nameSpace, "ModelElement"); StructureElement structElem = CreateStructureElement(structure, "Value", "Boolean"); structElem.setDefault("True"); Variable variable = CreateVariable(nameSpace, "ModelElement", "ModelElement"); variable.SubVariables["Value"].Value = System.BoolType.False; Expression expression = new Parser().Expression(dictionary, "NameSpace.ModelElement.Value"); IValue value = expression.GetExpressionValue(new InterpretationContext(), null); Assert.AreEqual(value, variable.SubVariables["Value"].Value); }
/// <summary> /// Constructor /// </summary> /// <param name="structure"></param> /// <param name="setDefaultValue">Indicates that default values should be set</param> public StructureValue(Structure structure, bool setDefaultValue = true) : base(structure, new Dictionary <string, INamable>()) { Enclosing = structure; _depth += 1; if (_depth > 100) { throw new Exception("Possible structure recursion found"); } try { foreach (StructureElement element in Structure.Elements) { Field field = CreateField(element, structure); if (setDefaultValue) { field.Value = field.DefaultValue; } else { if (field.Type is Collection) { field.Value = new ListValue(field.Type as Collection, new List <IValue>()); } else { field.Value = new DefaultValue(field); } } } } finally { _depth -= 1; } }
public override void visit(Generated.Structure obj, bool visitSubNodes) { DataDictionary.Types.Structure structure = obj as Types.Structure; if (structure != null) { foreach (Types.StructureElement element in structure.Elements) { Types.Structure elementType = element.Type as Types.Structure; if (elementType != null) { foreach (Types.StructureElement subElement in elementType.Elements) { if (!ValidMode(element.Mode, subElement.Mode)) { element.AddWarning("Invalid mode for " + subElement.Name); } } } } } base.visit(obj, visitSubNodes); }
/// <summary> /// Creates a structure in the namespace provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected StructureRef CreateStructureRef(Structure enclosing, string name) { StructureRef retVal = (StructureRef) Factory.createStructureRef(); enclosing.appendInterfaces(retVal); retVal.Name = name; return retVal; }
/// <summary> /// Creates a structure element in the structure provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <param name="type"></param> /// <returns></returns> protected StructureElement CreateStructureElement(Structure enclosing, string name, string type) { StructureElement retVal = (StructureElement) Factory.createStructureElement(); enclosing.appendElements(retVal); retVal.Name = name; retVal.TypeName = type; return retVal; }
/// <summary> /// Creates a state machine in the structure provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected StateMachine CreateStateMachine(Structure enclosing, string name) { StateMachine retVal = (StateMachine) Factory.createStateMachine(); enclosing.appendStateMachines(retVal); retVal.Name = name; return retVal; }
/// <summary> /// Creates a rule and a rule condition in the structure /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected RuleCondition CreateRuleAndCondition(Structure enclosing, string name) { Rule rule = (Rule) Factory.createRule(); enclosing.appendRules(rule); rule.Name = name; return CreateRuleCondition(rule, name); }
/// <summary> /// Creates a function in the enclosing structure /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected Procedure CreateProcedure(Structure enclosing, string name) { Procedure retVal = (Procedure) Factory.createProcedure(); enclosing.appendProcedures(retVal); retVal.Name = name; return retVal; }
/// <summary> /// Constructor /// </summary> /// <param name="item"></param> /// <param name="buildSubNodes"></param> public StructureElementsTreeNode(Structure item, bool buildSubNodes) : base(item, buildSubNodes, "Sub elements", true, false) { }