/// <summary> /// Initializes a new instance of the /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.ConditionalLeftStatement"/> class. /// </summary> /// <param name="reader">Reader.</param> public ConditionalLeftStatement(FileIOManager reader, int depthIn) { this.depth = depthIn; // Condition block parse byte nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.Condition) { this.condition = new Condition(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.Condition); } // LeftStatement block parse nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.LeftStatement) { this.leftStatement = new LeftStatement(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.LeftStatement); } }
/// <summary> /// Writes to disk. /// </summary> /// <param name="writer">Writer.</param> /// <param name="tabDepth">Tab depth.</param> public void WriteToDisk(FileIOManager writer, int tabDepth) { writer.WriteLine(CommonHelperMethods.PrePendTabs(this.Value, tabDepth)); writer.WriteLine(CommonHelperMethods.PrePendTabs(this.returnType.ToString(), tabDepth)); writer.WriteLine(CommonHelperMethods.PrePendTabs(this.lhsType.ToString(), tabDepth)); writer.WriteLine(CommonHelperMethods.PrePendTabs(this.rhsType.ToString(), tabDepth)); }
Session CreateSession(string ppidExtra) { GameObject gameObject = new GameObject(); FileIOManager fileIOManager = gameObject.AddComponent <FileIOManager>(); SessionLogger sessionLogger = gameObject.AddComponent <SessionLogger>(); Session session = gameObject.AddComponent <Session>(); session.AttachReferences( fileIOManager ); sessionLogger.AttachReferences( fileIOManager, session ); sessionLogger.Initialise(); fileIOManager.debug = true; fileIOManager.Begin(); string experimentName = "unit_test"; string ppid = "test_behaviour_" + ppidExtra; session.Begin(experimentName, ppid, "example_output"); // generate trials session.CreateBlock(2); session.CreateBlock(3); return(session); }
/// <summary> /// Writes to disk. /// </summary> /// <param name="writer">Writer.</param> /// <param name="tabDepth">Tab depth.</param> public void WriteToDisk(FileIOManager writer) { writer.WriteByte(this.OperatorType); writer.WriteByte(this.ReturnType); writer.WriteByte(this.LhsType); writer.WriteByte(this.RhsType); }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Assignment"/> class. /// </summary> /// <param name="reader">Reader.</param> public Assignment(FileIOManager reader, int depthIn) { this.depth = depthIn; byte nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.ReadWriteVariable) { this.readWriteVariable = new ReadWriteVariable(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.ReadWriteVariable); } nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.RightStatement) { this.rightStatement = new RightStatement(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.RightStatement); } }
/// <summary> /// Writes to disk protected. /// </summary> /// <param name="writer">Writer.</param> /// <param name="tabDepth">Tab depth.</param> protected void WriteToDiskProtected(FileIOManager writer) { if (this.signature != null) { this.signature.WriteToDisk(writer); } }
public void SetUp() { gameObject = new GameObject(); fileIOManager = gameObject.AddComponent <FileIOManager>(); sessionLogger = gameObject.AddComponent <SessionLogger>(); session = gameObject.AddComponent <Session>(); session.AttachReferences( fileIOManager ); sessionLogger.AttachReferences( fileIOManager, session ); sessionLogger.Initialise(); fileIOManager.debug = true; fileIOManager.Begin(); string experimentName = "unit_test"; string ppid = "test_trials"; session.Begin(experimentName, ppid, "example_output"); session.customHeaders.Add("observation"); session.customHeaders.Add("null_observation"); // generate trials session.CreateBlock(2); session.CreateBlock(3); }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.Attributes.MethodSignature"/> class. /// </summary> /// <param name="reader">Reader.</param> public MethodSignature(FileIOManager reader) { string nextLine = reader.ReadNextContentLineAndTrim(); this.MethodId = (EntMethodEnum)Enum.Parse(typeof(EntMethodEnum), nextLine); nextLine = reader.ReadNextContentLineAndTrim(); this.returnType = GeneticObject.ParseType(nextLine); int numberOfParameters; nextLine = reader.ReadNextContentLineAndTrim(); if (!int.TryParse(nextLine, out numberOfParameters)) { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, "An integer representing the number of parameters"); } for (int i = 0; i < numberOfParameters; ++i) { nextLine = reader.ReadNextContentLineAndTrim(); Type parsedType = GeneticObject.ParseType(nextLine); this.parameterTypes.Add(parsedType); } }
/// <summary> /// Initializes a new instance of the /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.RightStatement"/> class. /// </summary> /// <param name="reader">Reader.</param> public RightStatement(FileIOManager reader) { string nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, RightStatementOperation.Name)) { this.rightStatementOperation = new RightStatementOperation(reader); } else if (CommonHelperMethods.StringStartsWith(nextLine, ReadOnlyVariable.Name)) { this.readOnlyVariable = new ReadOnlyVariable(reader); } else if (CommonHelperMethods.StringStartsWith(nextLine, RightMethodCall.Name)) { this.rightMethodCall = new RightMethodCall(reader); } else if (CommonHelperMethods.StringStartsWith(nextLine, LiteralValue.Name)) { this.literalValue = new LiteralValue(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, new List <string>() { RightStatementOperation.Name, ReadOnlyVariable.Name, RightMethodCall.Name }); } }
/// <summary> /// Initializes a new instance of the /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.RightStatementOperation`1"/> class. /// </summary> /// <param name="reader">Reader.</param> public RightStatementOperation(FileIOManager reader) { // Parse operator this.operatorSignature = new OperatorSignature(reader); // Parse left hand side string nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name)) { this.leftHandSide = new RightStatement(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, RightStatement.Name); } // Parse right hand side nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name)) { this.rightHandSide = new RightStatement(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, RightStatement.Name); } }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.Attributes.OperatorSignature"/> class. /// </summary> /// <param name="reader">Reader.</param> public OperatorSignature(FileIOManager reader) { this.OperatorType = reader.ReadByte(); this.ReturnType = reader.ReadByte(); this.LhsType = reader.ReadByte(); this.RhsType = reader.ReadByte(); }
public void SetUp() { var gameObject = new GameObject(); fileIOManager = gameObject.AddComponent <FileIOManager>(); fileIOManager.debug = true; }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Assignment"/> class. /// </summary> /// <param name="reader">Reader.</param> public Assignment(FileIOManager reader) { string nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, ReadWriteVariable.Name)) { this.readWriteVariable = new ReadWriteVariable(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, ReadWriteVariable.Name); } nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name)) { this.rightStatement = new RightStatement(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, RightStatement.Name); } }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.LeftStatement"/> class. /// </summary> /// <param name="reader">Reader.</param> public LeftStatement(FileIOManager reader, int depthIn) { this.depth = depthIn; byte nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.LeftMethodCall) { this.leftMethodCall = new LeftMethodCall(reader, depthIn + 1); } else if (nextByte == StatementTypeEnum.Assignment) { this.assignment = new Assignment(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, new List <byte>() { StatementTypeEnum.LeftMethodCall, StatementTypeEnum.Assignment }); } }
private static void AddSurvivorsToGenePool() { foreach (KeyValuePair <string, GeneData> keyValuePair in teamNameToGeneDataDic) { string teamName = keyValuePair.Key; GeneData geneData = keyValuePair.Value; int teamPopCount = TeamManager.GetTeamPopulationCount(teamName); int winCount = 1 + teamPopCount - AverageTeamPopulationCount(); if (winCount <= 0) { // Losers don't get laid continue; } // Have to place a cap on number of files, otherwise this would flood the machine if (FileIOManager.GetFileNames().Count < GenePoolDirectoryFileLimit) { LogUtility.LogInfoFormat( "{0} writes DNA to disk", teamName); geneData.DNA.WriteToDisk(FileIOManager.GenerateNewDNAFilePath(winCount)); } else { LogUtility.LogInfoFormat( "Gene Pool has reached max size of {0} files", GenePoolDirectoryFileLimit); } } }
/// <summary> /// Initializes a new instance of the /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.ConditionalLeftStatement"/> class. /// </summary> /// <param name="reader">Reader.</param> public ConditionalLeftStatement(FileIOManager reader) { // Condition block parse string nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, Condition.Name)) { this.condition = new Condition(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, Condition.Name); } // LeftStatement block parse nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, LeftStatement.Name)) { this.leftStatement = new LeftStatement(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextLine, reader, LeftStatement.Name); } }
private void btnShop_Click(object sender, EventArgs e) { List <string> list = new List <string>(); list.AddRange(ingredients.Keys); using (FileIOManager fm = new FileIOManager("every week.txt")) { list.AddRange(fm.Read()); } using (FileIOManager fm = new FileIOManager("last plan.txt")) { fm.Write(meals); } using (LoginDetailsManager login = new LoginDetailsManager()) { if (login.DialogResult != DialogResult.OK) { return; } shoppingManager = new TescoShoppingManager() { LoginUserName = login.Username, LoginPassword = login.Password }; shoppingManager.DoShopping(list); } }
/// <summary> /// Writes to disk protected. /// </summary> /// <param name="writer">Writer.</param> /// <param name="tabDepth">Tab depth.</param> protected void WriteToDiskProtected(FileIOManager writer, int tabDepth) { if (this.signature != null) { this.signature.WriteToDisk(writer, tabDepth); } }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.Attributes.VariableSignature"/> class. /// </summary> /// <param name="reader">Reader.</param> public VariableSignature(FileIOManager reader) { string nextLine = reader.ReadNextContentLineAndTrim(); this.variableType = GeneticObject.ParseType(nextLine); this.VariableId = (EntVariableEnum)Enum.Parse(typeof(EntVariableEnum), reader.ReadNextContentLineAndTrim()); }
private void btnOk_Click(object sender, EventArgs e) { FileIOManager fm = new FileIOManager(Filename); list.Sort(); fm.Write(list); GoBack(); }
void Start() { InputManager.Instance.AddGlobalListener(gameObject); visionURL = "https://" + region + ".api.cognitive.microsoft.com/vision/v2.0/analyze?visualFeatures=Tags,Description&language=ja"; cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First(); tts = gameObject.GetComponent <TextToSpeech>(); fileIOManager = gameObject.GetComponent <FileIOManager>(); }
public EveryWeekItems() { InitializeComponent(); FileIOManager fm = new FileIOManager(Filename); list = fm.Read().ToList(); lstItems.DataSource = list; }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.LiteralValue"/> class. /// </summary> /// <param name="reader">Reader.</param> public LiteralValue(FileIOManager reader) { string nextLine = reader.ReadNextContentLineAndTrim(); this.type = GeneticObject.ParseType(nextLine); nextLine = reader.ReadNextContentLineAndTrim(); this.value = GeneticObject.ParseValue(this.type, nextLine); }
/// <summary> /// Writes to disk. /// </summary> /// <param name="writer">Writer.</param> /// <param name="tabDepth">Tab depth.</param> public void WriteToDisk(FileIOManager writer, int tabDepth) { writer.WriteLine(CommonHelperMethods.PrePendTabs(Condition.Name, tabDepth)); if (this.rightStatement != null) { this.rightStatement.WriteToDisk(writer, tabDepth + 1); } }
/// <summary> /// Writes to disk. /// </summary> /// <param name="writer">Writer.</param> public void WriteToDisk(FileIOManager writer) { writer.WriteByte(StatementTypeEnum.Condition); if (this.rightStatement != null) { this.rightStatement.WriteToDisk(writer); } }
/// <summary> /// Writes to disk. /// </summary> /// <param name="fileName">File name.</param> private void WriteToDisk(string fileName, List <RootStatement> statementList) { lock (CommonHelperMethods.GlobalFileIOLock) { using (FileIOManager fileManager = new FileIOManager(fileName)) foreach (RootStatement rootStatement in statementList) { rootStatement.WriteToDisk(fileManager); } } }
/// <summary> /// Writes to disk. /// </summary> /// <param name="writer">Writer.</param> public void WriteToDisk(FileIOManager writer) { writer.WriteByte(StatementTypeEnum.MethodSignature); writer.WriteByte(this.methodId); writer.WriteByte(this.returnType); writer.WriteByte((byte)this.parameterTypes.Count); foreach (byte parameterType in this.parameterTypes) { writer.WriteByte(parameterType); } }
private static void UpdateGenePoolFilesUponExtinction() { Dictionary <string, int> fileNameToModificationDic = new Dictionary <string, int> (); // Tabulate the new win loss info for the parent files foreach (KeyValuePair <string, GeneData> keyValuePair in teamNameToGeneDataDic) { string teamName = keyValuePair.Key; string parentFileName = keyValuePair.Value.ParentDNAFilePath; int teamPopCount = TeamManager.GetTeamPopulationCount(teamName); int modification = teamPopCount - AverageTeamPopulationCount(); if (fileNameToModificationDic.ContainsKey(parentFileName)) { // Update fileNameToModificationDic[parentFileName] += modification; } else { // Create new entry int startingParentWinLoss = ParseWinLoss(keyValuePair.Value.ParentDNAFilePath); fileNameToModificationDic.Add(parentFileName, startingParentWinLoss + modification); } } // Move or delete the parent files as appropriate foreach (KeyValuePair <string, int> keyValuePair in fileNameToModificationDic) { string oldFileName = keyValuePair.Key; int winLossCount = keyValuePair.Value; if (winLossCount <= 0) { // Delete losers LogUtility.LogInfoFormat( "Removing {0} from gene pool", oldFileName); FileIOManager.Delete(oldFileName); continue; } // Move winners to new file name string newFileName = FileIOManager.GenerateNewDNAFilePath(winLossCount); FileIOManager.Move(oldFileName, newFileName); LogUtility.LogInfoFormat( "Gene pool file {0} became {1}", oldFileName, newFileName); } }
/// <summary> /// Initializes a new instance of the <see cref="MethodSignatureBinary"/> class. /// </summary> /// <param name="reader">Reader.</param> public MethodSignature(FileIOManager reader) { this.MethodId = reader.ReadByte(); this.returnType = reader.ReadByte(); int numberOfParameters = (int)reader.ReadByte(); for (int i = 0; i < numberOfParameters; ++i) { this.parameterTypes.Add(reader.ReadByte()); } }
/// <summary> /// Initializes a new instance of the /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.RightMethodCall"/> class. /// </summary> /// <param name="reader">Reader.</param> public RightMethodCall(FileIOManager reader) { this.signature = new MethodSignature(reader); for (int i = 0; i < this.signature.ParameterTypes.Count; ++i) { string nextLine = reader.ReadNextContentLineAndTrim(); if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name)) { this.parameterList.Add(new RightStatement(reader)); } } }