-
-
Notifications
You must be signed in to change notification settings - Fork 44
sharedlibrarycore Utilities
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph SharedLibraryCore
SharedLibraryCore.Utilities[[Utilities]]
end
Type | Name | Methods |
---|---|---|
char |
CommandPrefix |
get, set |
TimeSpan |
DefaultCommandTimeout |
get, set |
ILogger |
DefaultLogger |
get, set |
bool |
IsDevelopment indicates if running in development mode |
get |
string |
OperatingDirectory |
get |
Dictionary <Permission , string > |
PermissionLevelOverrides |
get |
Returns | Name |
---|---|
IServiceCollection |
AddConfiguration (IServiceCollection serviceCollection, string fileName, TConfigurationType defaultConfig) |
double``[] |
AngleStuff (Vector3 a, Vector3 b) |
EFClient |
AsConsoleClient (IGameServer server) |
string |
CapClientName (string name, int maxLength)caps client name to the specified character length - 3 and adds ellipses to the end of the remaining client name |
long |
ConvertGuidToLong (... ) |
string |
ConvertIPtoString (Nullable <int > ip) |
string |
ConvertLevelToColor (Permission level, string localizedLevel) |
Nullable <int > |
ConvertToIP (string str) |
Dictionary <string , string > |
DictionaryFromKeyValue (string eventLine) |
void |
ExecuteAfterDelay (... ) |
Task <string``[] > |
ExecuteCommandAsync (... ) |
string |
FindRuleForReason (string reason, ApplicationConfiguration appConfig, Server server) |
string |
FixDirectoryCharacters (string path)replaces any directory separator chars with the platform specific character |
Vector3 |
FixIW4Angles (Vector3 vector) |
string |
FixIW4ForwardSlash (string str)returns a "fixed" string that prevents message truncation in IW4 (and probably other Q3 clients) |
string |
FormatExt (string input, object``[] values) |
string |
FormatMessageForEngine (string str, IRConParserConfiguration config) |
string``[] |
FragmentMessageForDisplay (string message) |
long |
GenerateGuidFromString (string value)generates a numerical hashcode from a string value |
string |
GetCommandLine (int pId) |
Task <Dvar <T >> |
GetDvarAsync (... ) |
Task <string > |
GetExternalIP ()retrieves the external IP address of the current running machine |
Game |
GetGame (string gameName) |
Task <IDictionary <string , string >> |
GetInfoAsync (Server server, Nullable <TimeSpan > delay) |
string |
GetLocalizedGametype (string input)Get the full gametype name |
Task <Dvar <T >> |
GetMappedDvarValueOrDefaultAsync (Server server, string dvarName, string infoResponseName, IDictionary <string , string > infoResponse, T overrideDefault, CancellationToken token) |
int |
GetStableHashCode (string str) |
Task <IStatusResponse > |
GetStatusAsync (Server server, CancellationToken token) |
double |
GetVersionAsDouble () |
string |
GetVersionAsString () |
bool |
HasPermission (... ) |
string |
HumanizeForCurrentCulture (... )wrapper method for humanizee that uses current current culture |
EFClient |
IW4MAdminClient (Server server) |
bool |
IsBotGuid (string guid)determines if the guid provided appears to be a bot guid "1277538174" - (Pluto?)WaW (T4) |
bool |
IsBroadcastCommand (string str, string broadcastCommandPrefix) |
bool |
IsCodGame (Server server) |
bool |
IsInternal (IPAddress toTest)https://stackoverflow.com/questions/8113546/how-to-determine-whether-an-ip-address-in-private/39120248 An extension method to determine if an IP address is internal, as specified in RFC1918 |
bool |
IsPrivileged (EFClient p)Helper extension that determines if a user is a privileged client |
bool |
IsQuickMessage (string message)Determines if the given message is a quick message |
bool |
IsRemoteLog (string log)indicates if the given log path is a remote (http) uri |
bool |
IsZombieServer (Server server)indicates if the given server is running a zombie game mode |
PenaltyType``[] |
LinkedPenaltyTypes ()returns a list of penalty types that should be shown across all profiles |
string |
MakeAbbreviation (string gameName) |
Permission |
MatchPermission (string str) |
TimeSpan |
ParseTimespan (string input) |
Task <string > |
ProcessMessageToken (Server server, IList <MessageToken > tokens, string str) |
bool |
PromptBool (string question, string description, bool defaultValue)prompt user to answer a yes/no question |
int |
PromptInt (string question, string description, int minValue, int maxValue, Nullable <int > defaultValue) |
(int Item1, T Item2) |
PromptSelection (string question, T defaultValue, string description, T``[] selections) |
string |
PromptString (string question, string description, string defaultValue)prompt use to enter a string response |
string |
RemoveDiacritics (string text) |
string |
RemoveWords (string str, int num) |
Task |
SetDvarAsync (... ) |
bool |
ShouldHideLevel (Permission perm) |
WebfrontTranslationHelper []
|
SplitTranslationTokens (string translationKey)parses translation string into tokens that are able to be formatted by the webfront |
string |
StripColors (string str)Remove all IW Engine color codes |
string |
ToBase64UrlSafeString (string src) |
float |
ToDegrees (float value) |
string |
ToLocalizedLevelName (Permission permission) |
string |
ToNumericalString (... ) |
EFClient |
ToPartialClient (EFClient client) |
float |
ToRadians (float value) |
string |
ToStandardFormat (... ) |
string |
ToTranslatedName (MetaType metaType) |
string |
TrimNewLine (string str)trims new line and whitespace from string |
Task <bool > |
TryCreatePenalty (EFPenalty penalty, IEntityService <EFPenalty > penaltyService, ILogger logger) |
Task <T > |
WithTimeout (... ) |
Task |
WithWaitCancellation (... )https://www.planetgeek.ch/2016/12/08/async-method-without-cancellation-support-do-it-my-way/ |
Returns | Name |
---|---|
string |
[`g__InputOrDefault |
string |
[`g__InputOrDefault |
public static string ToStandardFormat(Nullable<DateTime> time)
Type | Name | Description |
---|---|---|
Nullable <DateTime > |
time |
public static string ToStandardFormat(DateTime time)
Type | Name | Description |
---|---|---|
DateTime |
time |
public static EFClient IW4MAdminClient(Server server)
Type | Name | Description |
---|---|---|
Server |
server |
public static EFClient AsConsoleClient(IGameServer server)
Type | Name | Description |
---|---|---|
IGameServer |
server |
public static string RemoveWords(string str, int num)
Type | Name | Description |
---|---|---|
string |
str | |
int |
num |
public static string CapClientName(string name, int maxLength)
Type | Name | Description |
---|---|---|
string |
name | client name |
int |
maxLength | max number of characters for the name |
caps client name to the specified character length - 3 and adds ellipses to the end of the remaining client name
public static Permission MatchPermission(string str)
Type | Name | Description |
---|---|---|
string |
str |
public static string StripColors(string str)
Type | Name | Description |
---|---|---|
string |
str | String containing color codes |
Remove all IW Engine color codes
public static string FixIW4ForwardSlash(string str)
Type | Name | Description |
---|---|---|
string |
str |
returns a "fixed" string that prevents message truncation in IW4 (and probably other Q3 clients)
public static string RemoveDiacritics(string text)
Type | Name | Description |
---|---|---|
string |
text |
public static string FormatMessageForEngine(string str, IRConParserConfiguration config)
Type | Name | Description |
---|---|---|
string |
str | |
IRConParserConfiguration |
config |
public static bool IsZombieServer(Server server)
Type | Name | Description |
---|---|---|
Server |
server |
indicates if the given server is running a zombie game mode
public static bool IsCodGame(Server server)
Type | Name | Description |
---|---|---|
Server |
server |
public static string ConvertLevelToColor(Permission level, string localizedLevel)
Type | Name | Description |
---|---|---|
Permission |
level | |
string |
localizedLevel |
public static string ToLocalizedLevelName(Permission permission)
Type | Name | Description |
---|---|---|
Permission |
permission |
public static async Task<string> ProcessMessageToken(Server server, IList<MessageToken> tokens, string str)
Type | Name | Description |
---|---|---|
Server |
server | |
IList <MessageToken > |
tokens | |
string |
str |
public static bool IsBroadcastCommand(string str, string broadcastCommandPrefix)
Type | Name | Description |
---|---|---|
string |
str | |
string |
broadcastCommandPrefix |
public static string GetLocalizedGametype(string input)
Type | Name | Description |
---|---|---|
string |
input | Shorthand gametype reported from server |
Get the full gametype name
public static long ConvertGuidToLong(string str, NumberStyles numberStyle, Nullable<long> fallback)
Type | Name | Description |
---|---|---|
string |
str | |
NumberStyles |
numberStyle | |
Nullable <long > |
fallback |
public static long ConvertGuidToLong(string str, NumberStyles numberStyle, bool convertSigned, Nullable<long> fallback)
Type | Name | Description |
---|---|---|
string |
str | |
NumberStyles |
numberStyle | |
bool |
convertSigned | |
Nullable <long > |
fallback |
public static bool IsBotGuid(string guid)
Type | Name | Description |
---|---|---|
string |
guid | value of the guid |
determines if the guid provided appears to be a bot guid "1277538174" - (Pluto?)WaW (T4)
true if is bot guid, otherwise false
public static long GenerateGuidFromString(string value)
Type | Name | Description |
---|---|---|
string |
value | value string |
generates a numerical hashcode from a string value
public static int GetStableHashCode(string str)
Type | Name | Description |
---|---|---|
string |
str |
public static Nullable<int> ConvertToIP(string str)
Type | Name | Description |
---|---|---|
string |
str |
public static string ConvertIPtoString(Nullable<int> ip)
Type | Name | Description |
---|---|---|
Nullable <int > |
ip |
public static Game GetGame(string gameName)
Type | Name | Description |
---|---|---|
string |
gameName |
public static TimeSpan ParseTimespan(string input)
Type | Name | Description |
---|---|---|
string |
input |
public static bool HasPermission<TEntity, TPermission>(IEnumerable<string> permissionsSet, TEntity entity, TPermission permission)
where TEntity : Enum
where TPermission : Enum
Type | Name | Description |
---|---|---|
IEnumerable <string > |
permissionsSet | |
TEntity |
entity | |
TPermission |
permission |
public static bool HasPermission<TEntity, TPermission>(ApplicationConfiguration appConfig, Permission permissionLevel, TEntity entity, TPermission permission)
where TEntity : Enum
where TPermission : Enum
Type | Name | Description |
---|---|---|
ApplicationConfiguration |
appConfig | |
Permission |
permissionLevel | |
TEntity |
entity | |
TPermission |
permission |
public static PenaltyType LinkedPenaltyTypes()
returns a list of penalty types that should be shown across all profiles
public static bool IsPrivileged(EFClient p)
Type | Name | Description |
---|---|---|
EFClient |
p |
Helper extension that determines if a user is a privileged client
public static bool PromptBool(string question, string description, bool defaultValue)
Type | Name | Description |
---|---|---|
string |
question | question to prompt the user with |
string |
description | description of the question's value |
bool |
defaultValue | default value to set if no input is entered |
prompt user to answer a yes/no question
public static Tuple<int,T> PromptSelection<T>(string question, T defaultValue, string description, T[] selections)
where T :
Type | Name | Description |
---|---|---|
string |
question | |
T |
defaultValue | |
string |
description | |
T``[] |
selections |
public static int PromptInt(string question, string description, int minValue, int maxValue, Nullable<int> defaultValue)
Type | Name | Description |
---|---|---|
string |
question | |
string |
description | |
int |
minValue | |
int |
maxValue | |
Nullable <int > |
defaultValue |
public static string PromptString(string question, string description, string defaultValue)
Type | Name | Description |
---|---|---|
string |
question | question to prompt with |
string |
description | description of the question's value |
string |
defaultValue | default value to set the return value to |
prompt use to enter a string response
public static Dictionary<string, string> DictionaryFromKeyValue(string eventLine)
Type | Name | Description |
---|---|---|
string |
eventLine |
public static string GetCommandLine(int pId)
Type | Name | Description |
---|---|---|
int |
pId |
public static bool IsRemoteLog(string log)
Type | Name | Description |
---|---|---|
string |
log |
indicates if the given log path is a remote (http) uri
public static string ToBase64UrlSafeString(string src)
Type | Name | Description |
---|---|---|
string |
src |
public static async Task<Dvar<T>> GetDvarAsync<T>(Server server, string dvarName, T fallbackValue, CancellationToken token)
where T :
Type | Name | Description |
---|---|---|
Server |
server | |
string |
dvarName | |
T |
fallbackValue | |
CancellationToken |
token |
public static async Task<Dvar<T>> GetDvarAsync<T>(Server server, string dvarName, T fallbackValue)
where T :
Type | Name | Description |
---|---|---|
Server |
server | |
string |
dvarName | |
T |
fallbackValue |
public static async Task<Dvar<T>> GetMappedDvarValueOrDefaultAsync<T>(Server server, string dvarName, string infoResponseName, IDictionary<string, string> infoResponse, T overrideDefault, CancellationToken token)
where T :
Type | Name | Description |
---|---|---|
Server |
server | |
string |
dvarName | |
string |
infoResponseName | |
IDictionary <string , string > |
infoResponse | |
T |
overrideDefault | |
CancellationToken |
token |
public static async Task SetDvarAsync(Server server, string dvarName, object dvarValue, CancellationToken token)
Type | Name | Description |
---|---|---|
Server |
server | |
string |
dvarName | |
object |
dvarValue | |
CancellationToken |
token |
public static async Task SetDvarAsync(Server server, string dvarName, object dvarValue)
Type | Name | Description |
---|---|---|
Server |
server | |
string |
dvarName | |
object |
dvarValue |
public static async Task<string> ExecuteCommandAsync(Server server, string commandName, CancellationToken token)
Type | Name | Description |
---|---|---|
Server |
server | |
string |
commandName | |
CancellationToken |
token |
public static async Task<string> ExecuteCommandAsync(Server server, string commandName)
Type | Name | Description |
---|---|---|
Server |
server | |
string |
commandName |
public static async Task<IStatusResponse> GetStatusAsync(Server server, CancellationToken token)
Type | Name | Description |
---|---|---|
Server |
server | |
CancellationToken |
token |
public static async Task<IDictionary<string, string>> GetInfoAsync(Server server, Nullable<TimeSpan> delay)
Type | Name | Description |
---|---|---|
Server |
server | |
Nullable <TimeSpan > |
delay |
public static double GetVersionAsDouble()
public static string GetVersionAsString()
public static string FormatExt(string input, object[] values)
Type | Name | Description |
---|---|---|
string |
input | |
object``[] |
values |
public static bool IsInternal(IPAddress toTest)
Type | Name | Description |
---|---|---|
IPAddress |
toTest | The IP address that will be tested |
https://stackoverflow.com/questions/8113546/how-to-determine-whether-an-ip-address-in-private/39120248 An extension method to determine if an IP address is internal, as specified in RFC1918
Returns true if the IP is internal, false if it is external
public static async Task<string> GetExternalIP()
retrieves the external IP address of the current running machine
public static bool IsQuickMessage(string message)
Type | Name | Description |
---|---|---|
string |
message |
Determines if the given message is a quick message
true if the
public static string TrimNewLine(string str)
Type | Name | Description |
---|---|---|
string |
str | source string |
trims new line and whitespace from string
public static Vector3 FixIW4Angles(Vector3 vector)
Type | Name | Description |
---|---|---|
Vector3 |
vector |
public static float ToRadians(float value)
Type | Name | Description |
---|---|---|
float |
value |
public static float ToDegrees(float value)
Type | Name | Description |
---|---|---|
float |
value |
public static double AngleStuff(Vector3 a, Vector3 b)
Type | Name | Description |
---|---|---|
Vector3 |
a | |
Vector3 |
b |
public static async Task<bool> TryCreatePenalty(EFPenalty penalty, IEntityService<EFPenalty> penaltyService, ILogger logger)
Type | Name | Description |
---|---|---|
EFPenalty |
penalty | |
IEntityService <EFPenalty > |
penaltyService | |
ILogger |
logger |
public static async Task WithWaitCancellation(Task task, CancellationToken cancellationToken)
Type | Name | Description |
---|---|---|
Task |
task | |
CancellationToken |
cancellationToken |
https://www.planetgeek.ch/2016/12/08/async-method-without-cancellation-support-do-it-my-way/
public static async Task<T> WithWaitCancellation<T>(Task<T> task, CancellationToken cancellationToken)
where T :
Type | Name | Description |
---|---|---|
Task <T > |
task | |
CancellationToken |
cancellationToken |
public static async Task<T> WithTimeout<T>(Task<T> task, TimeSpan timeout)
where T :
Type | Name | Description |
---|---|---|
Task <T > |
task | |
TimeSpan |
timeout |
public static async Task WithTimeout(Task task, TimeSpan timeout)
Type | Name | Description |
---|---|---|
Task |
task | |
TimeSpan |
timeout |
public static bool ShouldHideLevel(Permission perm)
Type | Name | Description |
---|---|---|
Permission |
perm |
public static WebfrontTranslationHelper SplitTranslationTokens(string translationKey)
Type | Name | Description |
---|---|---|
string |
translationKey | key for translation lookup |
parses translation string into tokens that are able to be formatted by the webfront
public static string FixDirectoryCharacters(string path)
Type | Name | Description |
---|---|---|
string |
path | original file path |
replaces any directory separator chars with the platform specific character
public static string HumanizeForCurrentCulture(TimeSpan timeSpan, int precision, TimeUnit maxUnit, TimeUnit minUnit, string collectionSeparator, bool toWords)
Type | Name | Description |
---|---|---|
TimeSpan |
timeSpan | |
int |
precision | |
TimeUnit |
maxUnit | |
TimeUnit |
minUnit | |
string |
collectionSeparator | |
bool |
toWords |
wrapper method for humanizee that uses current current culture
public static string HumanizeForCurrentCulture(DateTime input, bool utcDate, Nullable<DateTime> dateToCompareAgainst, CultureInfo culture)
Type | Name | Description |
---|---|---|
DateTime |
input | |
bool |
utcDate | |
Nullable <DateTime > |
dateToCompareAgainst | |
CultureInfo |
culture |
public static string ToTranslatedName(MetaType metaType)
Type | Name | Description |
---|---|---|
MetaType |
metaType |
public static EFClient ToPartialClient(EFClient client)
Type | Name | Description |
---|---|---|
EFClient |
client |
public static string ToNumericalString(Nullable<int> value)
Type | Name | Description |
---|---|---|
Nullable <int > |
value |
public static string ToNumericalString(int value)
Type | Name | Description |
---|---|---|
int |
value |
public static string ToNumericalString(double value, int precision)
Type | Name | Description |
---|---|---|
double |
value | |
int |
precision |
public static string ToNumericalString(Nullable<double> value, int precision)
Type | Name | Description |
---|---|---|
Nullable <double > |
value | |
int |
precision |
public static string FragmentMessageForDisplay(string message)
Type | Name | Description |
---|---|---|
string |
message |
public static string FindRuleForReason(string reason, ApplicationConfiguration appConfig, Server server)
Type | Name | Description |
---|---|---|
string |
reason | |
ApplicationConfiguration |
appConfig | |
Server |
server |
public static string MakeAbbreviation(string gameName)
Type | Name | Description |
---|---|---|
string |
gameName |
public static IServiceCollection AddConfiguration<TConfigurationType>(IServiceCollection serviceCollection, string fileName, TConfigurationType defaultConfig)
where TConfigurationType :
Type | Name | Description |
---|---|---|
IServiceCollection |
serviceCollection | |
string |
fileName | |
TConfigurationType |
defaultConfig |
public static void ExecuteAfterDelay(TimeSpan duration, Func<CancellationToken, Task> action, CancellationToken token)
Type | Name | Description |
---|---|---|
TimeSpan |
duration | |
Func <CancellationToken , Task > |
action | |
CancellationToken |
token |
public static void ExecuteAfterDelay(int delayMs, Func<CancellationToken, Task> action, CancellationToken token)
Type | Name | Description |
---|---|---|
int |
delayMs | |
Func <CancellationToken , Task > |
action | |
CancellationToken |
token |
public static void ExecuteAfterDelay(Func<CancellationToken, Task> action, int delayMs, CancellationToken token)
Type | Name | Description |
---|---|---|
Func <CancellationToken , Task > |
action | |
int |
delayMs | |
CancellationToken |
token |
internal static string <PromptInt>g__InputOrDefault|55_0()
internal static string <PromptString>g__InputOrDefault|56_0()
public static ILogger DefaultLogger { get; set; }
public static string OperatingDirectory { get; }
public static TimeSpan DefaultCommandTimeout { get; set; }
public static char CommandPrefix { get; set; }
public static Dictionary<Permission, string> PermissionLevelOverrides { get; }
public static bool IsDevelopment { get; }
indicates if running in development mode
Generated with ModularDoc