public void AddTupleValue(string name, Variable variable) { Address addr_tuple_value = new Address(Address.Path, Address.Name + "." + name, AddressType.Variable); RuntimeEngine.PutVariable(addr_tuple_value, variable); _tuple_addresses.Add(name, addr_tuple_value); }
Variable addition_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { Double sum = 0; foreach (Address addr in _parameter_addresses) { Variable var = RuntimeEngine.GetVariable(addr); double tempval; if (var.Value.GetType() == typeof(int)) { tempval = (int)var.Value; } else { tempval = (Double)var.Value; } sum += tempval; if (var.Address.Name.Contains("$SYSTEM$_temp")) { RuntimeEngine.GetPool(addr.Parent).Pull(addr.Name); } } Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
public void UpdateMemorySetsEyeRefCount() { var bot = new Bot { DNA = new[] { new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye1), new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye2), new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye3), new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye4), new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye5), new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye6), new BasePair(BasePairType.StarNumber, (int)MemoryAddresses.Eye7), new BasePair(BasePairType.Number, (int)MemoryAddresses.Eye1), new BasePair(BasePairType.Basic, (int)MemoryAddresses.Eye2), new BasePair(BasePairType.Boolean, (int)MemoryAddresses.Eye3), new BasePair(BasePairType.Condition, (int)MemoryAddresses.Eye4), new BasePair(BasePairType.Flow, (int)MemoryAddresses.Eye5), new BasePair(BasePairType.Store, (int)MemoryAddresses.Eye6), new BasePair(BasePairType.Unknown, (int)MemoryAddresses.Eye7), } }; RuntimeEngine.UpdateMemory(bot); bot.GetFromMemory(MemoryAddresses.MyEyeRefCount).Should().Be(7); }
public Variable this[string tuple_field_name] { get { Address addr = new Address(Address.Path, Address.Name + "." + tuple_field_name, AddressType.Variable); return(RuntimeEngine.GetVariable(addr)); } }
private Variable Length_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { string str = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value; Variable result = new Variable(str.Length, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private Variable ToString_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { Variable var0 = RuntimeEngine.GetVariable(_parameter_addresses[0]); Variable result = new Variable(var0.Value.ToString(), TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private Variable EqualSign_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { Variable var0 = RuntimeEngine.GetVariable(_parameter_addresses[0]); Variable var1 = RuntimeEngine.GetVariable(_parameter_addresses[1]); Variable result = new Variable((int)var0.Value == (int)var1.Value, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type))); return(result); }
private static void DinkingUsingValidation() { Console.WriteLine("Drinking regulation using Validation Tree..."); var engine = RuntimeEngine.FromXml(File.OpenRead("DrinkingValidation.xml")); Check_Young_Female(engine); Check_Adult_Female(engine); Check_Adult_Pregnant_Female(engine); }
Variable not_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { Variable var = RuntimeEngine.GetVariable(_parameter_addresses[0]); bool sum = (bool)var.Value; Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
static void Main(string[] args) { var app = new Program(); var eng = RuntimeEngine.FromXml(File.OpenRead("LetterWorkflow.xml")); app.AskUserForDetails(eng, new Letter()); Console.ReadLine(); }
static void Main(string[] args) { var app = new Program(); var eng = RuntimeEngine.FromXml(File.OpenRead("ApplicationWorkflow.xml")); app.AskOptions(eng, new Application()); Console.ReadLine(); }
public EmailForm() { InitializeComponent(); comboLanguage.SelectedIndex = 0; _validator = RuntimeEngine.FromXml(File.OpenRead("LocalisedValidationRule.xml")); // Prepare engine for different culture messaging _validator.OnRunning = (eng) => SetupLocalisation(eng.ExecutorSetup); }
internal override void OnRemove() { bool suc = RuntimeEngine.GetSystem <UpdateSystem>().UpdateScriptCollection.Remove(this); if (!suc) { RuntimeEngine.GetSystem <StartSystem>().StartScriptCollection.Remove(this); } }
static void Main(string[] args) { var app = new Program(); var eng = RuntimeEngine.FromXml(File.OpenRead("VotingWorkflow.xml")); eng.Workflow.Registry.AddService <ITaskService>(new TaskRepository()); eng.Workflow.Registry.AddService <IDirectoryService>(new UserRepository()); app.Vote(eng); Console.ReadLine(); }
private static void RunFromFileAddress() { var engine = RuntimeEngine.FromXml(File.OpenRead("CarsDiscountFlow.xml")); var result = engine.Run(ConnectionString); var cars = result.Context.VariableContainer["cars"] as IEnumerable; foreach (IDictionary <string, object> car in cars) { Console.WriteLine("{0} {1} {2} Discount: {3}", car["Made"], car["Model"], car["Year"], car["Discount"]); } }
private Variable FromString_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { Variable var0 = RuntimeEngine.GetVariable(_parameter_addresses[0]); bool outint; bool.TryParse((string)var0.Value, out outint); Variable result = new Variable(outint, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private static void RunByXmlDecisionTable() { Console.WriteLine("Decision table using XML..."); // Loading decision table from excel document IRuntimeEngine engine = RuntimeEngine.FromXml(File.OpenRead("AgeTitle.xml"), "Sheet1"); // set events to be captured engine.EnableFullLog = true; // executing the decision table ExecuteDecisionTable(engine); }
Variable subtraction_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { int diff = 0; Variable var0 = RuntimeEngine.GetVariable(_parameter_addresses[0]); Variable var1 = RuntimeEngine.GetVariable(_parameter_addresses[1]); diff = (int)var0.Value - (int)var1.Value; Variable result = new Variable(diff, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private static void BuildDiscountDecision() { DiscountDecision = RuntimeEngine.FromXml(InMemoryFileStore.GetByName("DiscountDecision.xml").AsBytes()); // Capture events DiscountDecision.Events = EventNames.All; // registering custom function DiscountDecision.RegisterFunction(typeof(AgeExtensions)); // build validation plan for executing decision table // Creates a reader to access an excel file DiscountDecision.Entries.Add("Y", "true", true); DiscountDecision.Entries.Add("N", "false", true); }
public void Basic_StringCodelet_Weave() { // Arrange var arbitraryString = "foo"; var s = Encapsulate(new StringCodelet(arbitraryString)); var rte = new RuntimeEngine(false); // Act rte.StartFromCodelet(s, false); // Assert Assert.Equal(1, rte.ValueStackLength()); Assert.Equal(arbitraryString, rte.PeekOrElse()); }
public void Play() { graphics = RuntimeEngine.Construct2 ( consoleType: ConsoleType.Chinese, bold: false, maximum: false, width: WIDTH, height: HEIGHT, charWidth: CharWidth.Double, title: TITLE ); RuntimeEngine.Start(Start, Update, null, FPS); }
Variable addition_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { int sum = 0; foreach (Address addr in _parameter_addresses) { Variable var = RuntimeEngine.GetVariable(addr); sum += (int)var.Value; } Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private Variable Multipleconcat_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { string concatto = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value; Variable result = new Variable(); RuntimeEngine.PutVariable(_destination_address, result); for (int i = 1; i < _parameter_addresses.Length; i++) { Variable concat = new Variable(concatto + (string)RuntimeEngine.GetVariable(_parameter_addresses[i]).Value, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type))); result.AddTupleValue((i - 1) + "", concat); } return(result); }
static void Main(string[] args) { // initializing License for faster execution // so the other parts of framework will work with the // initialized license during execution FlexRule.License.UserLicense.Initialize(); var p = new Program(); var engine = RuntimeEngine.FromXml(File.OpenRead(RulePath)); p.RunEngine(engine); Console.ReadLine(); }
private Variable Removal_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { string removed = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value; for (int i = 1; i < _parameter_addresses.Length; i++) { string toremove = (string)RuntimeEngine.GetVariable(_parameter_addresses[i]).Value; removed = removed.Replace(toremove, ""); } Variable result = new Variable(removed, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private Variable Concatenation_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { string sum = ""; foreach (Address addr in _parameter_addresses) { Variable var = RuntimeEngine.GetVariable(addr); sum += (string)var.Value; } Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
Variable and_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { bool sum = true; foreach (Address addr in _parameter_addresses) { Variable var = RuntimeEngine.GetVariable(addr); sum = sum && (bool)var.Value; } Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private Variable Indexof_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses) { string str = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value; string of = (string)RuntimeEngine.GetVariable(_parameter_addresses[1]).Value; int idx = 0; if (_parameter_addresses.Length > 2) { idx = (int)RuntimeEngine.GetVariable(_parameter_addresses[2]).Value; } idx = str.IndexOf(of, idx); Variable result = new Variable(idx, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type))); RuntimeEngine.PutVariable(_destination_address, result); return(result); }
private static void ValidatePersonIdentity_StructuredRoutine() { var engine = RuntimeEngine.FromXml(File.OpenRead("PersonRule.nl")); var per = GetPerson(); var result = engine.Run(new RunParameter("person has identity"), per); if (!result.Outcome.Value) { // Check errors foreach (var notice in result.Context.Notifications.Default.Notices) { Console.WriteLine("{0}: {1}", notice.Message, notice.Tag); } } }
public void UpdateMemoryTransformsSpeed() { const int testX = 10; const float testAngle = (float)Math.PI / 3; var bot = new Bot() { Orientation = testAngle, Speed = new Vector2(testX, 0) }; RuntimeEngine.UpdateMemory(bot); bot.GetFromMemory(MemoryAddresses.SpeedForward).Should().Be((int)Math.Round(testX * Math.Cos(testAngle))); bot.GetFromMemory(MemoryAddresses.SpeedRight).Should().Be((int)Math.Round(-testX * Math.Sin(testAngle))); }