public void GetExpressions_Expressions()
        {
            TransformationSchema schema = new TransformationSchema();

            IExpression expr1 = ModelResolvers.ExprResolver();
            IExpression expr2 = ModelResolvers.ExprResolver();

            AssignmentObject assignmentObject1 = new AssignmentObject(schema, expr1, true, new List <string>());
            AssignmentObject assignmentObject2 = new AssignmentObject(schema, expr2, true, new List <string>());

            schema.AssignmentObjects.Add(assignmentObject1);
            schema.AssignmentObjects.Add(assignmentObject2);

            List <IExpression> expected = new List <IExpression>()
            {
                expr1, expr2
            };

            ICollection <IExpression> result = schema.GetExpressions();

            Assert.Equal(expected.Count, result.Count);
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i], result.ToArray()[i]);
            }
        }
    public Node Assignment()
    {
        Node   node = null;
        String name = MatchAndEat("KEYWORD").text;

        MatchAndEat("ASSIGNMENT");
        Node value = v8Expression();

        node = new AssignmentObject(name, value, this);
        return(node);
    }
Пример #3
0
 /// <summary>
 /// Adds the script for the assignment type to this gameObject and calls ConfigureAssignment on the script with a delay.
 /// </summary>
 /// <param name="type">The type of the assignment.</param>
 /// <param name="aObject">The AssignmentObject that called this method.</param>
 public void ConfigureNewAssignment(string type, AssignmentObject aObject)
 {
     assignmentObject = aObject;
     editButton = assignmentObject.GetComponent<Button>();
     editButton.onClick.AddListener(() => { ChangeAssignment(); });
     typeScriptName = type + "AssignmentConfig";
     if (type == null) type = "None";
     print("script added: " + typeScriptName);
     this.gameObject.AddComponent(Type.GetType(typeScriptName));
     Invoke("Activate", 0.1f);
 }
Пример #4
0
 /// <summary>
 /// Creates a mission from assignmentObjects like those used in the missionMaker, saves it as a Hashtable and sends it over the PhotonNetwork.
 /// </summary>
 /// <param name="assignmentObjects">Array of assignmentObjects.</param>
 /// <param name="missionDuration">De duration of the mission in hours.</param>
 public Mission CreateMissionFromAssignmentObjects(AssignmentObject[] assignmentObjects, int missionDuration)
 {
     Dictionary<int, Assignment> assignments = new Dictionary<int, Assignment>();
     foreach (AssignmentObject ao in assignmentObjects)
     {
         AssignmentObject assignmentObject = ao.gameObject.GetComponent<AssignmentObject>();
         assignmentObject.assignment.sequenceNumber = ao.gameObject.transform.GetSiblingIndex() + 1;
         assignments.Add(assignmentObject.assignment.sequenceNumber, assignmentObject.assignment);
     }
     Mission newMission = new Mission(DateTime.Now.AddDays(1), missionDuration, assignments);
     print("newMission: " + newMission);
     return newMission;
 }
    public Node FunctionDefinition()
    {
        MatchAndEat("FUNCTION");
        String functionName = MatchAndEat("KEYWORD").text;

        MatchAndEat("LEFT_PAREN");
        List <Parameter> parameters = FunctionDefParameters();

        MatchAndEat("RIGHT_PAREN");
        Node     functionBody     = Block();
        Function function         = new Function(functionName, functionBody, parameters);
        Node     functionVariable = new AssignmentObject(functionName, function, this);

        return(functionVariable);
    }