Size: 1493
Comment:
|
Size: 3247
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 9: | Line 9: |
== Package Specific snippits == || '''Package''' || '''Description''' || || [[/Colore|Colore]] || C# Library for Razer Chroma's SDK || |
|
Line 11: | Line 17: |
== Number Remap Class == {{{#!highlight c# public static class Remap { private static double Map(double value, double fromSource, double toSource, double fromTarget, double toTarget) { return (value - fromSource) / (toSource - fromSource) * (toTarget - fromTarget) + fromTarget; } } }}} |
|
Line 12: | Line 29: |
CustomEventArgs.cs | !CustomEventArgs.cs |
Line 42: | Line 59: |
InstanceOwner.cs | !InstanceOwner.cs |
Line 56: | Line 73: |
== Number Remap Class == | == IComparable Class == |
Line 58: | Line 76: |
public static class Remap { private static double Map(double value, double fromSource, double toSource, double fromTarget, double toTarget) { return (value - fromSource) / (toSource - fromSource) * (toTarget - fromTarget) + fromTarget; } } |
public class Mission : IComparable<Mission>, IComparable { public string Name { get; private set; } public DateTime LaunchDate { get; private set; } public DateTime ReturnDate { get; private set; } public string SpaceShip { get; private set; } public List<Astronaut> Astronauts { get; private set; } public Mission(string name, DateTime launchDate, DateTime returnDate, string spaceShip) { Astronauts = new List<Astronaut>(); Name = name; LaunchDate = launchDate; ReturnDate = returnDate; SpaceShip = spaceShip; } public int CompareTo(Mission other) { if (ReferenceEquals(this, other)) return 0; if (ReferenceEquals(null, other)) return 1; int nameComparison = string.Compare(Name, other.Name, StringComparison.Ordinal); if (nameComparison != 0) return nameComparison; int launchDateComparison = LaunchDate.CompareTo(other.LaunchDate); if (launchDateComparison != 0) return launchDateComparison; int returnDateComparison = ReturnDate.CompareTo(other.ReturnDate); if (returnDateComparison != 0) return returnDateComparison; return string.Compare(SpaceShip, other.SpaceShip, StringComparison.Ordinal); } public int CompareTo(object obj) { if (ReferenceEquals(null, obj)) return 1; if (ReferenceEquals(this, obj)) return 0; if (!(obj is Mission)) throw new ArgumentException($"Object must be of type {nameof(Mission)}"); return CompareTo((Mission) obj); } } |
Contents
Description
The snippets on this wikipage are written for the .NET Framework v4.0 and higher, but most probably work in older versions. Most will, however not work for .NET Core and .NET Standard.
Package Specific snippits
Package |
Description |
C# Library for Razer Chroma's SDK |
Snippets
Number Remap Class
Custom Events & Handling
CustomEventArgs.cs
Instance.cs
InstanceOwner.cs
IComparable Class
1 public class Mission : IComparable<Mission>, IComparable
2 {
3 public string Name { get; private set; }
4 public DateTime LaunchDate { get; private set; }
5 public DateTime ReturnDate { get; private set; }
6 public string SpaceShip { get; private set; }
7
8 public List<Astronaut> Astronauts { get; private set; }
9
10 public Mission(string name, DateTime launchDate, DateTime returnDate, string spaceShip)
11 {
12 Astronauts = new List<Astronaut>();
13 Name = name;
14 LaunchDate = launchDate;
15 ReturnDate = returnDate;
16 SpaceShip = spaceShip;
17 }
18
19 public int CompareTo(Mission other)
20 {
21 if (ReferenceEquals(this, other)) return 0;
22 if (ReferenceEquals(null, other)) return 1;
23 int nameComparison = string.Compare(Name, other.Name, StringComparison.Ordinal);
24 if (nameComparison != 0) return nameComparison;
25 int launchDateComparison = LaunchDate.CompareTo(other.LaunchDate);
26 if (launchDateComparison != 0) return launchDateComparison;
27 int returnDateComparison = ReturnDate.CompareTo(other.ReturnDate);
28 if (returnDateComparison != 0) return returnDateComparison;
29 return string.Compare(SpaceShip, other.SpaceShip, StringComparison.Ordinal);
30 }
31
32 public int CompareTo(object obj)
33 {
34 if (ReferenceEquals(null, obj)) return 1;
35 if (ReferenceEquals(this, obj)) return 0;
36 if (!(obj is Mission)) throw new ArgumentException($"Object must be of type {nameof(Mission)}");
37 return CompareTo((Mission) obj);
38 }
39 }