示例#1
0
 public static void Initialize(RailRegistry registry)
 {
     if (RailResource.Master != null)
     {
         throw new ApplicationException("RailResource already initialized");
     }
     RailResource.Master = new MasterInstance(registry);
 }
示例#2
0
            private void RegisterEvents(RailRegistry registry)
            {
                foreach (Type eventType in registry.EventTypes)
                {
                    IRailPool <RailEvent> statePool =
                        RailResource.CreatePool <RailEvent>(eventType);

                    int typeKey = this.eventPools.Count + 1; // 0 is an invalid type
                    this.eventPools.Add(typeKey, statePool);
                    this.EventTypeToKey.Add(eventType, typeKey);
                }

                this.EventTypeCompressor =
                    new RailIntCompressor(0, this.eventPools.Count + 1);
            }
示例#3
0
            internal MasterInstance(RailRegistry registry)
            {
                this.EntityFactories      = new Dictionary <int, IRailPool <RailEntity> >();
                this.EntityTypeToKey      = new Dictionary <Type, int>();
                this.EventTypeToKey       = new Dictionary <Type, int>();
                this.EventTypeCompressor  = null;
                this.EntityTypeCompressor = null;

                this.commandPool = null;
                this.statePools  = new Dictionary <int, IRailPool <RailState> >();
                this.eventPools  = new Dictionary <int, IRailPool <RailEvent> >();

                this.RegisterCommand(registry);
                this.RegisterEvents(registry);
                this.RegisterEntities(registry);
            }
示例#4
0
            private void RegisterEntities(RailRegistry registry)
            {
                foreach (KeyValuePair <Type, Type> pair in registry.EntityTypes)
                {
                    Type entityType = pair.Key;
                    Type stateType  = pair.Value;

                    IRailPool <RailState> statePool =
                        RailResource.CreatePool <RailState>(stateType);
                    IRailPool <RailEntity> entityPool =
                        RailResource.CreatePool <RailEntity>(entityType);

                    int typeKey = this.statePools.Count + 1; // 0 is an invalid type
                    this.statePools.Add(typeKey, statePool);
                    this.EntityFactories.Add(typeKey, entityPool);
                    this.EntityTypeToKey.Add(entityType, typeKey);
                }

                this.EntityTypeCompressor =
                    new RailIntCompressor(0, this.EntityFactories.Count + 1);
            }
示例#5
0
 private void RegisterCommand(RailRegistry registry)
 {
     this.commandPool =
         RailResource.CreatePool <RailCommand>(registry.CommandType);
 }