forked from serilog/serilog-settings-configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDummyPolicy.cs
52 lines (34 loc) · 1.3 KB
/
DummyPolicy.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
using Serilog.Core;
using Serilog.Events;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
namespace TestDummies;
public class DummyPolicy : IDestructuringPolicy
{
public static DummyPolicy? Current { get; set; }
public Type[]? Array { get; set; }
public List<Type>? List { get; set; }
public CustomCollection<Type>? Custom { get; set; }
public CustomCollection<string>? CustomStrings { get; set; }
public Type? Type { get; set; }
public float Float { get; set; }
public double Double { get; set; }
public decimal Decimal { get; set; }
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result)
{
result = null;
return false;
}
}
public class CustomCollection<T> : IEnumerable<T>
{
private readonly List<T> inner = [];
public void Add(T item) => inner.Add(item);
// wrong signature for collection initializer
public int Add() => 0;
// wrong signature for collection initializer
public void Add(string a, byte b) { }
public T? First => inner.Count > 0 ? inner[0] : default;
public IEnumerator<T> GetEnumerator() => inner.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => inner.GetEnumerator();
}