Advertisement
Guest User

Plugin Example Manifest

a guest
Jul 15th, 2021
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. using Intersect.Plugins.Interfaces;
  2. using Intersect.Plugins.Manifests.Types;
  3. using Intersect.Utilities;
  4.  
  5. using Semver;
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9.  
  10. namespace Intersect.Examples.Plugin.Client
  11. {
  12. /// <summary>
  13. /// Defines a plugin manifest in code rather than an embedded manifest.json file.
  14. /// </summary>
  15. public struct Manifest : IManifestHelper, IEquatable<IManifestHelper>, IEquatable<Manifest>
  16. {
  17. // ReSharper disable once AssignNullToNotNullAttribute This will not be null.
  18. /// <inheritdoc />
  19. public string Name => typeof(Manifest).Namespace;
  20.  
  21. // ReSharper disable once AssignNullToNotNullAttribute This will not be null.
  22. /// <inheritdoc />
  23. public string Key => typeof(Manifest).Namespace;
  24.  
  25. /// <inheritdoc />
  26. public SemVersion Version => new SemVersion(1);
  27.  
  28. /// <inheritdoc />
  29. public Authors Authors =>
  30. "Ascension Game Dev <admin@ascensiongamedev.com> (https://github.com/AscensionGameDev/Intersect-Engine)";
  31.  
  32. /// <inheritdoc />
  33. public string Homepage => "https://github.com/AscensionGameDev/Intersect-Engine";
  34.  
  35. public override bool Equals(object obj) => obj is Manifest other && Equals(other) ||
  36. obj is IManifestHelper otherManifestHelper &&
  37. Equals(otherManifestHelper);
  38.  
  39. public override int GetHashCode() => ValueUtils.ComputeHashCode(Name, Key, Version, Authors, Homepage);
  40.  
  41. public static bool operator ==(Manifest left, Manifest right) => left.Equals(right);
  42.  
  43. public static bool operator !=(Manifest left, Manifest right) => !(left == right);
  44.  
  45. public bool Equals(Manifest other) => Equals(other as IManifestHelper);
  46.  
  47. public bool Equals(IManifestHelper other) => other != null &&
  48. string.Equals(Name, other.Name, StringComparison.Ordinal) &&
  49. string.Equals(Key, other.Key, StringComparison.Ordinal) &&
  50. Version.Equals(other.Version) &&
  51. Authors.Equals(other.Authors as IEnumerable<Author>) &&
  52. string.Equals(Homepage, other.Homepage,
  53. StringComparison.OrdinalIgnoreCase);
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement