-
Notifications
You must be signed in to change notification settings - Fork 2
/
Utilities.cs
55 lines (45 loc) · 1.53 KB
/
Utilities.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Azure.ResourceManager.Samples.Common
{
public static class Utilities
{
public static Action<string> LoggerMethod { get; set; }
public static Func<string> PauseMethod { get; set; }
public static string ProjectPath { get; set; }
private static Random _random => new Random();
static Utilities()
{
LoggerMethod = Console.WriteLine;
PauseMethod = Console.ReadLine;
ProjectPath = ".";
}
public static void Log(string message)
{
LoggerMethod.Invoke(message);
}
public static void Log(object obj)
{
if (obj != null)
{
LoggerMethod.Invoke(obj.ToString());
}
else
{
LoggerMethod.Invoke("(null)");
}
}
public static void Log()
{
Utilities.Log("");
}
public static string ReadLine() => PauseMethod.Invoke();
public static string CreateRandomName(string namePrefix) => $"{namePrefix}{_random.Next(9999)}";
public static string CreatePassword() => "azure12345QWE!";
public static string CreateUsername() => "tirekicker";
}
}