Show / Hide Table of Contents

Class Helpers

Some helper functions used by OAT.

Inheritance
System.Object
Helpers
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: Microsoft.CST.OAT.Utils
Assembly: OAT.dll
Syntax
public static class Helpers

Methods

| Improve this Doc View Source

ConstructedOfLoadedTypes(ConstructorInfo)

Determines if the ConstructorInfo given is constructable given what is loaded into the AppDomain.

Declaration
public static bool ConstructedOfLoadedTypes(ConstructorInfo constructorInfo)
Parameters
Type Name Description
System.Reflection.ConstructorInfo constructorInfo
Returns
Type Description
System.Boolean

true if only basic types and types derived from basic types can be used to construct.

| Improve this Doc View Source

ConstructedOfLoadedTypes(Type)

Recursively checks if the object Type given can be constructed given what is loaded into the AppDomain.

Declaration
public static bool ConstructedOfLoadedTypes(Type type)
Parameters
Type Name Description
System.Type type

The Type to Check

Returns
Type Description
System.Boolean
| Improve this Doc View Source

CreateDictionary(Type, Type)

Create a Dictionary to hold the given types

Declaration
public static IDictionary CreateDictionary(Type keyType, Type valueType)
Parameters
Type Name Description
System.Type keyType

The Type of the Key

System.Type valueType

The Type of the Value

Returns
Type Description
System.Collections.IDictionary

A Dictionary of the given types or null.

| Improve this Doc View Source

CreateList(Type)

Create a list to hold the given type

Declaration
public static IList CreateList(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Collections.IList

A List of the given type or null.

| Improve this Doc View Source

GetAllNestedFieldsAndProperties(Type, String)

Gets the Paths of all the Fields and Properties in the provided Type

Declaration
public static List<string> GetAllNestedFieldsAndProperties(Type type, string currentPath = null)
Parameters
Type Name Description
System.Type type
System.String currentPath
Returns
Type Description
System.Collections.Generic.List<System.String>
| Improve this Doc View Source

GetAllNestedFieldsAndPropertiesMemberInfo(Type, String)

Get MemberInfo and Paths for all the BasicType properties and fields in the Type

Declaration
public static List<(string Path, MemberInfo MemInfo)> GetAllNestedFieldsAndPropertiesMemberInfo(Type type, string currentPath = null)
Parameters
Type Name Description
System.Type type
System.String currentPath
Returns
Type Description
System.Collections.Generic.List<System.ValueTuple<System.String, System.Reflection.MemberInfo>>
| Improve this Doc View Source

GetConstructors(Type)

Get the constructors which exclusively use loaded/basic types (are constructable)

Declaration
public static List<ConstructorInfo> GetConstructors(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Collections.Generic.List<System.Reflection.ConstructorInfo>
| Improve this Doc View Source

GetDefaultValueForType(Type)

Gets a sensible default value for the type.

Declaration
public static object GetDefaultValueForType(Type type)
Parameters
Type Name Description
System.Type type

The type to get a default value for.

Returns
Type Description
System.Object

The default value for the type.

| Improve this Doc View Source

GetFriendlyName(Type)

Get the friendly name for a type

Declaration
public static string GetFriendlyName(this Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.String
| Improve this Doc View Source

GetListType(Type)

Create a list to hold the given type

Declaration
public static IList GetListType(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Collections.IList

A List of the given type or null.

| Improve this Doc View Source

GetTypesInNamespace(Assembly, String)

Returns a list of the Types in the given namespace in the given assembly.

Declaration
public static Type[] GetTypesInNamespace(Assembly assembly, string nameSpace)
Parameters
Type Name Description
System.Reflection.Assembly assembly

The Assembly to scan

System.String nameSpace

The Namespace to look for.

Returns
Type Description
System.Type[]
| Improve this Doc View Source

GetValueByPropertyOrFieldName(Object, String)

Gets the object value stored at the field or property named by the string. Property tried first. Returns null if none found.

Declaration
public static object GetValueByPropertyOrFieldName(object obj, string propertyName)
Parameters
Type Name Description
System.Object obj

The target object

System.String propertyName

The Property or Field name

Returns
Type Description
System.Object

The object at that Name or null

| Improve this Doc View Source

GetVersionString()

Returns the assembly version string.

Declaration
public static string GetVersionString()
Returns
Type Description
System.String
| Improve this Doc View Source

IsBasicType(Type)

Checks if this is a type that OAT Blazor has a component for

Declaration
public static bool IsBasicType(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IsNullable(Type)

Determines if a type is nullable

Declaration
public static bool IsNullable(Type type)
Parameters
Type Name Description
System.Type type

The type

Returns
Type Description
System.Boolean
| Improve this Doc View Source

IsValidRegex(String)

Determines if a Regex is valid or not by checking if a Regex object can be created with it.

Declaration
public static bool IsValidRegex(string pattern)
Parameters
Type Name Description
System.String pattern
Returns
Type Description
System.Boolean
| Improve this Doc View Source

PrintViolations(IEnumerable<Violation>)

Prints out the Enumerable of violations to Warning

Declaration
public static void PrintViolations(IEnumerable<Violation> violations)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<Violation> violations

An Enumerable of Violations to print

| Improve this Doc View Source

SetValueByPropertyOrFieldName(Object, String, Object)

Sets the object value stored at the field or property named by the string. Property tried first.

Declaration
public static void SetValueByPropertyOrFieldName(object obj, string propertyName, object value)
Parameters
Type Name Description
System.Object obj

The target object

System.String propertyName

The Property or Field name

System.Object value

The value to set.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX