Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.World.BlockCacheExtension Class Reference

Static Public Member Functions

static T PopulateCache< T > (this IBlockLookup lookup, T cache)
 
static T PopulateCache< T > (this IBlockLookup lookup)
 

Member Function Documentation

static T pluginbase.Objects.World.BlockCacheExtension.PopulateCache< T > ( this IBlockLookup  lookup,
cache 
)
static
Type Constraints
T :class 
12  : class
13  {
14 
15  var fields = typeof(T).GetFields(BINDING);
16 
17  foreach(var field in fields)
18  {
19  var attr = field.GetCustomAttributes(typeof(BlockCacheAttribute), true)
20  .Cast<BlockCacheAttribute>().FirstOrDefault();
21 
22  if (attr != null)
23  {
24  if (!string.IsNullOrEmpty(attr.Name))
25  {
26  //Inject by name
27  field.SetValue( cache, lookup.SlowGetBlock(attr.Name) );
28  }
29  else
30  {
31  //Inject by type
32  field.SetValue( cache, lookup.SlowGetBlock(attr.Type) );
33  }
34  }
35  else
36  {
37  //Inject by field type
38  field.SetValue( cache, lookup.SlowGetBlock(field.FieldType) );
39  }
40  }
41  return cache;
42  }
static T pluginbase.Objects.World.BlockCacheExtension.PopulateCache< T > ( this IBlockLookup  lookup)
static
Type Constraints
T :class 
T :new() 
45  : class, new()
46  {
47  return PopulateCache<T>(lookup, new T());
48  }
static T PopulateCache< T >(this IBlockLookup lookup, T cache)
Definition: BlockCacheExtension.cs:11

The documentation for this class was generated from the following file: