Last active
September 4, 2019 13:25
-
-
Save tbolon/71e25228bc7ce4f67a9a238155b1e015 to your computer and use it in GitHub Desktop.
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
/// <summary> | |
/// Structure spéciale permettant de "fusionner" les deux structures <see cref="Guid"/> et <see cref="ExposedGuid"/> | |
/// en les superposant. | |
/// </summary> | |
/// <remarks> | |
/// Cette structure permet ainsi de modifier la valeur des champs de <see cref="Guid"/> en passant par | |
/// <see cref="P:ExposedGuid"/>, alors que ceci ne devrait pas être possible. | |
/// </remarks> | |
[StructLayout(LayoutKind.Explicit)] | |
private struct Union | |
{ | |
public Union(Guid guid) | |
{ | |
this.ExposedGuid = new ExposedGuid(); | |
this.Guid = guid; | |
} | |
/// <summary> | |
/// Instance du <see cref="T:Guid"/> à modifier. | |
/// </summary> | |
[FieldOffset(0)] | |
public Guid Guid; | |
/// <summary> | |
/// Instance de <see cref="ExposedGuid"/> permettant de modifier la valeur des champs. | |
/// </summary> | |
[FieldOffset(0)] | |
public ExposedGuid ExposedGuid; | |
} | |
/// <summary> | |
/// Expose la structure de <see cref="Guid"/> au travers de champs publics. | |
/// </summary> | |
private struct ExposedGuid | |
{ | |
#pragma warning disable 169 | |
#pragma warning disable 649 | |
// ReSharper disable InconsistentNaming | |
public int _a; | |
public short _b; | |
public short _c; | |
public byte _d; | |
public byte _e; | |
public byte _f; | |
public byte _g; | |
public byte _h; | |
public byte _i; | |
public byte _j; | |
public byte _k; | |
// ReSharper restore InconsistentNaming | |
#pragma warning restore 649 | |
#pragma warning restore 169 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment