Class CoreUtils
Provides core utility functions used by the majority of projects
Inheritance
System.Object
CoreUtils
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Azos
Assembly: Azos.dll
Syntax
public static class CoreUtils
Methods
DisplayNameWithExpandedGenericArgs(Type)
Returns the name of the type with expanded generic argument names.
This helper is useful for printing class names to logs/messages.
List'1[System.Object] -> List<Object>
Declaration
public static string DisplayNameWithExpandedGenericArgs(this Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
System.String |
|
EntryExeName(Boolean)
Returns the name of entry point executable file optionally with its path
Declaration
public static string EntryExeName(bool withPath = true)
Parameters
Type |
Name |
Description |
System.Boolean |
withPath |
|
Returns
Type |
Description |
System.String |
|
FullNameWithExpandedGenericArgs(Type, Boolean)
Returns the full name of the type optionally prefixed with verbatim id specifier '@'.
The generic arguments ar expanded into their full names i.e.
List'1[System.Object] -> System.Collections.Generic.List<System.Object>
Declaration
public static string FullNameWithExpandedGenericArgs(this Type type, bool verbatimPrefix = true)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Boolean |
verbatimPrefix |
|
Returns
Type |
Description |
System.String |
|
FullNestedTypeName(Type, Boolean)
Returns full name of the nested type, for example: System.Namespace.Type+Sub -> Type.Sub
Declaration
public static string FullNestedTypeName(this Type type, bool verbatimPrefix = true)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Boolean |
verbatimPrefix |
|
Returns
Type |
Description |
System.String |
|
InjectInto<T>(IApplication, T)
Shortcut to App.DependencyInjector.InjectInto(...)
Declaration
public static T InjectInto<T>(this IApplication app, T target)
where T : class
Parameters
Returns
Type Parameters
IsComponentDesignerHosted(Component)
Determines if component is being used within designer
Declaration
public static bool IsComponentDesignerHosted(Component cmp)
Parameters
Type |
Name |
Description |
System.ComponentModel.Component |
cmp |
|
Returns
Type |
Description |
System.Boolean |
|
IsTrue(Nullable<Boolean>, Boolean)
Tests bool? for being assigned with true
Declaration
public static bool IsTrue(this bool? value, bool dflt = false)
Parameters
Type |
Name |
Description |
System.Nullable<System.Boolean> |
value |
|
System.Boolean |
dflt |
|
Returns
Type |
Description |
System.Boolean |
|
IsValidXMLName(String)
Returns true when supplied name can be used for XML node naming (node names, attribute names)
Declaration
public static bool IsValidXMLName(this string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Boolean |
|
NonBlank(String, String)
Checks the string value for null or whitespace and throws exception if it is.
The method is useful for .ctor call chaining and expression bodies methods to preclude otherwise anonymous NullReferenceException
Declaration
public static string NonBlank(this string str, string name = null)
Parameters
Type |
Name |
Description |
System.String |
str |
|
System.String |
name |
|
Returns
Type |
Description |
System.String |
|
NonBlankMax(String, Int32, String)
Checks the string value for being non-blank less than max length and throws exception if it is.
The method is useful for .ctor call chaining and expression bodies methods to preclude otherwise anonymous NullReferenceException
Declaration
public static string NonBlankMax(this string str, int maxLen, string name = null)
Parameters
Type |
Name |
Description |
System.String |
str |
|
System.Int32 |
maxLen |
|
System.String |
name |
|
Returns
Type |
Description |
System.String |
|
NonBlankMin(String, Int32, String)
Checks the string value for being non-blank at least the min length and throws exception if it is.
The method is useful for .ctor call chaining and expression bodies methods to preclude otherwise anonymous NullReferenceException
Declaration
public static string NonBlankMin(this string str, int minLen, string name = null)
Parameters
Type |
Name |
Description |
System.String |
str |
|
System.Int32 |
minLen |
|
System.String |
name |
|
Returns
Type |
Description |
System.String |
|
NonBlankMinMax(String, Int32, Int32, String)
Checks the string value for being non-blank at least the min length and throws exception if it is.
The method is useful for .ctor call chaining and expression bodies methods to preclude otherwise anonymous NullReferenceException
Declaration
public static string NonBlankMinMax(this string str, int minLen, int maxLen, string name = null)
Parameters
Type |
Name |
Description |
System.String |
str |
|
System.Int32 |
minLen |
|
System.Int32 |
maxLen |
|
System.String |
name |
|
Returns
Type |
Description |
System.String |
|
NonNull<T>(T, String)
Checks the value for null and throws exception if it is.
The method is useful for .ctor call chaining and expression bodies methods to preclude otherwise anonymous NullReferenceException
Declaration
public static T NonNull<T>(this T obj, string name = null)
where T : class
Parameters
Type |
Name |
Description |
T |
obj |
|
System.String |
name |
|
Returns
Type Parameters
ToDebugView(Expression, Int32)
Converts expression tree to simple textual form for debugging
Declaration
public static string ToDebugView(this Expression expr, int indent = 0)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression |
expr |
|
System.Int32 |
indent |
|
Returns
Type |
Description |
System.String |
|
ToJSONDataMap(Exception, Boolean, Boolean)
If there is error, converts its details to JSONDataMap
Declaration
public static JSONDataMap ToJSONDataMap(this Exception error, bool recurse = true, bool stackTrace = false)
Parameters
Type |
Name |
Description |
System.Exception |
error |
|
System.Boolean |
recurse |
|
System.Boolean |
stackTrace |
|
Returns
ToMessageWithType(Exception)
Writes exception message with exception type
Declaration
public static string ToMessageWithType(this Exception error)
Parameters
Type |
Name |
Description |
System.Exception |
error |
|
Returns
Type |
Description |
System.String |
|