/// <summary> /// Returns the hive containing the specified <paramref name="keyName"/> as a <see cref="RegistryKey"/>. /// </summary> /// <exception cref="ApplicationException"> /// An <see cref="ApplicationException"/> is thrown if the <see cref="RegistryHive"/> /// can't be extracted from the specified <paramref name="keyName"/>. /// </exception> /// <param name="keyName">The full key name. Used to extract the rootkey from.</param> /// <param name="subKeyName">The name of the hive's subkey, as specified in <paramref name="keyName"/>.</param> /// <returns>The top-level <see cref="RegistryKey"/> of which <paramref name="keyName"/> is a member.</returns> public static RegistryHive GetHive(string keyName, out string subKeyName) { int index = keyName.IndexOf("\\"); if (index == 0) { throw new ApplicationException("Can't extract the root key from " + keyName); } if (index != -1) { subKeyName = keyName.Substring(index + 1); keyName = keyName.Substring(0, index).ToUpperInvariant(); } else { subKeyName = null; } var id = HiveMap.GetIdFor(keyName); if (HiveMap.IsLegalId(id)) { return(HiveMap.GetHiveById(id)); } throw new ApplicationException(string.Format("The requested hive \"{0}\" can't be found.", keyName)); }
/// <summary> /// Returns the root key associated with the current <see cref="RegistryHive"/>. /// </summary> /// <param name="registryHive">Indicator of the top-level key to return.</param> /// <returns>The root <see cref="RegistryKey"/> matching the <see cref="RegistryHive"/>.</returns> public static RegistryKey AsRegistryKey(this RegistryHive registryHive) { var id = HiveMap.GetIdFor(registryHive); return(HiveMap.IsLegalId(id) ? HiveMap.GetKeyById(id) : null); }
public static HiveMap InitiateMap(int dimensions) { HiveMap map = new HiveMap(dimensions); Cell queenCell = map.GetCell(dimensions / 2, dimensions / 2); queenCell.Ant = new Queen(queenCell); queenCell.PrintCoords(); //why i cannot acces queen methods when queenCell.Ant = new Queen(..) queenCell.Ant.GenerateAnts(ref map); return(map); }
/// <summary> /// Returns whether the specified handle is predefined for a hive. /// </summary> /// <param name="hKey">The handle to check.</param> /// <param name="hiveName">The name of the hive matching the handle.</param> /// <returns>True if <paramref name="hKey"/> is a predefined handle.</returns> public static bool IsHiveHandle(uint hKey, out string hiveName) { var id = HiveMap.GetIdFor(hKey); if (HiveMap.IsLegalId(id)) { hiveName = HiveMap.GetNameById(id); return(true); } hiveName = null; return(false); }
/// <summary> /// Returns whether the specified handle is predefined for a hive. /// </summary> /// <param name="hKey">The handle to check.</param> /// <param name="registryHive">The <see cref="RegistryHive"/> matching the handle.</param> /// <returns>True if <paramref name="hKey"/> is a predefined handle.</returns> public static bool IsHiveHandle(uint hKey, out RegistryHive registryHive) { var id = HiveMap.GetIdFor(hKey); if (HiveMap.IsLegalId(id)) { registryHive = HiveMap.GetHiveById(id); return(true); } registryHive = default(RegistryHive); return(false); }
public override void GenerateAnts(ref HiveMap map) { List <string> listOfPopulatedFields = PopulateList(map.Dimensions); int listCounter = 0; for (int x = 0; x < map.Dimensions; x++) { for (int y = 0; y < map.Dimensions; y++) { Cell cell = map.GetCell(x, y); if (!cell.Ant?.IsNotPassable ?? true) { Console.WriteLine("wpadl queen if"); switch (listOfPopulatedFields[listCounter]) { case "drone": cell.Ant = new Drone(cell); Console.WriteLine("Drone created"); cell.PrintCoords(); break; case "worker": cell.Ant = new Worker(cell); Console.WriteLine("Worker created"); cell.PrintCoords(); break; case "soldier": cell.Ant = new Soldier(cell); Console.WriteLine("Soldier created"); cell.PrintCoords(); break; } } listCounter++; } } }
public abstract void GenerateAnts(ref HiveMap map);
public override void GenerateAnts(ref HiveMap map) { throw new NotImplementedException(); }
/// <summary> /// Returns the full name of the root key associated with the current <see cref="RegistryHive"/>. /// </summary> /// <param name="registryHive">Indicator of the registry hive which full name must be returned.</param> /// <returns>The full name of the root key matching the <see cref="RegistryHive"/>.</returns> public static string AsRegistryHiveName(this RegistryHive registryHive) { return(HiveMap.GetNameById(HiveMap.GetIdFor(registryHive))); }
/// <summary> /// Returns whether a hive with the given <paramref name="name"/> is defined. /// </summary> /// <param name="name">The name to check.</param> /// <returns>True if <paramref name="name"/> identifies a registry hive.</returns> public static bool IsHiveName(string name) { return(HiveMap.IsDefined(name)); }
/// <summary> /// Returns whether the specified handle is predefined for a hive. /// </summary> /// <param name="hKey">The handle to check.</param> /// <returns>True if <paramref name="hKey"/> is a predefined handle.</returns> public static bool IsHiveHandle(uint hKey) { return(HiveMap.IsDefined(hKey)); }
public static HiveMap UpdateMap(HiveMap map) { HiveMap updatedMap = map; return(updatedMap); }