Tanoda
CallbackCacheEntey.cs
Go to the documentation of this file.
1using System;
2
4{
5 public class CallbackCacheEntry : CacheEntryBase
6 {
7 private readonly string _message;
8 private readonly Action _callback;
9
10 public CallbackCacheEntry(string name, string message, Action callback) : base(name)
11 {
12 _message = message;
13 try
14 {
15 _callback = callback;
16 }
17 catch (Exception e)
18 {
19 // ignored
20 }
21 }
22
23 public override object GetValueToCache()
24 {
25 return _message;
26 }
27
28 public override bool CanEnterValue()
29 {
30 return true;
31 }
32
33 public override object EnterValue()
34 {
35 try
36 {
37 _callback();
38 }
39 catch (Exception e)
40 {
41 // ignored
42 }
43 return null;
44 }
45
46 protected override bool OnSetValue(object newValue)
47 {
48 return false;
49 }
50
51 public override Type Type()
52 {
53 return typeof(void);
54 }
55
56 public override bool CanSetValue()
57 {
58 return false;
59 }
60 }
61
63 {
64 private readonly string _message;
65 private readonly Func<T> _callback;
66
67 public CallbackCacheEntry(string name, string message, Func<T> callback) : base(name)
68 {
69 _message = message;
70 try
71 {
72 _callback = callback;
73 }
74 catch (Exception e)
75 {
76 // ignored
77 }
78 }
79
80 public override object GetValueToCache()
81 {
82 return _message;
83 }
84
85 public override bool CanEnterValue()
86 {
87 return true;
88 }
89
90 public override object EnterValue()
91 {
92 return _callback(); //Ehhh
93 }
94
95 protected override bool OnSetValue(object newValue)
96 {
97 return false;
98 }
99
100 public override Type Type()
101 {
102 return typeof(T);
103 }
104
105 public override bool CanSetValue()
106 {
107 return false;
108 }
109 }
110}
override Type Type()
override object EnterValue()
Get object that is entered when variable name is clicked in inspector
CallbackCacheEntry(string name, string message, Action callback)
override object GetValueToCache()
override bool CanSetValue()
override bool OnSetValue(object newValue)
override bool CanEnterValue()
CallbackCacheEntry(string name, string message, Func< T > callback)