Class Utilities (1.59.0)

public static class Utilities

A utility class which contains helper methods and extension methods.

Inheritance

Object > Utilities

Namespace

Google.Apis.Util

Assembly

Google.Apis.Core.dll

Methods

CheckArgument<T1, T2>(Boolean, String, String, T1, T2)

public static void CheckArgument<T1, T2>(bool condition, string paramName, string format, T1 arg0, T2 arg1)

Checks that given argument-based condition is met, throwing an ArgumentException otherwise.

Parameters
NameDescription
conditionBoolean

The (already evaluated) condition to check.

paramNameString

The name of the parameter whose value is being tested.

formatString

The format string to use to create the exception message if the condition is not met.

arg0T1

The first argument to the format string.

arg1T2

The second argument to the format string.

Type Parameters
NameDescription
T1
T2

CheckEnumValue<T>(T, String)

public static T CheckEnumValue<T>(T value, string paramName)
    where T : struct

Checks that the given value is in fact defined in the enum used as the type argument of the method.

Parameters
NameDescription
valueT

The value to check.

paramNameString

The name of the parameter whose value is being tested.

Returns
TypeDescription
T

value if it was a defined value

Type Parameter
NameDescription
T

The enum type to check the value within.

ConvertToString(Object)

public static string ConvertToString(object o)

Tries to convert the specified object to a string. Uses custom type converters if available. Returns null for a null object.

Parameter
NameDescription
oObject
Returns
TypeDescription
String

GetCustomAttribute<T>(MemberInfo)

public static T GetCustomAttribute<T>(this MemberInfo info)
    where T : Attribute

A Google.Apis utility method for returning the first matching custom attribute (or null) of the specified member.

Parameter
NameDescription
infoMemberInfo
Returns
TypeDescription
T
Type Parameter
NameDescription
T

GetDateTimeFromString(String)

public static DateTime? GetDateTimeFromString(string raw)

Parses the input string and returns DateTime if the input is a valid representation of a date. Otherwise it returns null.

Parameter
NameDescription
rawString
Returns
TypeDescription
Nullable<DateTime>

GetEnumStringValue(Enum)

public static string GetEnumStringValue(Enum value)

Returns the defined string value of an Enum. Use for test purposes or in other Google.Apis projects.

Parameter
NameDescription
valueEnum
Returns
TypeDescription
String

GetLibraryVersion()

public static string GetLibraryVersion()

Returns the version of the core library.

Returns
TypeDescription
String

GetStringFromDateTime(Nullable<DateTime>)

public static string GetStringFromDateTime(DateTime? date)

Returns a string (by RFC3339) form the input DateTime instance.

Parameter
NameDescription
dateNullable<DateTime>
Returns
TypeDescription
String

ThrowIfNull<T>(T, String)

public static T ThrowIfNull<T>(this T obj, string paramName)

A Google.Apis utility method for throwing an ArgumentNullException if the object is null.

Parameters
NameDescription
objT
paramNameString
Returns
TypeDescription
T
Type Parameter
NameDescription
T

ThrowIfNullOrEmpty(String, String)

public static string ThrowIfNullOrEmpty(this string str, string paramName)

A Google.Apis utility method for throwing an ArgumentNullException if the string is null or empty.

Parameters
NameDescription
strString
paramNameString
Returns
TypeDescription
String

The original string.