public void Post() { objectGraph.DoOnAttribute <GamePartAttribute>((attribute, type) => { if (type.Implements <PartTarget>()) { var serviceType = attribute.ForType ?? type; var target = objectGraph.Get(serviceType); if (type.Implements <DrawTarget>()) { drawParts.Add((DrawTarget)target); } if (type.Implements <UpdateTarget>()) { updateParts.Add((UpdateTarget)target); } if (type.Implements <ContentTarget>()) { contentParts.Add((ContentTarget)target); } if (type.Implements <PostUpdateTarget>()) { postUpdateTargets.Add((PostUpdateTarget)target); } if (type.Implements <PreUpdateTarget>()) { preUpdateTargets.Add((PreUpdateTarget)target); } if (type.Implements <ReadyTarget>()) { readyTargets.Add((ReadyTarget)target); } } }); }
public void Post() { graph.DoOnAttribute <ResourceProcessorAttribute>((attribute, type) => { var processor = (IResourceProcessor)graph.Construct(type); Console.WriteLine(processor.GetType().Name); for (var i = 0; i < attribute.FileTypes.Length; i++) { var extension = attribute.FileTypes[i]; processors.Add(extension, processor); } }); }
public void Post() { objectGraph.DoOnAttribute <SubscribeAttribute>((attribute, type) => { if (type.Implements <CollisionSubscriber>() && attribute.MessageName.Equals("collision", StringComparison.CurrentCultureIgnoreCase)) { var subscriber = (CollisionSubscriber)objectGraph.Construct(type); if (!channels.ContainsKey(subscriber.GetChannel())) { channels.Add(subscriber.GetChannel(), new CollisionMessageChannel(subscriber.GetChannel())); } channels[subscriber.GetChannel()].Subscribe(subscriber, subscriber.Collide); } }); }