ServiceStack.Common Register Task to run in APP_TASKS=task1;task2 Asserts that the supplied arguments are not null. AssertUtils.AreNotNull(new Dictionary<string,object>{ {"name",null} }); will throw new ArgumentNullException("name"); The field map. An async-compatible manual-reset event. The object used for synchronization. The current state of the event. The semi-unique identifier for this instance. This is 0 if the id has not yet been created. Creates an async-compatible manual-reset event. Whether the manual-reset event is initially set or unset. Creates an async-compatible manual-reset event that is initially unset. Gets a semi-unique identifier for this asynchronous manual-reset event. Whether this event is currently set. This member is seldom used; code using this member has a high possibility of race conditions. Asynchronously waits for this event to be set. Asynchronously waits for this event to be set or for the wait to be canceled. The cancellation token used to cancel the wait. If this token is already canceled, this method will first check whether the event is set. Synchronously waits for this event to be set. This method may block the calling thread. Synchronously waits for this event to be set. This method may block the calling thread. The cancellation token used to cancel the wait. If this token is already canceled, this method will first check whether the event is set. Sets the event, atomically completing every task returned by . If the event is already set, this method does nothing. Resets the event. If the event is already reset, this method does nothing. Allocates Ids for instances on demand. 0 is an invalid/unassigned Id. Ids may be non-unique in very long-running systems. This is similar to the Id system used by and . The type for which ids are generated. The last id generated for this type. This is 0 if no ids have been generated. Returns the id, allocating it if necessary. A reference to the field containing the id. Holds the task for a cancellation token, as well as the token registration. The registration is disposed when this instance is disposed. The cancellation token registration, if any. This is null if the registration was not necessary. Creates a task for the specified cancellation token, registering with the token if necessary. The cancellation token to observe. Gets the task for the source cancellation token. Disposes the cancellation token registration, if any. Note that this may cause to never complete. Provides extension methods for . Attempts to complete a , propagating the completion of . The type of the result of the target asynchronous operation. The type of the result of the source asynchronous operation. The task completion source. May not be null. The task. May not be null. true if this method completed the task completion source; false if it was already completed. Attempts to complete a , propagating the completion of but using the result value from if the task completed successfully. The type of the result of the target asynchronous operation. The task completion source. May not be null. The task. May not be null. A delegate that returns the result with which to complete the task completion source, if the task completed successfully. May not be null. true if this method completed the task completion source; false if it was already completed. Creates a new TCS for use with async code, and which forces its continuations to execute asynchronously. The type of the result of the TCS. Provides synchronous extension methods for tasks. Asynchronously waits for the task to complete, or for the cancellation token to be canceled. The task to wait for. May not be null. The cancellation token that cancels the wait. Waits for the task to complete, unwrapping any exceptions. The task. May not be null. Waits for the task to complete, unwrapping any exceptions. The task. May not be null. A cancellation token to observe while waiting for the task to complete. The was cancelled before the completed, or the raised an . Waits for the task to complete, unwrapping any exceptions. The type of the result of the task. The task. May not be null. The result of the task. Waits for the task to complete, unwrapping any exceptions. The type of the result of the task. The task. May not be null. A cancellation token to observe while waiting for the task to complete. The result of the task. The was cancelled before the completed, or the raised an . Waits for the task to complete, but does not raise task exceptions. The task exception (if any) is unobserved. The task. May not be null. Waits for the task to complete, but does not raise task exceptions. The task exception (if any) is unobserved. The task. May not be null. A cancellation token to observe while waiting for the task to complete. The was cancelled before the completed. Attempts to prepare the exception for re-throwing by preserving the stack trace. The returned exception should be immediately thrown. The exception. May not be null. The that was passed into this method. Provide the an option for the callee to block until all commands are executed Constant Time byte[] comparison Return T[0] when enumerable is null, safe to use in enumerations like foreach Gets the textual description of the enum if it has one. e.g. enum UserColors { [Description("Bright Red")] BrightRed } UserColors.BrightRed.ToDescription(); Default base sleep time (milliseconds). Default maximum back-off time before retrying a request Maximum retry limit. Avoids integer overflow issues. How long to sleep before next retry using Exponential BackOff delay with Full Jitter. How long to wait before next retry using Exponential BackOff delay with Full Jitter. Exponential BackOff Delay with Full Jitter Exponential BackOff Delay with Full Jitter from: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/retry/PredefinedBackoffStrategies.java Calculate exponential retry back-off. Calculate exponential retry back-off. Calculate back-off logic for obtaining an in memory lock Move conflicting extension methods to ServiceStack.Extensions namespace Invokes the action provided and returns true if no exception was thrown. Otherwise logs the exception and returns false if an exception was thrown. The action. AccessTokenSecret Intercept and override GitHub JSON API requests Create or Write Gist Text Files. Requires AccessToken Create new Gist File. Requires AccessToken Create or Write Gist File. Requires AccessToken Helper utility for inspecting variables Dump serialized values to 'vars.json' Anonymous object with named value Recursively prints the contents of any POCO object in a human-friendly, readable format Print Dump to Console.WriteLine Dump object in Ascii Markdown table Dump object in Ascii Markdown table Dump object in Ascii Markdown table using specified column headers Print Dump object in Ascii Markdown table Print Dump object in Ascii Markdown table using specified column headers Recursively prints the contents of any POCO object to HTML Recursively prints the contents of any POCO object to HTML Recursively prints the contents of any POCO object to HTML with specified columns Print htmlDump object Print htmlDump object with specified columns Transforms multiple data content types into a FileContents containing either a binary Stream or text string Transform multi supported content types into FileContents containing either Stream or string. If returning unbuffered Stream responsibility is up to callee to properly dispose Get only files in this directory Get only sub directories in this directory Get All Files in current and all sub directories Useful IPAddressExtensions from: http://blogs.msdn.com/knom/archive/2008/12/31/ip-address-calculations-with-c-subnetmasks-networks.aspx Gets the ipv4 addresses from all Network Interfaces that have Subnet masks. Gets the ipv6 addresses from all Network Interfaces. Configure ServiceStack.Text JSON Serializer to use Templates JS parsing Parse JS Expression into an AST Token Returns cached AST of a single expression Returns cached AST of a script Lightweight expression evaluator of a single JS Expression with results cached in global context cache Creates a Console Logger, that logs all messages to: System.Console Made public so its testable Default logger is to Console.WriteLine Made public so its testable Initializes a new instance of the class. Initializes a new instance of the class. Logs the specified message. Logs the format. Logs the specified message. Creates a Debug Logger, that logs all messages to: System.Diagnostics.Debug Made public so its testable Default logger is to System.Diagnostics.Debug.WriteLine Made public so its testable Initializes a new instance of the class. Initializes a new instance of the class. Logs the specified message. Logs the format. Logs the specified message. Categories of sql statements. Unknown DML statements that alter database state, e.g. INSERT, UPDATE Statements that return a single record Statements that iterate over a result set A callback for ProfiledDbConnection and family Called when a command starts executing Called when a reader finishes executing Called when a reader is done iterating through the data Called when an error happens during execution of a command True if the profiler instance is active Wraps a database connection, allowing sql execution timings to be collected when a session is started. Returns a new that wraps , providing query execution profiling. If profiler is null, no profiling will occur. Your provider-specific flavor of connection, e.g. SqlConnection, OracleConnection The currently started or null. Determines whether the ProfiledDbConnection will dispose the underlying connection. The underlying, real database connection to your db provider. The current profiler instance; could be null. The raw connection this is wrapping Wrapper for a db provider factory to enable profiling Every provider factory must have an Instance public field Allow to re-init the provider factory. proxy proxy proxy proxy proxy proxy proxy proxy proxy proxy Runs an action for a minimum of runForMs What to run Minimum ms to run for time elapsed in micro seconds Returns average microseconds an action takes when run for the specified runForMs What to run How many times to run for each iteration Minimum ms to run for Async Process Helper - https://gist.github.com/Indigo744/b5f3bd50df4b179651c876416bf70d0a .NET Core / Win throws Win32Exception (193): The specified executable is not a valid application for this OS platform. This method converts it to a cmd.exe /c execute to workaround this Returns path of executable if exists within PATH Run the command with the OS's command runner Run the process and return the Standard Output, any Standard Error output will throw an Exception Run the command with the OS's command runner Run a Process asynchronously, returning entire captured process output, whilst streaming stdOut, stdErr callbacks Run process result Exit code If NULL, process exited due to timeout Standard error stream Standard output stream UTC Start UTC End Duration (ms) Duration (ms) Duplicate Params are given a unique key by appending a #1 suffix Captures the output and assigns it to the specified variable. Accepts an optional Object Dictionary as scope arguments when evaluating body. Usages: {{#capture output}} {{#each args}} - [{{it}}](/path?arg={{it}}) {{/each}} {{/capture}} {{#capture output {nums:[1,2,3]} }} {{#each nums}} {{it}} {{/each}} {{/capture}} {{#capture appendTo output {nums:[1,2,3]} }} {{#each nums}} {{it}} {{/each}} {{/capture}} Parse csv contents into a string dictionary List and assign to identifier Usage: {{#csv list}} Item,Qty Apples,2 Oranges,3 {{/csv}} Handlebars.js like each block Usages: {{#each customers}} {{Name}} {{/each}} {{#each customers}} {{it.Name}} {{/each}} {{#each num in numbers}} {{num}} {{/each}} {{#each num in [1,2,3]}} {{num}} {{/each}} {{#each numbers}} {{it}} {{else}} no numbers {{/each}} {{#each numbers}} {{it}} {{else if letters != null}} has letters {{else}} no numbers {{/each}} {{#each n in numbers where n > 5}} {{it}} {{else}} no numbers > 5 {{/each}} {{#each n in numbers where n > 5 orderby n skip 1 take 2}} {{it}} {{else}} no numbers > 5 {{/each}} Special block which evaluates the rendered body as a ServiceStack Template Usages: {{#eval}}emit {{evaluateBodyOfArg}} at {{now}} {{/eval}} {{#eval {scopeArg:1} }} emit {{evaluateBodyOfArg}} at {{now}} with {{scopeArg}} {{/eval}} {{#eval {htmlDecode:true} }} emit htmldecoded {{evaluateBodyOfArg}} at {{now}} {{/eval}} {{#eval {use:{methods:'ServiceStackScripts',plugins:['MarkdownScriptPlugin']} }} emit {{evaluateBodyOfArg}} at {{now}} in new context {{/eval}} {{#eval { use:{context:true} } }} emit {{evaluateBodyOfArg}} in host context {{/eval}} Define a reusable function Usage: {{#function calc(a, b) }} a * b | to => c a + b + c | return {{/function}} Usages: {{#ul {each:items, class:'nav'} }}
  • {{it}}
  • {{/ul}}
    Handlebars.js like if block Usages: {{#if a > b}} max {{a}} {{/if}} {{#if a > b}} max {{a}} {{else}} max {{b}} {{/if}} {{#if a > b}} max {{a}} {{else if b > c}} max {{b}} {{else}} max {{c}} {{/if}} Parse text contents into a list of string Key/Value pairs and assign to specified identifier Usage: {{#keyvalues list}} Apples 2 Oranges 3 {{/keyvalues}} {{#keyvalues list ':'}} Grape Fruit: 2 Rock Melon: 3 {{/keyvalues}} Handlebars.js like noop block Usage: Remove {{#noop}} contents in here {{/noop}} Partial Block doesn't emit anything it only creates and saves a partial in the PageResult Usages: {{#partial mypartial}} contents {{/partial}} {{#partial mypartial {format:'html'} }} contents {{/partial}} {{#partial mypartial {format:'html', pageArg:1} }} contents {{/partial}} Special block which captures the raw body as a string fragment Usages: {{#raw}}emit {{ verbatim }} body{{/raw}} {{#raw varname}}assigned to varname{{/raw}} {{#raw appendTo varname}}appended to varname{{/raw}} while block Usages: {{#while times > 0}} {{times}}. {{times - 1 | to => times}} {{/while}} {{#while b}} {{ false | to => b }} {{else}} {{b}} was false {{/while}} Max Iterations = Context.Args[ScriptConstants.MaxQuota] Handlebars.js like with block Usages: {{#with person}} Hi {{name}}, I'm {{age}} years old{{/with}} {{#with person}} Hi {{name}}, I'm {{age}} years old {{else}} no person {{/with}} Evaluate if result can be async, if so converts async result to Task<object> otherwise wraps result in a Task Evaluate if result can be async, if so converts async result to Task<object> otherwise wraps result in a Task Evaluate if result can be async, if so converts async result to Task<object> otherwise wraps result in a Task Evaluate then set asyncResult if Result was async, otherwise set result. true if result was synchronous otherwise false Puts value in dictionary at key value Returns Type from type name syntax of .NET's typeof() Qualified Constructor Name Examples: - Type() - Type(string) - GenericType<string<(System.Int32) - Namespace.Type() Shorter Alias for Constructor Shorter Alias for Function Shorter Alias for Function(name,args) Qualified Method Name Examples: - Console.WriteLine(string) - Type.StaticMethod - Type.InstanceMethod - GenericType<string<.Method - GenericType<string<.GenericMethod<System.Int32< - Namespace.Type.Method Resolve Function from qualified type name, when args Type list are unspecified fallback to use args to resolve ambiguous methods Qualified Method Name Examples: - Console.WriteLine ['string'] - Type.StaticMethod - Type.InstanceMethod - GenericType<string<.Method - GenericType<string<.GenericMethod<System.Int32< - Namespace.Type.Method The Page to Render The Code Page to Render Use specified Layout Use Layout with specified name Render without any Layout Extract Model Properties into Scope Args Add additional Args available to all pages Add additional script methods available to all pages Add additional script blocks available to all pages Add additional partials available to all pages Return additional HTTP Headers in HTTP Requests Specify the Content-Type of the Response Transform the Page output using a chain of stream transformers Transform the entire output using a chain of stream transformers Available transformers that can transform context filter stream outputs Don't allow access to specified filters The last error thrown by a filter The StackTrace where the Last Error Occured What argument errors should be binded to What argument captured errors should be binded to Whether to skip execution of all page filters and just write page string fragments Overrides Context to specify whether to Ignore or Continue executing filters on error Whether to always rethrow Exceptions Immediately halt execution of the page Whether to disable buffering output and render directly to OutputStream The Return value of the page (if any) The Current StackDepth The Current StackDepth of rendering partials Can be used to track number of Evaluations Can be used to track number of Evaluations Parse Body using Specified Language. Uses host language if unspecified. Rethrow fatal exceptions thrown on incorrect API usage Where to store cached files, if unspecified falls back to configured VirtualFiles if it implements IVirtualFiles (i.e. writable) Scan Types and auto-register any Script Methods, Blocks and Code Pages Scan Assemblies and auto-register any Script Methods, Blocks and Code Pages Allow scripting of Types from specified Assemblies Allow scripting of the specified Types Lookup Namespaces for resolving Types in Scripts Allow scripting of all Types in loaded Assemblies Register short Type name accessible from scripts. (Advanced, use ScriptAssemblies/ScriptTypes first) Register long qualified Type name accessible from scripts. (Advanced, use ScriptAssemblies/ScriptTypes first) Insert additional Methods at the start so they have priority over default Script Methods Insert additional Blocks at the start so they have priority over default Script Blocks Insert plugins at the start of Plugins so they're registered first Available transformers that can transform context filter stream outputs Whether to check for modified pages by default when not in DebugMode How long in between checking for modified pages Existing caches and pages created prior to specified date should be invalidated Render render filter exceptions in-line where filter is located What argument to assign Exceptions to Whether to skip executing expressions if an Exception was thrown Limit Max Iterations for Heavy Operations like rendering a Script Block (default 10K) Limit Max number for micro ops like evaluating an AST instruction (default 1M) Limit Recursion Max StackDepth (default 25) Inverse of the #Script Language Template Syntax where each line is a statement i.e. in contrast to #Script's default where text contains embedded template expressions {{ ... }} Define and export a LISP function to the page Usage: {{#defn calc [a, b] }} (let ( (c (* a b)) ) (+ a b c) ) {{/defn}} Exception in evaluation Stack trace of Lisp evaluation Construct with a base message, cause, and a flag whether to quote strings in the cause. Return a string representation which contains the message and the stack trace. A Lisp interpreter written in C# 7 This is ported from Nuka Lisp in Dart (https://github.com/nukata/lisp-in-dart) except for bignum. It is named after ex-Nukata Town in Japan. Allow loading of remote scripts - https://example.org/lib.l - gist:{gist-id} - gist:{gist-id}/file.l - index:{name} - index:{name}/file.l Gist where to resolve `index:{name}` references from Reset Global Symbols back to default Load Lisp into Global Symbols, a new CreateInterpreter() starts with a copy of global symbols Load Lisp into Global Symbols, a new CreateInterpreter() starts with a copy of global symbols Create a Lisp interpreter initialized pre-configured with Global Symbols. Cons cell Head part of the cons cell Tail part of the cons cell Construct a cons cell with its head and tail. Make a simple string representation. Do not invoke this for any circular list. Length as a list Lisp symbol The symbol's name Construct a symbol that is not interned. Return the symbol's name Return the hashcode of the symbol's name Table of interned symbols Return an interned symbol for the name. If the name is not interned yet, such a symbol will be constructed with . Construct an interned symbol. Is it interned? The symbol of t Common base class of Lisp functions Number of arguments, made negative if the function has &rest Construct with Carity. Make a frame for local variables from a list of actual arguments. Evaluate each expression in a frame. Function type which represents any built-in function body Built-in function Name of this function C# function as the body of this function Construct with Name, Carity and Body. Return a string representation in Lisp. Invoke the built-in function with a list of actual arguments. Core of the Lisp interpreter Table of the global values of symbols Standard out Set each built-in function/variable as the global value of symbol. Cache final output from load reference Load examples: - file.l - virtual/path/file.l - index:lib-calc - index:lib-calc/lib1.l - gist:{gist-id} - gist:{gist-id}/single-file.l - https://mydomain.org/file.l Define a built-in function by a name, an arity, and a body. Evaluate a Lisp expression in an environment. Expand x of any quqsi-quotation `x into the equivalent S-expression. Quote x so that the result evaluates to x. Returns List of SExpression's Returns List of SExpression's Run Read-Eval Loop. Reader of Lisp expressions Token of "End Of File" Read a Lisp expression and return it. Return EOF if the input runs out. Make a string representation of Lisp expression. Lisp expression flag whether to quote string Run Read-Eval-Print Loop. This never ends, use Ctrl+C to Exit. Exceptions are handled here and not thrown. Lisp initialization script Lisp Common Utils Popular Clojure + nicer UX Utils #Script Language which processes ```lang ... ``` blocks The #Script Default Template Language (does not process ```lang ... ``` blocks) Create SharpPage configured to use #Script Create SharpPage configured to use #Script Templates Render #Script output to string Alias for EvaluateScript Render #Script output to string Alias for RenderScript Render #Script output to string Alias for RenderScript Render #Script output to string asynchronously Alias for RenderScriptAsync Evaluate #Script and convert returned value to T Evaluate #Script and return value Evaluate #Script and convert returned value to T asynchronously Evaluate #Script and convert returned value to T asynchronously Resolve value from stored arguments and filters Resolve value from stored arguments only Try Resolve value from stored arguments and filters Whether to evaluate as Template block or code block Allow slugs to capture URLs, Examples: techstacks.io => https://techstacks.io http:techstacks.io => http://techstacks.io techstacks.io:1000 => https://techstacks.io:1000 techstacks.io:1000:site1:site2 => https://techstacks.io:1000/site1/site2 techstacks.io:site1%7Csite2 => https://techstacks.io/site1|site2 techstacks.io:1000:site1:site2(a:1,b:"c,d",e:f) => https://techstacks.io:1000/site1/site2(a:1,b:"c,d",e:f) Convert URL to URL-friendly slugs, Examples: https://techstacks.io => techstacks.io http://techstacks.io => http:techstacks.io https://techstacks.io:1000 => techstacks.io:1000 https://techstacks.io:1000/site1/site2 => techstacks.io:1000:site1:site2 https://techstacks.io/site1|site2 => techstacks.io:site|site2 https://techstacks.io:1000/site1/site2(a:1,b:"c,d",e:f) => techstacks.io:1000:site1:site2(a:1,b:"c,d",e:f) Multiple string replacements Even number of old and new value pairs Replace string contents outside of string quotes Protect against XSS by cleaning non-standard User Input Common functionality when creating adapters Executes the specified expression. Executes the specified expression. Executes the specified expression. Executes the specified action (for void methods). Executes the specified action (for void methods). Executes the specified action (for void methods). Note: InMemoryLog keeps all logs in memory, so don't use it long running exceptions Returns a thread-safe InMemoryLog which you can use while *TESTING* to provide a detailed analysis of your logs. Delegate to return a different value from an instance (e.g. member accessor) Create the correct Invoker Delegate Type based on the type of Method Create an Invoker for public instance methods Create an Invoker for public static methods Create an Invoker for public instance void methods Create an Invoker for public static void methods Creates a Unified Resource Name (URN) with the following formats: - urn:{TypeName}:{IdFieldValue} e.g. urn:UserSession:1 - urn:{TypeName}:{IdFieldName}:{IdFieldValue} e.g. urn:UserSession:UserId:1 High-level Input options for rendering HTML Input controls Display the Control inline Label for the control Class for Label Override the class on the error message (default: invalid-feedback) Small Help Text displayed with the control Bootstrap Size of the Control: sm, lg Multiple Value Data Source for Checkboxes, Radio boxes and Select Controls Typed setter of Multi Input Values Whether to preserve value state after post back Whether to show Error Message associated with this control Customize JS/CSS/HTML bundles List of file and directory sources to include in this bundle, directory sources must end in `/`. Sources can include prefixes to specify which Virtual File System Source to use, options: 'content:' (ContentRoot HostContext.VirtualFiles), 'filesystem:' (WebRoot FileSystem), 'memory:' (WebRoot Memory) Write bundled file to this Virtual Path If needed, use alternative OutputTo Virtual Path in html tag If needed, include PathBase prefix in output tag Whether to minify sources in bundle (default true) Whether to save to disk or Memory File System (default Memory) Whether to return cached bundle if exists (default true) Whether to bundle and emit single or not bundle and emit multiple html tags Whether to call AMD define for CommonJS modules Whether to wrap JS scripts in an Immediately-Invoked Function Expression Whether to "async" load script (default false) Whether to "defer" loading script (default false) Whether script should be loaded as a "module" (default false) Generic collection of Nav Links Single NavLink List Item Navigation Bar Menu Items Collection of Link Buttons (e.g. used to render /auth buttons) User Attributes for conditional rendering, e.g: - auth - User is Authenticated - role:name - User Role - perm:name - User Permission Path Info that should set as active Prefix to include before NavItem.Path (if any) Custom classes applied to different navigation elements (defaults to Bootstrap classes) Public API for ViewUtils Shared Utils shared between different Template Filters and Razor Views/Helpers Display a list of NavItem's Display a `nav-link` nav-item Display a `nav-link` nav-item Emit HTML hidden input field for each specified Key/Value pair entry Comma delimited field names Show validation summary error message unless there's an error in exceptFor list of fields as validation errors will be displayed along side the field instead Display a "Success Alert Box" Return an error message unless there's an error in fieldNames Return an error message unless there are field errors Return an error for the specified field (if any)