API Reference / Sandbox / SandboxSystemExtensions SandboxSystemExtensionsclass object → SandboxSystemExtensions
Namespace Sandbox Assembly Sandbox.System Declaration public static abstract sealed class Sandbox . SandboxSystemExtensions Parameter Type Description self Random —
public static int AsInt ( T value ) PUBLIC STATIC Parameter Type Description value T —
Parameter Type Description base64EncodedData string —
Parameter Type Description plainText string —
Parameter Type Description i int —
public static System . Collections . Generic . IEnumerable ` 1 < Vector3 > CatmullRomSpline ( System . Collections . Generic . IEnumerable ` 1 < Vector3 > points , int interpolation ) PUBLIC STATIC Parameter Type Description points IEnumerable <Vector3 >— interpolation int —
Parameter Type Description prop PropertyInfo The property whose arguments to test. obj object Instance of the object this property is of. errors string []If returned false, these will be the error messages to display. name = null string Override the property name in error messages.
Returns: bool Returns true if all checks have passed or there is no attributes to test, false if there were errors.
Parameter Type Description input T — min T — max T —
public static System . Collections . Generic . Dictionary ` 2 < TKey , TValue > Clone ( System . Collections . Generic . Dictionary ` 2 < TKey , TValue > dict ) PUBLIC STATIC Parameter Type Description dict Dictionary <TKey ,TValue >—
Returns: Dictionary <TKey ,TValue >—
Parameter Type Description str string —
Parameter Type Description str string —
public static Color Color ( System . Random self ) PUBLIC STATIC Returns a random Color
Parameter Type Description self Random —
Parameter Type Description str string — maxLength int — right = False bool —
Parameter Type Description source string — target string —
Parameter Type Description str string —
Parameter Type Description str string —
public static float FloatDeterministic ( System . Random self , int i ) PUBLIC STATIC Get a random float (0-1) from a pre-calculated list. This is faster, and if you put the same seed in, it will always return the same number.
The downside is that it only has 8192 variations of floats, but that seem like enough for most things.
Parameter Type Description self Random — i int —
public static System . Threading . Tasks . Task ForEachTaskAsync ( System . Collections . Generic . IEnumerable ` 1 < T > source , System . Func ` 2 < T , System . Threading . Tasks . Task > body , int maxRunning = 8 , System . Threading . CancellationToken token = null ) PUBLIC STATIC Parameter Type Description source IEnumerable <T >— body Func <T ,Task >— maxRunning = 8 int — token = null CancellationToken —
public static string FormatBytes ( T input , bool shortFormat = False ) PUBLIC STATIC Given a number, will format as a memory value, ie 10gb, 4mb
Parameter Type Description input T — shortFormat = False bool —
Parameter Type Description num int —
Parameter Type Description self Random — array T []— defVal = null T —
Parameter Type Description input string —
public static T FromList ( System . Random self , System . Collections . Generic . List ` 1 < T > array , T defVal = null ) PUBLIC STATIC Parameter Type Description self Random — array List <T >— defVal = null T —
Parameter Type Description self Random — mean = 0 float — stdDev = 1 float —
public static Vector2 Gaussian2D ( System . Random self , System . Nullable ` 1 < Vector2 > mean = null , System . Nullable ` 1 < Vector2 > stdDev = null ) PUBLIC STATIC Parameter Type Description self Random — mean = null Nullable <Vector2 >— stdDev = null Nullable <Vector2 >—
public static Vector3 Gaussian3D ( System . Random self , System . Nullable ` 1 < Vector3 > mean = null , System . Nullable ` 1 < Vector3 > stdDev = null ) PUBLIC STATIC Parameter Type Description self Random — mean = null Nullable <Vector3 >— stdDev = null Nullable <Vector3 >—
public static Vector4 Gaussian4D ( System . Random self , System . Nullable ` 1 < Vector4 > mean = null , System . Nullable ` 1 < Vector4 > stdDev = null ) PUBLIC STATIC Parameter Type Description self Random — mean = null Nullable <Vector4 >— stdDev = null Nullable <Vector4 >—
Parameter Type Description enumVal Enum The enum value
Returns: T The attribute of type T that exists on the enum value
Example Built-in examples define the default contract and should be read first.
public static System . Type GetCommonBaseType ( System . Collections . Generic . IEnumerable ` 1 < System . Type > types ) PUBLIC STATIC Parameter Type Description types IEnumerable <Type >—
Parameter Type Description d DateTime —
Parameter Type Description input string —
Note
An IL-level `sizeof(t)` will return `sizeof(IntPtr)` for reference types, as it refers to the size on stack or in an object,
not the size on heap.
Parameter Type Description t Type —
public static TValue GetOrCreate ( System . Collections . Generic . IDictionary ` 2 < TKey , TValue > dict , TKey key ) PUBLIC STATIC Parameter Type Description dict IDictionary <TKey ,TValue >— key TKey —
Parameter Type Description jso JsonObject — membername string — defaultvalue T —
public static string HtmlEncode ( string str ) PUBLIC STATIC Parameter Type Description str string —
Parameter Type Description src Type The type to test. test Type The type to test against. Typically this will be something like typeof( MyType<> )
Parameter Type Description property PropertyInfo The property to test.
Returns: bool Returns true if the property is init-only, false otherwise.
public static bool IsPowerOfTwo ( int x ) PUBLIC STATIC Return true if the number is a power of two (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc)
Parameter Type Description x int —
Parameter Type Description obj IValid —
Parameter Type Description source string —
Parameter Type Description input string —
Parameter Type Description a int — single string — plural string —
Parameter Type Description str string — optional = False bool —
Parameter Type Description stream Stream The stream to read from. offset long Offset where to start reading, from the beginning of the stream.
Parameter Type Description str string —
Parameter Type Description self Random —
Parameter Type Description str string —
public static string Snippet ( string source , string find , int padding ) PUBLIC STATIC Given a large string, find all occurrences of a substring and return them with padding.
This is useful in situations where you're searching for a word in a hug body of text, and
want to show how it's used without displaying the whole text.
Parameter Type Description source string — find string — padding int —
public static string [ ] SplitQuotesStrings ( string input ) PUBLIC STATIC in : I am "splitting a" string "because it's fun "
out : ["I", "am", "splitting a", "string", "because it's fun"]
Parameter Type Description input string —
public static System . Collections . Generic . IEnumerable ` 1 < Vector3 > TcbSpline ( System . Collections . Generic . IEnumerable ` 1 < Vector3 > points , int interpolation , float tension , float continuity , float bias ) PUBLIC STATIC Parameter Type Description points IEnumerable <Vector3 >— interpolation int — tension float — continuity float — bias float —
Parameter Type Description i T —
public static bool ToBool ( string str ) PUBLIC STATIC Try to convert to bool. Inputs can be true, false, yes, no, 0, 1, null (caps insensitive)
Parameter Type Description str string —
Parameter Type Description str string — Default = default decimal —
Parameter Type Description str string — Default = 0 float —
Parameter Type Description expression string — Default = 0 double —
Parameter Type Description str string — Default = 0 float —
Parameter Type Description expression string — Default = 0 float —
Parameter Type Description input string —
Parameter Type Description str string — Default = 0 int —
Parameter Type Description expression string — Default = 0 int —
Parameter Type Description str string — Default = 0 long —
Parameter Type Description expression string — Default = 0 long —
public static string ToRemainingTimeString ( System . TimeSpan span ) PUBLIC STATIC Parameter Type Description span TimeSpan —
Parameter Type Description source string —
Parameter Type Description str string — t Type —
Parameter Type Description str string — Default = 0 int —
Parameter Type Description str string — Default = 0 ulong —
Parameter Type Description str string — ignoreSurroundingSpaces = False bool —
public static string Truncate ( string str , int maxLength , string appendage = null ) PUBLIC STATIC If the string is longer than this amount of characters then truncate it
If appendage is defined, it will be appended to the end of truncated strings (ie, "..")
Parameter Type Description str string — maxLength int — appendage = null string —
public static string TruncateFilename ( string str , int maxLength , string appendage = null ) PUBLIC STATIC If the string is longer than this amount of characters then truncate it
If appendage is defined, it will be appended to the end of truncated strings (ie, "..")
Parameter Type Description str string — maxLength int — appendage = null string —
Parameter Type Description str string — t Type — Value object —
public static int UnsignedMod ( int a , int b ) PUBLIC STATIC Does what you expected to happen when you did "a % b", that is, handles negative `a` values by returning a positive number from the end.
Parameter Type Description a int — b int —
public static string UrlEncode ( string str ) PUBLIC STATIC Parameter Type Description str string —
Parameter Type Description self Random — radius = 1 float —
Parameter Type Description self Random — radius = 1 float —
Parameter Type Description self Random — extents = 1 float —
Parameter Type Description str string — wildcard string —
Parameter Type Description path string A file path with or without an extension. ext string A file extension with or without a leading period.
public static T WithFlag ( T value , T flag , bool set ) PUBLIC STATIC Parameter Type Description value T — flag T — set bool —
No results match this filter.