mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
30 lines
967 B
C#
30 lines
967 B
C#
// -----------------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// -----------------------------------------------------------------------
|
|
using System;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
|
|
namespace System.UnitTesting
|
|
{
|
|
public static class TestServices
|
|
{
|
|
public static string GenerateRandomString()
|
|
{
|
|
return Guid.NewGuid().ToString().Replace('-', '_');
|
|
}
|
|
|
|
public static IEnumerable<TEnum> GetEnumValues<TEnum>() where TEnum : struct
|
|
{ // Silverlight 2.0 does not have Enum.GetValues()
|
|
// so we need to write our own
|
|
|
|
foreach (FieldInfo field in typeof(TEnum).GetFields())
|
|
{
|
|
if (!field.IsLiteral)
|
|
continue;
|
|
|
|
yield return (TEnum)field.GetRawConstantValue();
|
|
}
|
|
}
|
|
}
|
|
} |