Esempio n. 1
0
 /// <summary>
 /// Adds a Thing to the session.
 /// </summary>
 public static Thing AddThing(string thingID)
 {
     return(Facts.AddThing(thingID));
 }
Esempio n. 2
0
            /// <summary>
            /// Returns a function representing the fact.
            /// </summary>
            public Func <Tvar> GetFunction()
            {
                // Get the template for the function, based on the relationship
                Question q = Interactive.Templates.GetQ(Relationship);

                // Set the function's arguments before invoking it

                // Convert first argument from string to proper type
                if (q.arg1Type == "Thing")
                {
                    Engine.Thing1 = Facts.AddThing(Convert.ToString(Arg1));
                }
                else if (q.arg1Type == "Tbool")
                {
                    Engine.Tbool1 = Convert.ToBoolean(Arg1);
                }
                else if (q.arg1Type == "Tnum")
                {
                    Engine.Tnum1 = Convert.ToDecimal(Arg1);
                }
                else if (q.arg1Type == "Tstr")
                {
                    Engine.Tstr1 = Convert.ToString(Arg1);
                }
                else if (q.arg1Type == "Tdate")
                {
                    Engine.Tdate1 = Convert.ToDateTime(Arg1);
                }
                else if (q.arg1Type == "Tset")
                {
                    Engine.Tset1 = (Tset)Arg1;                               // ?
                }
                // Second argument
                if (q.arg2Type == "Thing")
                {
                    Engine.Thing2 = Facts.AddThing(Convert.ToString(Arg2));
                }
                else if (q.arg2Type == "Tbool")
                {
                    Engine.Tbool2 = Convert.ToBoolean(Arg2);
                }
                else if (q.arg2Type == "Tnum")
                {
                    Engine.Tnum2 = Convert.ToDecimal(Arg2);
                }
                else if (q.arg2Type == "Tstr")
                {
                    Engine.Tstr2 = Convert.ToString(Arg2);
                }
                else if (q.arg2Type == "Tdate")
                {
                    Engine.Tdate2 = Convert.ToDateTime(Arg2);
                }
                else if (q.arg2Type == "Tset")
                {
                    Engine.Tset2 = (Tset)Arg2;
                }

                // Third argument
                if (q.arg3Type == "Thing")
                {
                    Engine.Thing3 = Facts.AddThing(Convert.ToString(Arg3));
                }
                else if (q.arg3Type == "Tbool")
                {
                    Engine.Tbool3 = Convert.ToBoolean(Arg3);
                }
                else if (q.arg3Type == "Tnum")
                {
                    Engine.Tnum3 = Convert.ToDecimal(Arg3);
                }
                else if (q.arg3Type == "Tstr")
                {
                    Engine.Tstr3 = Convert.ToString(Arg3);
                }
                else if (q.arg3Type == "Tdate")
                {
                    Engine.Tdate3 = Convert.ToDateTime(Arg3);
                }
                else if (q.arg3Type == "Tset")
                {
                    Engine.Tset3 = (Tset)Arg3;
                }

                // Return the lambda function
                return(Interactive.Templates.GetQ(Relationship).theFunc);
            }