public SourceCode CreateSourceCodeFromString(string pName, string pContent)
        {
            SourceCode newSourceCode = new SourceCode();
            newSourceCode.CreateNewRelayEntry(_sourceCodeTable, typeof(SourceCode).Name);
            newSourceCode.content = pContent;
            newSourceCode.name = pName;

            _sourceCodes.Add(newSourceCode);

            return newSourceCode;
        }
Пример #2
0
        public SourceCode CreateSourceCodeFromString(string pName, string pContent)
        {
            SourceCode newSourceCode = new SourceCode();

            newSourceCode.CreateNewRelayEntry(_sourceCodeTable, typeof(SourceCode).Name);
            newSourceCode.content = pContent;
            newSourceCode.name    = pName;

            _sourceCodes.Add(newSourceCode);

            return(newSourceCode);
        }
Пример #3
0
        public SourceCode GetSourceCode(string pName)
        {
            SourceCode s = _sourceCodes.Find(o => o.name == pName);

            if (s != null)
            {
                return(s);
            }
            else
            {
                throw new Exception("Can't find SourceCode with name '" + pName + "' in Source Code Dispenser");
            }
        }
Пример #4
0
        public void AddProgramsToProgramsArray()
        {
            MimanTing mimanTing = _world.tingRunner.CreateTing<MimanTingConcrete>("Miman Ting", new WorldCoordinate("Kitchen", IntPoint.Zero));
            SourceCode dummyCode = new SourceCode();
            dummyCode.CreateNewRelayEntry(_world.relay.GetTable(SourceCode.TABLE_NAME), typeof(SourceCode).Name);

            WorldTestHelper.PreloadWorld (_world);

            Program p1 = _world.programRunner.CreateProgram(dummyCode);
            Program p2 = _world.programRunner.CreateProgram(dummyCode);
            _world.Update (0.1f); // the programs are added to the program runner at the end of the frame

            Assert.AreEqual(0, mimanTing.programs.Length);
            mimanTing.AddProgramToProgramsArray(p1);
            Assert.AreEqual(1, mimanTing.programs.Length);
            mimanTing.AddProgramToProgramsArray(p2);
            Assert.AreEqual(2, mimanTing.programs.Length);
        }
Пример #5
0
        public Program EnsureProgram(string pProgramName, string pNameOfSourceCodeToUseIfProgramDoesNotExist)
        {
            logger.Log("Ensuring program with name '" + pProgramName + "'...");
            Program p = GetProgram(pProgramName);

            if (p != null)
            {
                logger.Log("Program already existed");
                return(p);
            }
            else
            {
                SourceCode source     = _sourceCodeDispenser.GetSourceCode(pNameOfSourceCodeToUseIfProgramDoesNotExist);
                Program    newProgram = _programRunner.CreateProgram(pProgramName, source.content, pNameOfSourceCodeToUseIfProgramDoesNotExist);
                logger.Log("Created a new program with id " + newProgram.objectId + " and name " + newProgram.name + " from source " + source.name);                  // + " with content: " + source.content);
                AddProgramToProgramsArray(newProgram);
                return(newProgram);
            }
        }
Пример #6
0
 public Program CreateProgram(SourceCode pSourceCode)
 {
     return CreateProgram(pSourceCode.name, pSourceCode.content, "unknown");
 }
Пример #7
0
 public Program CreateProgram(SourceCode pSourceCode)
 {
     return(CreateProgram(pSourceCode.name, pSourceCode.content, "unknown"));
 }