commit f76395b726bb4a1e193bebca6a9169d43b25af24
parent bfc3a9faf3194f98fd6ee426795e378d0e7116b3
Author: Mikolaj Lenczewski <33129490+EnderRifter@users.noreply.github.com>
Date: Sat, 13 Jul 2019 22:35:50 +0100
Tuned orbit tracers, started database implementation.
Diffstat:
11 files changed, 798 insertions(+), 11 deletions(-)
diff --git a/StarSim/StarSim/Program.cs b/StarSim/StarSim/Program.cs
@@ -1,9 +1,16 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection.Metadata.Ecma335;
+using System.Security.Cryptography;
+using System.Text;
using System.Timers;
using SFML.Graphics;
using SFML.Window;
using StarSimLib;
+using StarSimLib.Contexts;
+using StarSimLib.Cryptography;
using StarSimLib.Data_Structures;
using StarSimLib.Graphics;
using StarSimLib.Physics;
@@ -43,6 +50,11 @@ namespace StarSim
private static readonly Dictionary<Body, CircleShape> bodyShapeMap;
/// <summary>
+ /// The database context to use for the lifetime of the program.
+ /// </summary>
+ private static readonly SimulatorContext databaseContext;
+
+ /// <summary>
/// The input handler to use to provide interactivity to the simulator.
/// </summary>
private static readonly InputHandler inputHandler;
@@ -72,6 +84,9 @@ namespace StarSim
/// </summary>
static Program()
{
+ // set up the database context for the program
+ databaseContext = new SimulatorContext();
+
// we construct a new window instance, but immediately hide it so that we can configure the rest of the app
window = new RenderWindow(VideoMode.DesktopMode, "N-Body Simulator: FPS ", Styles.Default, new ContextSettings());
window.SetVisible(false);
@@ -100,6 +115,33 @@ namespace StarSim
}
/// <summary>
+ /// Converts the given enumerable to a string representation of its contents.
+ /// </summary>
+ /// <typeparam name="T">The type of object held in the enumerable.</typeparam>
+ /// <param name="enumerable">The enumerable to convert.</param>
+ /// <param name="itemConverter">The custom function to use to convert a single enumerable item to its string form.</param>
+ /// <returns>The contents of the enumerable as a string.</returns>
+ private static string EnumerableToString<T>(IEnumerable<T> enumerable, Func<T, string> itemConverter = null)
+ {
+ StringBuilder enumerableStringBuilder = new StringBuilder("[");
+
+ if (itemConverter == null)
+ {
+ // the default converter function is just calling the Object.ToString() function
+ itemConverter = item => item.ToString();
+ }
+
+ foreach (T item in enumerable)
+ {
+ enumerableStringBuilder.Append($"{itemConverter(item) ?? ""},");
+ }
+
+ enumerableStringBuilder.Append("]");
+
+ return enumerableStringBuilder.ToString();
+ }
+
+ /// <summary>
/// Entry point for our application.
/// </summary>
private static void Main()
@@ -150,5 +192,32 @@ namespace StarSim
Console.WriteLine("Press 'enter' to quit...");
Console.ReadLine();
}
+
+ private static void TestHashing(string password)
+ {
+ // set a shorthand for nicety reasons
+ string BytesToString(byte[] contents) => CryptographyHelper.BytesToString(contents);
+
+ Console.WriteLine($"Password to hash: {password}");
+
+ byte[] passwordBytes = CryptographyHelper.StringToBytes(password);
+ Console.WriteLine($"Password bytes:\n{BytesToString(passwordBytes)}");
+
+ // generates a salt of the default length
+ byte[] saltBytes = CryptographyHelper.GenerateSalt();
+ Console.WriteLine($"Generated salt:\n{BytesToString(saltBytes)}");
+
+ // generates a hash of the default length
+ byte[] passwordHash = CryptographyHelper.GenerateHash(passwordBytes, saltBytes);
+ Console.WriteLine($"Generated valid hash:\n{BytesToString(passwordHash)}");
+
+ byte[] invalidPasswordBytes = CryptographyHelper.StringToBytes("password ");
+ Console.WriteLine($"Invalid password bytes:\n{BytesToString(invalidPasswordBytes)}");
+
+ byte[] invalidPasswordHash = CryptographyHelper.GenerateHash(invalidPasswordBytes, saltBytes);
+ Console.WriteLine($"Generated invalid hash:\n{BytesToString(invalidPasswordHash)}");
+
+ Console.WriteLine($"Valid hash == invalid hash: {CryptographyHelper.HashesEqual(passwordHash, invalidPasswordHash)}");
+ }
}
}
\ No newline at end of file
diff --git a/StarSim/StarSimLib/Constants.cs b/StarSim/StarSimLib/Constants.cs
@@ -10,7 +10,7 @@ namespace StarSimLib
/// <summary>
/// The amount of bodies that are rendered by default.
/// </summary>
- public const int BodyCount = 100;
+ public const int BodyCount = 50;
/// <summary>
/// The mass of the central body, if it is included.
@@ -71,7 +71,7 @@ namespace StarSimLib
/// <summary>
/// The default time step for the simulation.
/// </summary>
- public const double TimeStep = SecondsPerTick * (SimulationRate / (float)FrameRate) * SimulationRate;
+ public const double TimeStep = SecondsPerTick * (SimulationRate / (double)FrameRate) * SimulationRate;
/// <summary>
/// The tolerance of the mass grouping approximation in the simulation. A body is only accelerated when the
diff --git a/StarSim/StarSimLib/Contexts/SimulatorContext.cs b/StarSim/StarSimLib/Contexts/SimulatorContext.cs
@@ -1,4 +1,6 @@
-using Microsoft.EntityFrameworkCore;
+using System.Security.Cryptography;
+using Microsoft.EntityFrameworkCore;
+using StarSimLib.Models;
namespace StarSimLib.Contexts
{
@@ -27,6 +29,26 @@ namespace StarSimLib.Contexts
{
}
+ /// <summary>
+ /// Holds the <see cref="Body"/> entities in the database. Also allows querying the database via LINQ.
+ /// </summary>
+ public DbSet<Body> Bodies { get; set; }
+
+ /// <summary>
+ /// Holds the <see cref="BodyToSystemJoin"/> entities in the database. Also allows querying the database via LINQ.
+ /// </summary>
+ public DbSet<BodyToSystemJoin> BodyToSystemJoins { get; set; }
+
+ /// <summary>
+ /// Holds the <see cref="Models.System"/> entities in the database. Also allows querying the database via LINQ.
+ /// </summary>
+ public DbSet<Models.System> Systems { get; set; }
+
+ /// <summary>
+ /// Holds the <see cref="User"/> entities in the database. Also allows querying the database via LINQ.
+ /// </summary>
+ public DbSet<User> Users { get; set; }
+
#region Overrides of DbContext
/// <inheritdoc />
@@ -39,7 +61,37 @@ namespace StarSimLib.Contexts
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
- base.OnModelCreating(modelBuilder);
+ modelBuilder.Entity<Body>().HasIndex(body => body.Id).IsUnique();
+
+ modelBuilder.Entity<Body>().Property(body => body.Name).HasDefaultValue("UNNAMED");
+
+ modelBuilder.Entity<Body>().HasData(
+ new Body(1, "Sagittarius A*", Constants.CentralBodyMass),
+ new Body(2, "Sol", Constants.SolarMass),
+ new Body(3, "Earth", Constants.SolarMass)
+ );
+
+ modelBuilder.Entity<Models.System>().HasIndex(system => system.Id).IsUnique();
+
+ modelBuilder.Entity<Models.System>().HasData(
+ new Models.System(1, "Test")
+ );
+
+ modelBuilder.Entity<BodyToSystemJoin>().HasIndex(join => new { join.BodyId, join.SystemId }).IsUnique();
+
+ modelBuilder.Entity<BodyToSystemJoin>().HasData(
+ new BodyToSystemJoin(1, 1, 1),
+ new BodyToSystemJoin(2, 2, 1),
+ new BodyToSystemJoin(3, 3, 1)
+ );
+
+ modelBuilder.Entity<User>().HasIndex(user => user.Id).IsUnique();
+
+ modelBuilder.Entity<User>().Property(user => user.Email).HasDefaultValue("john.doe@gmail.com");
+
+ modelBuilder.Entity<User>().HasData(
+ new User(1, "John Doe", new byte[0], new byte[0])
+ );
}
#endregion Overrides of DbContext
diff --git a/StarSim/StarSimLib/Cryptography/CryptographyHelper.cs b/StarSim/StarSimLib/Cryptography/CryptographyHelper.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace StarSimLib.Cryptography
+{
+ /// <summary>
+ /// Provides helper methods for manipulating password salts and hashes.
+ /// </summary>
+ public static class CryptographyHelper
+ {
+ /// <summary>
+ /// The cryptographically secure random number generator to use to generate cryptographically strong sequences
+ /// of bytes.
+ /// </summary>
+ private static readonly RNGCryptoServiceProvider cryptoServiceProvider = new RNGCryptoServiceProvider();
+
+ /// <summary>
+ /// The number of iterations used when deriving the password hash from the salted password.
+ /// </summary>
+ public const int HashIterations = 10_000;
+
+ /// <summary>
+ /// The number of bytes of hash to return
+ /// </summary>
+ public const int HashLength = 2048;
+
+ /// <summary>
+ /// The number of bytes per password salt.
+ /// </summary>
+ public const int SaltByteCount = 2048;
+
+ /// <summary>
+ /// Returns the string representation of the given bytes.
+ /// </summary>
+ /// <param name="contents">The byte contents to convert.</param>
+ /// <returns>The string that represents the given bytes.</returns>
+ public static string BytesToString(byte[] contents)
+ {
+ StringBuilder contentsStringBuilder = new StringBuilder();
+
+ foreach (byte contentByte in contents)
+ {
+ contentsStringBuilder.Append(Convert.ToChar(contentByte));
+ }
+
+ return contentsStringBuilder.ToString();
+ }
+
+ /// <summary>
+ /// Returns the hash of the given salted password (password with salt prepended) with the given number of iterations.
+ /// </summary>
+ /// <param name="password">The password to hash.</param>
+ /// <param name="salt">The salt to prepend to the password.</param>
+ /// <param name="hashLength">The number of bytes of hash to return.</param>
+ /// <param name="iterations">The number of iterations of hashing algorithm to perform.</param>
+ /// <returns>The given number of bytes of hashed salted password.</returns>
+ public static byte[] GenerateHash(byte[] password, byte[] salt, int hashLength = HashLength, int iterations = HashIterations)
+ {
+ using (Rfc2898DeriveBytes pbkdf = new Rfc2898DeriveBytes(password, salt, iterations))
+ {
+ return pbkdf.GetBytes(hashLength);
+ }
+ }
+
+ /// <summary>
+ /// Returns a cryptographically strong sequence of bytes of the given length to function as a password salt.
+ /// </summary>
+ /// <param name="length">The number of bytes that should make up the salt.</param>
+ /// <returns>The generated salt.</returns>
+ public static byte[] GenerateSalt(int length = SaltByteCount)
+ {
+ byte[] saltBytes = new byte[length];
+
+ cryptoServiceProvider.GetBytes(saltBytes);
+
+ return saltBytes;
+ }
+
+ /// <summary>
+ /// Determines whether the two hashes given are equal.
+ /// </summary>
+ /// <param name="a">The first hash to compare.</param>
+ /// <param name="b">The second hash to compare.</param>
+ /// <returns>Whether the two hashes are equal.</returns>
+ public static bool HashesEqual(byte[] a, byte[] b)
+ {
+ if (a.Length != b.Length)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < a.Length; i++)
+ {
+ // bytewise XOR will return a 0 if, and only if, both bytes are the same. if they are not, the hashes
+ // are not identical
+ if ((a[i] ^ b[i]) != 0)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Returns the bytes of the given string.
+ /// </summary>
+ /// <param name="contents">The string contents to convert.</param>
+ /// <returns>The bytes that make up the given string.</returns>
+ public static byte[] StringToBytes(string contents)
+ {
+ return contents.Select(Convert.ToByte).ToArray();
+ }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Data Structures/OrbitTracer.cs b/StarSim/StarSimLib/Data Structures/OrbitTracer.cs
@@ -10,9 +10,9 @@ namespace StarSimLib.Data_Structures
{
/// <summary>
/// Sample rate for the previous position. Used to improve performance and get a longer orbit tracer tail
- /// for less computation. The previous position will be saved once every 15 sampling opportunities.
+ /// for less computation. The previous position will be saved once every 10 sampling opportunities.
/// </summary>
- private const int PositionSampleRate = 15;
+ private const int PositionSampleRate = 10;
/// <summary>
/// Backing field for the <see cref="PreviousPositions"/> property.
diff --git a/StarSim/StarSimLib/Models/Body.cs b/StarSim/StarSimLib/Models/Body.cs
@@ -0,0 +1,59 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace StarSimLib.Models
+{
+ /// <summary>
+ /// Represents a known stellar body in the database. Maps to a <see cref="Data_Structures.Body"/> instance.
+ /// </summary>
+ public class Body
+ {
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Body"/> class.
+ /// </summary>
+ /// <param name="id">The unique id for this instance.</param>
+ /// <param name="name">The name for this instance.</param>
+ /// <param name="mass">The mass for this instance.</param>
+ public Body(ulong id, string name, double mass)
+ {
+ Id = id;
+ Name = name;
+ Mass = mass;
+ }
+
+ /// <summary>
+ /// The <see cref="BodyToSystemJoin"/> entities that map this <see cref="Body"/> to the <see cref="System"/>
+ /// entities that hold it.
+ /// </summary>
+ [InverseProperty(nameof(BodyToSystemJoin.Body))]
+ public virtual ICollection<BodyToSystemJoin> BodyToSystemJoins { get; set; } = new List<BodyToSystemJoin>();
+
+ /// <summary>
+ /// The unique primary key for this instance.
+ /// </summary>
+ [Key, Required(ErrorMessage = "Body must have unique id.")]
+ public ulong Id { get; set; }
+
+ /// <summary>
+ /// The mass of this instance.
+ /// </summary>
+ [Required(ErrorMessage = "Body must have a mass.")]
+ public double Mass { get; set; }
+
+ /// <summary>
+ /// The displayed name of this instance.
+ /// </summary>
+ [Required(ErrorMessage = "Body must have a name.")]
+ [MinLength(0, ErrorMessage = "Body's name can not be less than 0 characters long.")]
+ [MaxLength(100, ErrorMessage = "Body's name can not be more than 100 characters long")]
+ public string Name { get; set; }
+
+ /// <summary>
+ /// A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ /// multiple access to the same field.
+ /// </summary>
+ [Timestamp, Required(ErrorMessage = "Body must have a timestamp associated with it.")]
+ public byte[] Timestamp { get; set; }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Models/BodyToSystemJoin.cs b/StarSim/StarSimLib/Models/BodyToSystemJoin.cs
@@ -0,0 +1,63 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace StarSimLib.Models
+{
+ /// <summary>
+ /// Maps a <see cref="Models.Body"/> entity and <see cref="Models.System"/> entity in a many-to-many relationship in the database.
+ /// </summary>
+ public class BodyToSystemJoin
+ {
+ /// <summary>
+ /// Initialises a new instance of the <see cref="BodyToSystemJoin"/> class.
+ /// </summary>
+ /// <param name="id">The unique id for this instance.</param>
+ /// <param name="bodyId">The id of the body mapped by this instance.</param>
+ /// <param name="systemId">The id of the system mapped by this instance.</param>
+ public BodyToSystemJoin(ulong id, ulong bodyId, ulong systemId)
+ {
+ Id = id;
+ BodyId = bodyId;
+ SystemId = systemId;
+ }
+
+ /// <summary>
+ /// The <see cref="Models.Body"/> instance mapped by this join instance.
+ /// </summary>
+ [ForeignKey(nameof(BodyId))]
+ [Required(ErrorMessage = "Body-to-System join must map a body.")]
+ public Body Body { get; set; }
+
+ /// <summary>
+ /// The Id of the <see cref="Models.Body"/> instance mapped by this join instance.
+ /// </summary>
+ [Required(ErrorMessage = "Body-to-System join must have the mapped body's id.")]
+ public ulong BodyId { get; set; }
+
+ /// <summary>
+ /// The unique primary key for this instance.
+ /// </summary>
+ [Key, Required(ErrorMessage = "Body-to-System join must have unique id.")]
+ public ulong Id { get; set; }
+
+ /// <summary>
+ /// The <see cref="Models.System"/> instance mapped by this join instance.
+ /// </summary>
+ [ForeignKey(nameof(SystemId))]
+ [Required(ErrorMessage = "Body-to-System join must map a system.")]
+ public System System { get; set; }
+
+ /// <summary>
+ /// The Id of the <see cref="Models.System"/> instance mapped by this join instance.
+ /// </summary>
+ [Required(ErrorMessage = "Body-to-System join must have the mapped system's id.")]
+ public ulong SystemId { get; set; }
+
+ /// <summary>
+ /// A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ /// multiple access to the same field.
+ /// </summary>
+ [Timestamp, Required(ErrorMessage = "Body-to-System join must have a timestamp associated with it.")]
+ public byte[] Timestamp { get; set; }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Models/System.cs b/StarSim/StarSimLib/Models/System.cs
@@ -0,0 +1,64 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace StarSimLib.Models
+{
+ /// <summary>
+ /// Represents a star system in the database, with a collection of child <see cref="Body"/> instances.
+ /// </summary>
+ public class System
+ {
+ /// <summary>
+ /// Initialises a new instance of the <see cref="System"/> class.
+ /// </summary>
+ /// <param name="id">The unique id of this instance.</param>
+ /// <param name="name">The name of this instance.</param>
+ public System(ulong id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+
+ /// <summary>
+ /// The <see cref="BodyToSystemJoin"/> entities that map this <see cref="System"/> to the <see cref="Body"/>
+ /// entities that it holds.
+ /// </summary>
+ [InverseProperty(nameof(BodyToSystemJoin.System))]
+ public virtual ICollection<BodyToSystemJoin> BodyToSystemJoins { get; set; } = new List<BodyToSystemJoin>();
+
+ /// <summary>
+ /// The <see cref="User"/> who created this instance.
+ /// </summary>
+ [ForeignKey(nameof(CreatorId))]
+ [Required(ErrorMessage = "System must have creator.")]
+ public User Creator { get; set; }
+
+ /// <summary>
+ /// The Id of the <see cref="User"/> who created this instance.
+ /// </summary>
+ [Required(ErrorMessage = "System must have id of creator.")]
+ public ulong CreatorId { get; set; }
+
+ /// <summary>
+ /// The unique primary key for this instance.
+ /// </summary>
+ [Key, Required(ErrorMessage = "System must have unique id.")]
+ public ulong Id { get; set; }
+
+ /// <summary>
+ /// The displayed name of this instance.
+ /// </summary>
+ [Required(ErrorMessage = "System must have a name.")]
+ [MinLength(0, ErrorMessage = "System's name can not be less than 0 characters long.")]
+ [MaxLength(100, ErrorMessage = "System's name can not be more than 100 characters long")]
+ public string Name { get; set; }
+
+ /// <summary>
+ /// A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ /// multiple access to the same field.
+ /// </summary>
+ [Timestamp, Required(ErrorMessage = "System must have a timestamp associated with it.")]
+ public byte[] Timestamp { get; set; }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Models/User.cs b/StarSim/StarSimLib/Models/User.cs
@@ -0,0 +1,90 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using StarSimLib.Cryptography;
+
+namespace StarSimLib.Models
+{
+ /// <summary>
+ /// Represents a user in the database.
+ /// </summary>
+ public class User
+ {
+ /// <summary>
+ /// Initialises a new instance of the <see cref="User"/> class.
+ /// </summary>
+ /// <param name="id">The unique id of this instance.</param>
+ /// <param name="username">The username of this instance.</param>
+ /// <param name="email">The optional email of this instance.</param>
+ public User(ulong id, string username, string email = null)
+ {
+ Id = id;
+ Username = username;
+ Email = email;
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="User"/> class.
+ /// </summary>
+ /// <param name="id">The unique id of this instance.</param>
+ /// <param name="username">The username of this instance.</param>
+ /// <param name="passwordHash">The hash of the salted password of this instance.</param>
+ /// <param name="passwordSalt">The salt used to hash the password.</param>
+ /// <param name="email">The optional email of this instance.</param>
+ public User(ulong id, string username, byte[] passwordHash, byte[] passwordSalt, string email = null)
+ {
+ Id = id;
+ Username = username;
+ PasswordHash = passwordHash;
+ PasswordSalt = passwordSalt;
+ Email = email;
+ }
+
+ /// <summary>
+ /// The <see cref="System"/> entities that this <see cref="User"/> has created.
+ /// </summary>
+ [InverseProperty(nameof(System.Creator))]
+ public virtual ICollection<System> CreatedSystems { get; set; } = new List<System>();
+
+ /// <summary>
+ /// The email address of this instance.
+ /// </summary>
+ [MinLength(0, ErrorMessage = "User's email can not be less than 0 characters long.")]
+ [MaxLength(100, ErrorMessage = "User's email can not be more than 100 characters long")]
+ public string Email { get; set; }
+
+ /// <summary>
+ /// The unique primary key for this instance.
+ /// </summary>
+ [Key, Required(ErrorMessage = "User must have unique id.")]
+ public ulong Id { get; set; }
+
+ /// <summary>
+ /// The hash of this instance's salted password.
+ /// </summary>
+ [Required(ErrorMessage = "User must have a password hash.")]
+ public byte[] PasswordHash { get; set; }
+
+ /// <summary>
+ /// The salt prepended to this instance's password prior to hashing.
+ /// </summary>
+ [Required(ErrorMessage = "User must have a password salt.")]
+ [MinLength(256, ErrorMessage = "User's password salt must be no shorter than 256 bytes long.")]
+ public byte[] PasswordSalt { get; set; }
+
+ /// <summary>
+ /// A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ /// multiple access to the same field.
+ /// </summary>
+ [Timestamp, Required(ErrorMessage = "User must have a timestamp associated with it.")]
+ public byte[] Timestamp { get; set; }
+
+ /// <summary>
+ /// The displayed username of this instance.
+ /// </summary>
+ [Required(ErrorMessage = "User must have a username.")]
+ [MinLength(0, ErrorMessage = "User's username can not be less than 0 characters long.")]
+ [MaxLength(100, ErrorMessage = "User's username can not be more than 100 characters long")]
+ public string Username { get; set; }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/StarSimLib.csproj b/StarSim/StarSimLib/StarSimLib.csproj
@@ -41,8 +41,4 @@
</PackageReference>
<PackageReference Include="SFML.Net" Version="2.5.0" />
</ItemGroup>
-
- <ItemGroup>
- <Folder Include="Models\" />
- </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/StarSim/StarSimLib/StarSimLib.xml b/StarSim/StarSimLib/StarSimLib.xml
@@ -117,12 +117,97 @@
</summary>
<param name="options">Any <see cref="T:Microsoft.EntityFrameworkCore.DbContextOptions"/> that should be set on this instance.</param>
</member>
+ <member name="P:StarSimLib.Contexts.SimulatorContext.Bodies">
+ <summary>
+ Holds the <see cref="T:StarSimLib.Models.Body"/> entities in the database. Also allows querying the database via LINQ.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Contexts.SimulatorContext.BodyToSystemJoins">
+ <summary>
+ Holds the <see cref="T:StarSimLib.Models.BodyToSystemJoin"/> entities in the database. Also allows querying the database via LINQ.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Contexts.SimulatorContext.Systems">
+ <summary>
+ Holds the <see cref="T:StarSimLib.Models.System"/> entities in the database. Also allows querying the database via LINQ.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Contexts.SimulatorContext.Users">
+ <summary>
+ Holds the <see cref="T:StarSimLib.Models.User"/> entities in the database. Also allows querying the database via LINQ.
+ </summary>
+ </member>
<member name="M:StarSimLib.Contexts.SimulatorContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)">
<inheritdoc />
</member>
<member name="M:StarSimLib.Contexts.SimulatorContext.OnModelCreating(Microsoft.EntityFrameworkCore.ModelBuilder)">
<inheritdoc />
</member>
+ <member name="T:StarSimLib.Cryptography.CryptographyHelper">
+ <summary>
+ Provides helper methods for manipulating password salts and hashes.
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Cryptography.CryptographyHelper.cryptoServiceProvider">
+ <summary>
+ The cryptographically secure random number generator to use to generate cryptographically strong sequences
+ of bytes.
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Cryptography.CryptographyHelper.HashIterations">
+ <summary>
+ The number of iterations used when deriving the password hash from the salted password.
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Cryptography.CryptographyHelper.HashLength">
+ <summary>
+ The number of bytes of hash to return
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Cryptography.CryptographyHelper.SaltByteCount">
+ <summary>
+ The number of bytes per password salt.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Cryptography.CryptographyHelper.BytesToString(System.Byte[])">
+ <summary>
+ Returns the string representation of the given bytes.
+ </summary>
+ <param name="contents">The byte contents to convert.</param>
+ <returns>The string that represents the given bytes.</returns>
+ </member>
+ <member name="M:StarSimLib.Cryptography.CryptographyHelper.GenerateHash(System.Byte[],System.Byte[],System.Int32,System.Int32)">
+ <summary>
+ Returns the hash of the given salted password (password with salt prepended) with the given number of iterations.
+ </summary>
+ <param name="password">The password to hash.</param>
+ <param name="salt">The salt to prepend to the password.</param>
+ <param name="hashLength">The number of bytes of hash to return.</param>
+ <param name="iterations">The number of iterations of hashing algorithm to perform.</param>
+ <returns>The given number of bytes of hashed salted password.</returns>
+ </member>
+ <member name="M:StarSimLib.Cryptography.CryptographyHelper.GenerateSalt(System.Int32)">
+ <summary>
+ Returns a cryptographically strong sequence of bytes of the given length to function as a password salt.
+ </summary>
+ <param name="length">The number of bytes that should make up the salt.</param>
+ <returns>The generated salt.</returns>
+ </member>
+ <member name="M:StarSimLib.Cryptography.CryptographyHelper.HashesEqual(System.Byte[],System.Byte[])">
+ <summary>
+ Determines whether the two hashes given are equal.
+ </summary>
+ <param name="a">The first hash to compare.</param>
+ <param name="b">The second hash to compare.</param>
+ <returns>Whether the two hashes are equal.</returns>
+ </member>
+ <member name="M:StarSimLib.Cryptography.CryptographyHelper.StringToBytes(System.String)">
+ <summary>
+ Returns the bytes of the given string.
+ </summary>
+ <param name="contents">The string contents to convert.</param>
+ <returns>The bytes that make up the given string.</returns>
+ </member>
<member name="T:StarSimLib.Data_Structures.Body">
<summary>
Represents a stellar body.
@@ -688,7 +773,7 @@
<member name="F:StarSimLib.Data_Structures.OrbitTracer.PositionSampleRate">
<summary>
Sample rate for the previous position. Used to improve performance and get a longer orbit tracer tail
- for less computation. The previous position will be saved once every 15 sampling opportunities.
+ for less computation. The previous position will be saved once every 10 sampling opportunities.
</summary>
</member>
<member name="F:StarSimLib.Data_Structures.OrbitTracer.previousPositions">
@@ -1208,6 +1293,193 @@
</summary>
<param name="scaleMultiplier">The multiplier by which to scale the viewport of this instances render target.</param>
</member>
+ <member name="T:StarSimLib.Models.Body">
+ <summary>
+ Represents a known stellar body in the database. Maps to a <see cref="T:StarSimLib.Data_Structures.Body"/> instance.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Models.Body.#ctor(System.UInt64,System.String,System.Double)">
+ <summary>
+ Initialises a new instance of the <see cref="T:StarSimLib.Models.Body"/> class.
+ </summary>
+ <param name="id">The unique id for this instance.</param>
+ <param name="name">The name for this instance.</param>
+ <param name="mass">The mass for this instance.</param>
+ </member>
+ <member name="P:StarSimLib.Models.Body.BodyToSystemJoins">
+ <summary>
+ The <see cref="T:StarSimLib.Models.BodyToSystemJoin"/> entities that map this <see cref="T:StarSimLib.Models.Body"/> to the <see cref="T:StarSimLib.Models.System"/>
+ entities that hold it.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.Body.Id">
+ <summary>
+ The unique primary key for this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.Body.Mass">
+ <summary>
+ The mass of this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.Body.Name">
+ <summary>
+ The displayed name of this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.Body.Timestamp">
+ <summary>
+ A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ multiple access to the same field.
+ </summary>
+ </member>
+ <member name="T:StarSimLib.Models.BodyToSystemJoin">
+ <summary>
+ Maps a <see cref="T:StarSimLib.Models.Body"/> entity and <see cref="T:StarSimLib.Models.System"/> entity in a many-to-many relationship in the database.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Models.BodyToSystemJoin.#ctor(System.UInt64,System.UInt64,System.UInt64)">
+ <summary>
+ Initialises a new instance of the <see cref="T:StarSimLib.Models.BodyToSystemJoin"/> class.
+ </summary>
+ <param name="id">The unique id for this instance.</param>
+ <param name="bodyId">The id of the body mapped by this instance.</param>
+ <param name="systemId">The id of the system mapped by this instance.</param>
+ </member>
+ <member name="P:StarSimLib.Models.BodyToSystemJoin.Body">
+ <summary>
+ The <see cref="T:StarSimLib.Models.Body"/> instance mapped by this join instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.BodyToSystemJoin.BodyId">
+ <summary>
+ The Id of the <see cref="T:StarSimLib.Models.Body"/> instance mapped by this join instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.BodyToSystemJoin.Id">
+ <summary>
+ The unique primary key for this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.BodyToSystemJoin.System">
+ <summary>
+ The <see cref="T:StarSimLib.Models.System"/> instance mapped by this join instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.BodyToSystemJoin.SystemId">
+ <summary>
+ The Id of the <see cref="T:StarSimLib.Models.System"/> instance mapped by this join instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.BodyToSystemJoin.Timestamp">
+ <summary>
+ A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ multiple access to the same field.
+ </summary>
+ </member>
+ <member name="T:StarSimLib.Models.System">
+ <summary>
+ Represents a star system in the database, with a collection of child <see cref="T:StarSimLib.Models.Body"/> instances.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Models.System.#ctor(System.UInt64,System.String)">
+ <summary>
+ Initialises a new instance of the <see cref="T:StarSimLib.Models.System"/> class.
+ </summary>
+ <param name="id">The unique id of this instance.</param>
+ <param name="name">The name of this instance.</param>
+ </member>
+ <member name="P:StarSimLib.Models.System.BodyToSystemJoins">
+ <summary>
+ The <see cref="T:StarSimLib.Models.BodyToSystemJoin"/> entities that map this <see cref="T:StarSimLib.Models.System"/> to the <see cref="T:StarSimLib.Models.Body"/>
+ entities that it holds.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.System.Creator">
+ <summary>
+ The <see cref="T:StarSimLib.Models.User"/> who created this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.System.CreatorId">
+ <summary>
+ The Id of the <see cref="T:StarSimLib.Models.User"/> who created this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.System.Id">
+ <summary>
+ The unique primary key for this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.System.Name">
+ <summary>
+ The displayed name of this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.System.Timestamp">
+ <summary>
+ A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ multiple access to the same field.
+ </summary>
+ </member>
+ <member name="T:StarSimLib.Models.User">
+ <summary>
+ Represents a user in the database.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Models.User.#ctor(System.UInt64,System.String,System.String)">
+ <summary>
+ Initialises a new instance of the <see cref="T:StarSimLib.Models.User"/> class.
+ </summary>
+ <param name="id">The unique id of this instance.</param>
+ <param name="username">The username of this instance.</param>
+ <param name="email">The optional email of this instance.</param>
+ </member>
+ <member name="M:StarSimLib.Models.User.#ctor(System.UInt64,System.String,System.Byte[],System.Byte[],System.String)">
+ <summary>
+ Initialises a new instance of the <see cref="T:StarSimLib.Models.User"/> class.
+ </summary>
+ <param name="id">The unique id of this instance.</param>
+ <param name="username">The username of this instance.</param>
+ <param name="passwordHash">The hash of the salted password of this instance.</param>
+ <param name="passwordSalt">The salt used to hash the password.</param>
+ <param name="email">The optional email of this instance.</param>
+ </member>
+ <member name="P:StarSimLib.Models.User.CreatedSystems">
+ <summary>
+ The <see cref="T:StarSimLib.Models.System"/> entities that this <see cref="T:StarSimLib.Models.User"/> has created.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.User.Email">
+ <summary>
+ The email address of this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.User.Id">
+ <summary>
+ The unique primary key for this instance.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.User.PasswordHash">
+ <summary>
+ The hash of this instance's salted password.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.User.PasswordSalt">
+ <summary>
+ The salt prepended to this instance's password prior to hashing.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.User.Timestamp">
+ <summary>
+ A timestamp updated whenever the entity is handled by the database. Functions as a concurrency token to prevent
+ multiple access to the same field.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Models.User.Username">
+ <summary>
+ The displayed username of this instance.
+ </summary>
+ </member>
<member name="T:StarSimLib.Physics.MassToColourDelegate">
<summary>
Takes the mass of a <see cref="T:StarSimLib.Data_Structures.Body"/> instance and returns a colour for the <see cref="T:SFML.Graphics.CircleShape"/>