public static DirectoryValue Read1(long currItemId) { DirectoryValue result = CurrDBContext.Get().tblDirectoryValue.Where(x => x.Id == currItemId). Select(x => new DirectoryValue(x.Id, x.EnumName, x.IsReadOnly, x.DirectoryId)).SingleOrDefault(); return(result); }
public void Feed(PakEntry entry, string pathOverride = null) { string path = pathOverride ?? entry.Filename; int index_slash = path.IndexOf('/'); if (index_slash == 0) { throw new Exception($"Empty directory name: {path}"); } else if (index_slash > 0) { string directory_name = path.Substring(0, index_slash); if (!Directories.TryGetValue(directory_name, out DirectoryValue d_value)) { d_value = new DirectoryValue(); Directories.Add(directory_name, d_value); } d_value.Feed(entry, path.Substring(index_slash + 1)); } else { string file_name = path; if (Files.ContainsKey(file_name)) { throw new Exception($"File already exist: {entry.Filename}"); } Files.Add(file_name, entry); } }
public static void Update1(DirectoryValue item) { tblDirectoryValue dataItem = CurrDBContext.Get().tblDirectoryValue.Where(x => x.Id == item.Id).Single(); dataItem.EnumName = item.EnumName; dataItem.IsReadOnly = item.IsReadOnly; dataItem.IsDeleted = item.IsDeleted; dataItem.DirectoryId = item.DirectoryId; CurrDBContext.Get().SaveChanges(); }
public static void Create1(DirectoryValue item) { tblDirectoryValue currItem = new tblDirectoryValue { DirectoryId = item.DirectoryId, EnumName = item.EnumName, IsReadOnly = item.IsReadOnly }; CurrDBContext.Get().tblDirectoryValue.Add(currItem); CurrDBContext.Get().SaveChanges(); }
private void FillOneTblDirectoryValue(DirectoryValue dirValue, StringFileWriter fileWriter) { fileWriter.WriteString(""); fileWriter.WriteString("IF NOT EXISTS( SELECT * FROM tblDirectoryValue WHERE Id=" + dirValue.Id.ToString() + " )"); fileWriter.WriteString("BEGIN"); fileWriter.WriteString(" INSERT INTO tblDirectoryValue "); fileWriter.WriteString(" ( Id, EnumName, IsReadOnly, DirectoryId )"); fileWriter.WriteString(" VALUES"); String IsReadOnlyStr = dirValue.IsReadOnly == true ? "1" : "0"; fileWriter.WriteString(" ( " + dirValue.Id.ToString() + ", \'" + dirValue.EnumName + "\', " + IsReadOnlyStr + ", " + dirValue.DirectoryId.ToString() + " );"); fileWriter.WriteString("END"); }
public Problem() { DirectoryValue robocodeDir = new DirectoryValue { Value = @"c:\Thesis\robocode" }; EnemyCollection robotList = EnemyCollection.ReloadEnemies(robocodeDir.Value); FeatureCollection features = FeatureCollection.ReloadFeatures(DateTime.Now); robotList.RobocodePath = robocodeDir.Value; Parameters.Add(new FixedValueParameter <DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir)); Parameters.Add(new FixedValueParameter <IntValue>(NrOfRoundsParameterName, "Number of rounds a robot has to fight against each opponent.", new IntValue(1))); Parameters.Add(new ValueParameter <EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList)); Parameters.Add(new ValueParameter <FeatureCollection>(FeaturesParameterName, "The enemies that should be battled.", features)); Encoding = new BpEaRealVectorEncoding("FeaturesWeights", features.Count, features.Select(f => (double)f.Min.Value).ToList(), features.Select(f => (double)f.Max.Value).ToList(), features.Select(f => f.Name).ToList()); RegisterEventHandlers(); }
public Problem() : base() { DirectoryValue robocodeDir = new DirectoryValue { Value = @"robocode" }; var robotList = EnemyCollection.ReloadEnemies(robocodeDir.Value); robotList.RobocodePath = robocodeDir.Value; Parameters.Add(new FixedValueParameter <DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir)); Parameters.Add(new FixedValueParameter <IntValue>(NrOfRoundsParameterName, "Number of rounds a robot has to fight against each opponent.", new IntValue(3))); Parameters.Add(new ValueParameter <EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList)); Encoding = new SymbolicExpressionTreeEncoding(new Grammar(), 1000, 10); Encoding.FunctionArguments = 0; Encoding.FunctionDefinitions = 0; RegisterEventHandlers(); }