public SchemaMethod GetMethod(string name) { SchemaMethod returnValue = null; foreach (SchemaMethod method in Methods) { if (method.Name.Equals(name)) { returnValue = method; break; } } return(returnValue); }
protected long SendMethodRequest(QMFObject obj, Broker aBroker, string name, List <object> args, bool synchronous, int timeToLive) { SchemaMethod method = obj.Schema.GetMethod(name); if (args == null) { args = new List <object>(); } long seq = 0; if (method != null) { KeyValuePair <SchemaMethod, bool> pair = new KeyValuePair <SchemaMethod, bool>(method, synchronous); seq = SequenceManager.Reserve(pair); IEncoder enc = aBroker.CreateEncoder('M', seq); obj.ObjectID.encode(enc); obj.Schema.Key.encode(enc); enc.WriteStr8(name); if (args.Count < method.InputArgCount) { throw new Exception(String.Format("Incorrect number of arguments: expected {0}, got{1}", method.InputArgCount, args.Count)); } int argIndex = 0; foreach (SchemaArgument arg in method.Arguments) { if (arg.IsInput()) { ; this.EncodeValue(enc, arg.Type, args[argIndex]); argIndex += 1; } } Message msg = aBroker.CreateMessage(enc, obj.RoutingKey(), timeToLive); if (synchronous) { aBroker.SetSyncInFlight(true); } aBroker.Send(msg); } return(seq); }