Struct PermissionLeaf
- Namespace
- Uncreated.Warfare.Players.Permissions
- Assembly
- Uncreated.Warfare.dll
Represents an absolute permission with no wildcards or additive/subtractive metadata.
[JsonConverter(typeof(PermissionLeafJsonConverter))]
public readonly struct PermissionLeaf : IEquatable<PermissionLeaf>, IEquatable<PermissionBranch>, ITranslationArgument
- Implements
- Inherited Members
- Extension Methods
Remarks
Stolen from DevkitServer.
Constructors
PermissionLeaf(string)
Parse a permission leaf with or without a prefix.
public PermissionLeaf(string path)
Parameters
pathstring
Remarks
Permission leafs without prefixes will be invalid.
Exceptions
- FormatException
Parse failure.
Fields
InvalidPrefix
Prefix for invalid permissions.
public const string InvalidPrefix = "unknown"
Field Value
Nil
A permission that can never be met.
public static readonly PermissionLeaf Nil
Field Value
UnturnedModulePrefix
Prefix for Core permissions.
public const string UnturnedModulePrefix = "unturned"
Field Value
WarfareModulePrefix
Prefix for Warfare module permissions.
public const string WarfareModulePrefix = "warfare"
Field Value
Properties
Level
Permission depth level (number of periods plus one).
public int Level { get; }
Property Value
Path
The path relative to the leaf's domain. The domain is the permission prefix of the permission owner.
public string Path { get; }
Property Value
Remarks
Example: request.vehicle.
Unturned
Is this permission relating to the base game?
public bool Unturned { get; }
Property Value
Valid
Is this permission valid (has a path and a source definition)?
public bool Valid { get; }
Property Value
Warfare
Is this permission relating to Uncreated Warfare?
public bool Warfare { get; }
Property Value
Methods
CountLevels(string)
Count the number of levels in a path. Example: warfare::request.vehicle would return 2.
public static int CountLevels(string path)
Parameters
pathstring
Returns
Remarks
Can optionally have a prefix.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(PermissionBranch)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(PermissionBranch branch)
Parameters
branchPermissionBranch
Returns
Equals(PermissionLeaf)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(PermissionLeaf leaf)
Parameters
leafPermissionLeaf
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetPrefix()
Get the permission prefix.
public string GetPrefix()
Returns
Remarks
Looks like this when placed in a full permission leaf: warfare::request.vehicle.
Parse(string)
Parse a permission leaf with a prefix.
public static PermissionLeaf Parse(string path)
Parameters
pathstring
Returns
Exceptions
- FormatException
Parse failure.
Read(ByteReader)
public static PermissionLeaf Read(ByteReader reader)
Parameters
readerByteReader
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Translate(ITranslationValueFormatter, in ValueFormatParameters)
Allows objects to define how they're translated in their own definition instead of creating a value converter.
public string Translate(ITranslationValueFormatter formatter, in ValueFormatParameters parameters)
Parameters
formatterITranslationValueFormatterparametersValueFormatParameters
Returns
TryParse(string, out PermissionLeaf)
Parse a permission leaf with a prefix.
public static bool TryParse(string path, out PermissionLeaf permissionLeaf)
Parameters
pathstringpermissionLeafPermissionLeaf
Returns
Write(ByteWriter, PermissionLeaf)
public static void Write(ByteWriter writer, PermissionLeaf leaf)
Parameters
writerByteWriterleafPermissionLeaf
Operators
operator ==(PermissionLeaf, PermissionLeaf)
public static bool operator ==(PermissionLeaf left, PermissionLeaf right)
Parameters
leftPermissionLeafrightPermissionLeaf
Returns
implicit operator PermissionBranch(PermissionLeaf)
public static implicit operator PermissionBranch(PermissionLeaf leaf)
Parameters
leafPermissionLeaf
Returns
operator !=(PermissionLeaf, PermissionLeaf)
public static bool operator !=(PermissionLeaf left, PermissionLeaf right)
Parameters
leftPermissionLeafrightPermissionLeaf