-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathInternalUtils.cs
More file actions
46 lines (41 loc) · 1.18 KB
/
InternalUtils.cs
File metadata and controls
46 lines (41 loc) · 1.18 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Plotly.NET.CSharp
{
[AttributeUsage(AttributeTargets.Class)]
internal class TypeFormatterSourceAttribute : Attribute
{
public TypeFormatterSourceAttribute(Type formatterSourceType)
{
FormatterSourceType = formatterSourceType;
}
public Type FormatterSourceType { get; }
public string[] PreferredMimeTypes { get; set; }
}
internal class MyConventionBasedFormatter
{
public string MimeType { get; set; }
public bool Format(object instance, TextWriter writer)
{
if (instance is Plotly.NET.GenericChart myObj)
{
writer.Write($"<div>Custom formattering for {myObj}</div>");
return true;
}
else
{
return false;
}
}
}
internal class MyConventionBasedFormatterSource
{
public IEnumerable<object> CreateTypeFormatters()
{
yield return new MyConventionBasedFormatter { MimeType = "text/html" };
}
}
}