public void MessageCreator() { MessageQueueTemplate mqt = applicationContext["txqueue"] as MessageQueueTemplate; Assert.IsNotNull(mqt); string path = @".\Private$\mlptestqueue"; if (MessageQueue.Exists(path)) { MessageQueue.Delete(path); } MessageQueue.Create(path, true); mqt.MessageQueueFactory.RegisterMessageQueue("newQueueDefinition", delegate { MessageQueue mq = new MessageQueue(); mq.Path = path; // other properties return mq; }); Assert.IsTrue(mqt.MessageQueueFactory.ContainsMessageQueue("newQueueDefinition")); SendAndReceive("newQueueDefinition",mqt); SimpleCreator sc = new SimpleCreator(); mqt.MessageQueueFactory.RegisterMessageQueue("fooQueueDefinition", sc.CreateQueue ); }
public void MessageCreator() { MessageQueueTemplate mqt = applicationContext["txqueue"] as MessageQueueTemplate; Assert.IsNotNull(mqt); string path = @".\Private$\mlptestqueue"; if (MessageQueue.Exists(path)) { MessageQueue.Delete(path); } MessageQueue.Create(path, true); mqt.MessageQueueFactory.RegisterMessageQueue("newQueueDefinition", delegate { MessageQueue mq = new MessageQueue(); mq.Path = path; // other properties return(mq); }); Assert.IsTrue(mqt.MessageQueueFactory.ContainsMessageQueue("newQueueDefinition")); SendAndReceive("newQueueDefinition", mqt); SimpleCreator sc = new SimpleCreator(); mqt.MessageQueueFactory.RegisterMessageQueue("fooQueueDefinition", sc.CreateQueue); }
// Checks user input and perform common actions void UpdateInput() { // Check the user inputs // Fire1 == Run the SimpleCreator on the current Player GameObject if (Input.GetButtonDown("Fire1")) { SimpleCreator sc = Player.GetComponent <SimpleCreator>(); if (sc != null) { sc.Create(0); } } }
/// <summary> /// 简单工厂模式 /// 不符合开闭原则,不好扩展,但是在很多情况下很好用。 /// </summary> public void SimpleFactory() { SimpleCreator.CreateProduct <ConcreteProduct>(); SimpleCreator.CreateProduct <ConcreteProduct2>(); }