@@ -7,34 +7,31 @@ namespace Toolbox.Editor.Drawers
77 /// Internal system responsible for keeping and clearing data between <see cref="UnityEditor.Editor"/>s.
88 /// This small system works only for attribute-based drawers and should be defined as a static field.
99 /// </summary>
10- /// <typeparam name="T ">Key-related object.</typeparam>
11- /// <typeparam name="T1 ">Data to store.</typeparam>
12- /// <typeparam name="T2 ">Any type needed for storage item creation. Pass <see cref="EventArgs.Empty"/> if no additional data is needed.</typeparam>
13- public abstract class DrawerDataStorage < T , T1 , T2 > : DrawerDataStorageBase
10+ /// <typeparam name="TKey ">Key-related object.</typeparam>
11+ /// <typeparam name="TData ">Data to store.</typeparam>
12+ /// <typeparam name="TArgs ">Any type needed for storage item creation. Pass <see cref="EventArgs.Empty"/> if no additional data is needed.</typeparam>
13+ public abstract class DrawerDataStorage < TKey , TData , TArgs > : DrawerDataStorageBase
1414 {
15- protected readonly Dictionary < string , T1 > items = new Dictionary < string , T1 > ( ) ;
15+ protected readonly Dictionary < string , TData > items = new Dictionary < string , TData > ( ) ;
1616
17- protected readonly Func < T , T2 , T1 > createMethod ;
18- protected readonly Action < T1 > removeMethod ;
17+ protected readonly Func < TKey , TArgs , TData > createMethod ;
18+ protected readonly Action < TData > removeMethod ;
1919
20-
21- public DrawerDataStorage ( Func < T , T2 , T1 > createMethod ) : this ( createMethod , null )
20+ public DrawerDataStorage ( Func < TKey , TArgs , TData > createMethod ) : this ( createMethod , null )
2221 { }
2322
24- public DrawerDataStorage ( Func < T , T2 , T1 > createMethod , Action < T1 > removeMethod )
23+ public DrawerDataStorage ( Func < TKey , TArgs , TData > createMethod , Action < TData > removeMethod )
2524 {
2625 this . createMethod = createMethod ;
2726 this . removeMethod = removeMethod ;
2827 }
2928
30-
31- protected abstract string GetKey ( T context ) ;
32-
29+ protected abstract string GetKey ( TKey context ) ;
3330
3431 /// <summary>
3532 /// Returns and if needed creates new item.
3633 /// </summary>
37- public virtual T1 ReturnItem ( T context , T2 args )
34+ public virtual TData ReturnItem ( TKey context , TArgs args )
3835 {
3936 var key = GetKey ( context ) ;
4037 if ( items . TryGetValue ( key , out var item ) )
@@ -47,12 +44,12 @@ public virtual T1 ReturnItem(T context, T2 args)
4744 }
4845 }
4946
50- public virtual T1 CreateItem ( T context , T2 args )
47+ public virtual TData CreateItem ( TKey context , TArgs args )
5148 {
5249 return CreateItem ( context , args , true ) ;
5350 }
5451
55- public virtual T1 CreateItem ( T context , T2 args , bool append )
52+ public virtual TData CreateItem ( TKey context , TArgs args , bool append )
5653 {
5754 var item = createMethod ( context , args ) ;
5855 if ( append )
@@ -63,13 +60,13 @@ public virtual T1 CreateItem(T context, T2 args, bool append)
6360 return item ;
6461 }
6562
66- public virtual T1 AppendItem ( T context , T1 item )
63+ public virtual TData AppendItem ( TKey context , TData item )
6764 {
6865 var key = GetKey ( context ) ;
6966 return items [ key ] = item ;
7067 }
7168
72- public virtual void ClearItem ( T context )
69+ public virtual void ClearItem ( TKey context )
7370 {
7471 var key = GetKey ( context ) ;
7572 if ( removeMethod != null )
0 commit comments