- Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathEventFactory.cs
72 lines (67 loc) · 2.39 KB
/
EventFactory.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
usingSystem;
usingSystem.Text.RegularExpressions;
usingSystem.Threading.Tasks;
usingNamespacePrefixPlaceholder.PowerShell.Runtime;
namespaceNamespacePrefixPlaceholder.PowerShell
{
publicstaticclassEventFactory
{
/// <summary>
/// Create a tracing event containing a string message
/// </summary>
/// <param name="message">The string message to include in event data</param>
/// <returns>Valid EventData containing the message</returns>
publicstaticEventDataCreateLogEvent(Task<string>message)
{
returnnewEventData
{
Id=Guid.NewGuid().ToString(),
Message=message.Result
};
}
/// <summary>
/// Create a new debug message event
/// </summary>
/// <param name="message">The message</param>
/// <returns>An event containing the debug message</returns>
publicstaticEventDataCreateDebugEvent(stringmessage)
{
returnnewEventData
{
Id=Events.Debug,
Message=message
};
}
/// <summary>
/// Create a new debug message event
/// </summary>
/// <param name="message">The message</param>
/// <returns>An event containing the debug message</returns>
publicstaticEventDataCreateWarningEvent(stringmessage)
{
returnnewEventData
{
Id=Events.Warning,
Message=message
};
}
publicstaticstringSplitPascalCase(stringword)
{
varregex=newRegex("([a-z]+)([A-Z])");
varoutput=regex.Replace(word,"$1 $2");
regex=newRegex("([A-Z])([A-Z][a-z])");
returnregex.Replace(output,"$1 $2");
}
publicstaticEventArgsCreateLogEvent(stringmessage)
{
returnnewEventData
{
Id=Guid.NewGuid().ToString(),
Message=message
};
}
}
}