-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from SteveDunn/extend-members-attribute-for-s…
…trings Extend Members attribute to allow strings
- Loading branch information
Showing
12,518 changed files
with
272,247 additions
and
53,092 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...amples/TypicalScenarios/Deconstruction.cs → ...ypicalScenarios/DeconstructionScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
samples/Intellenum.Examples/TypicalScenarios/EqualityExamples.cs
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
samples/Intellenum.Examples/TypicalScenarios/EqualityScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
|
||
// ReSharper disable RedundantCast | ||
|
||
namespace Intellenum.Examples.TypicalScenarios.Equality; | ||
|
||
[UsedImplicitly] | ||
internal class EqualityScenario : IScenario | ||
{ | ||
public Task Run() | ||
{ | ||
Console.WriteLine(Centigrade.AbsoluteZero == Centigrade.FromName("AbsoluteZero")); // true | ||
Console.WriteLine(Centigrade.AbsoluteZero == Centigrade.FromValue(-273.15m)); // true | ||
Console.WriteLine(Centigrade.AbsoluteZero == -273.15m); // true | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
|
||
[Intellenum<decimal>] | ||
public partial class Centigrade | ||
{ | ||
static Centigrade() | ||
{ | ||
Member("AbsoluteZero", -273.15m); | ||
Member("FreezingPointOfWater", 0m); | ||
Member("BoilingPointOfWater", 100m); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
samples/Intellenum.Examples/TypicalScenarios/IComparable.cs
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
samples/Intellenum.Examples/TypicalScenarios/IComparableScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Intellenum.Examples.TypicalScenarios.IComparable; | ||
|
||
internal class IComparableScenario : IScenario | ||
{ | ||
public Task Run() | ||
{ | ||
// The underlying type of PlanetEnum is Planet, which implements IComparable<Planet> and | ||
// compares on circumference. This means that the Intellenum can be sorted. | ||
|
||
Console.WriteLine(PlanetEnum.Mars < PlanetEnum.Jupiter); // true | ||
|
||
Console.WriteLine(string.Join(", ", PlanetEnum.List().OrderDescending())); // Jupiter, Venus, Mars | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
|
||
[Intellenum<Planet>] | ||
public partial class PlanetEnum | ||
{ | ||
public static readonly PlanetEnum Jupiter = new(new Planet("Brown", 273_400)); | ||
public static readonly PlanetEnum Mars= new(new Planet("Red", 13_240)); | ||
public static readonly PlanetEnum Venus= new(new Planet("White", 23_622)); | ||
} | ||
|
||
public record class Planet(string Colour, int CircumferenceInMiles) : IComparable<Planet> | ||
{ | ||
public int CompareTo(Planet other) => CircumferenceInMiles.CompareTo(other.CircumferenceInMiles); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.