public Registered(FactoryFunction fieldFactory, Type propertiesType, TypeNameRegistry typeNameRegistry) { typeName = typeNameRegistry.GetName(propertiesType); this.fieldFactory = fieldFactory; this.propertiesType = propertiesType; }
/// <summary> /// Create entity using custom local method and register it for later disposal /// </summary> /// <typeparam name="TEntity">Required type of entity</typeparam> /// <param name="creator">Delegate used to create entity instance</param> /// <returns>Created entity</returns> internal TEntity Create <TEntity>(FactoryFunction <TEntity> creator) where TEntity : BaseAsset { var entity = creator.Invoke(); RegisterForDisposal(entity); return(entity); }
private void Add <TFieldProperties>(FactoryFunction fieldFactory) { Guard.NotNull(fieldFactory, nameof(fieldFactory)); typeNameRegistry.Map(typeof(TFieldProperties)); var registered = new Registered(fieldFactory, typeof(TFieldProperties)); fieldsByPropertyType[registered.PropertiesType] = registered; }
/* AttachInternal may be useful if you create your own subclass of Storage. * You can have your own Attach() function that calls AttachInternal with your * own factory function to create an instance of your class. */ protected static Storage AttachInternal(Game game, bool autosave, FactoryFunction fn) { if (game == null) { throw new ArgumentNullException("You must supply a valid game!"); } if (Instance != null) { Instance.Dispose(); } Timing.Init(); Autosave = autosave; GameInstance = game; Instance = fn(); return(Instance); }
public Grid(int width, int height, FactoryFunction factory = null) { this.factory = factory ?? defaultFactory; this.grid = new T[width, height]; this.width = width; this.height = height; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { grid[x, y] = factory(x, y); } } T[] test = Columns[0]; }
public Registered(FactoryFunction fieldFactory, Type propertiesType) { this.fieldFactory = fieldFactory; this.propertiesType = propertiesType; }