protected override DataType GetResultType(VerificationContext context, ListType listType) { var addOperator = context.ResolveCall("Add", new Signature(new[] { listType.ElementType, listType.ElementType })); var divideOperator = context.ResolveCall("Divide", new Signature(new[] { listType.ElementType, listType.ElementType })); return divideOperator.ResultType; }
protected override DataType GetResultType(VerificationContext context, ListType listType) { context.VerifyType(listType.ElementType, DataTypes.Boolean); return DataTypes.Boolean; }
protected override DataType GetResultType(VerificationContext context, ListType listType) { return listType.ElementType; }
protected override DataType GetResultType(VerificationContext context, ListType listType) { var greaterOperator = context.ResolveCall("Greater", new Signature(new[] { listType.ElementType, listType.ElementType })); return listType.ElementType; }
protected override DataType GetResultType(VerificationContext context, ListType listType) { return DataTypes.Integer; }
protected abstract DataType GetResultType(VerificationContext context, ListType listType);
private void VerifyResponseBindings(VerificationContext context, Node node, Dictionary<string, ParameterDef> containers) { // foreach action // If DeclareResponseAction // Create a parameter with that name // If CollectInformationAction // Create a property on the appropriate parameter with the correct type // Name = responseBinding.property // Type = responseCardinality = Single ? responseDataType : List<responseDataType> try { switch (node.NodeType.GetLocalName()) { case "DeclareResponseAction" : { var containerName = node.GetAttribute<string>("name"); var container = new ParameterDef { Name = containerName, ParameterType = new ObjectType(containerName + "Type", new List<PropertyDef> { }) }; containers.Add(container.Name, container); } break; case "CollectInformationAction" : { var responseBinding = node.Children.FirstOrDefault(c => c.Name == "responseBinding"); if (responseBinding != null) { var containerName = responseBinding.GetAttribute<string>("container"); if (String.IsNullOrEmpty(containerName)) { containerName = "Responses"; } if (!containers.ContainsKey(containerName)) { throw new InvalidOperationException(String.Format("Could not resolve response container name {0}.", containerName)); } var container = containers[containerName]; var containerType = (ObjectType)container.ParameterType; DataType responseType = null; var responseName = responseBinding.GetAttribute<string>("property"); var documentationConcept = node.Children.FirstOrDefault(c => c.Name == "documentationConcept"); if (documentationConcept != null) { var responseDataType = documentationConcept.Children.FirstOrDefault(c => c.Name == "responseDataType"); if (responseDataType != null) { responseType = context.ResolveType(responseDataType.GetAttribute<string>("value")); } else { responseType = DataTypes.String; } var responseCardinality = documentationConcept.Children.FirstOrDefault(c => c.Name == "responseCardinality"); if (responseCardinality != null) { if (responseCardinality.GetAttribute<string>("value") == "Multiple") { responseType = new ListType(responseType); } } } if (responseType == null) { responseType = DataTypes.String; } if (containerType.Properties.FirstOrDefault(pd => pd.Name == responseName) != null) { throw new InvalidOperationException(String.Format("The response container {0} already has a response named {1}.", container.Name, responseName)); } containerType.Properties.Add(new PropertyDef(responseName, responseType)); } } break; } } catch (Exception e) { context.ReportMessage(e, node); } foreach (var child in node.Children) { VerifyResponseBindings(context, child, containers); } }