//点对点发送消息 public void DisparcherMessage(double delay, int sender, int receiver, MessageEnum msg) { BaseGameEntity pSender = EntityManager.Instance().GetEntityFromID(sender); BaseGameEntity pReceiver = EntityManager.Instance().GetEntityFromID(receiver); if (pReceiver == null) { return; } Telegram telegram = new Telegram(); telegram.SetTelegram(0, sender, receiver, msg); //如果没有延迟的话,就调用处理函数Discharge,这个函数会调用handlemessage函数 if (delay <= 0.0f) { DisCharge(pReceiver, telegram); } //需要延迟发送的话就计算时间,计算要发送的时间,在delayDispatcher中根据时间判断并发送 else { double CurrentTime = Time.time; telegram.DispatchTime = CurrentTime + delay; PriorityQ.Add(telegram);//把信息加入到链表中 } }
public AlarmActions(WarpEnum Warp, MessageEnum Message, Boolean PlaySound, Boolean DeleteWhenDone) { this.Warp = Warp; this.Message = Message; this.PlaySound = PlaySound; this.DeleteWhenDone = DeleteWhenDone; }
public void refuse() { this.msg.state = MessageEnum.SEND; this.network.refuseChange(this.msg); Session.Messages [this.pos].reset(); this.msg = Session.Messages [this.pos]; }
//点对面发送消息 public void DisparcherMessage(double delay, int sender, MessageEnum msg) { BaseGameEntity pSender = EntityManager.Instance().GetEntityFromID(sender); Telegram telegram = new Telegram(); //为什么这里设置信息不直接用delay telegram.SetTelegram(0, sender, msg); //如果没有延迟的话,就调用处理函数Discharge,这个函数会调用handlemessage函数 if (delay <= 0.0f) { //遍历所有的basegameobject将消息发送出去,有处理这个方法的状态就会处理,没有的不做处理 //遍历可能出错,检查的时候注意下!!! foreach (KeyValuePair <int, BaseGameEntity> pvr in EntityManager.Instance().EntityMap) { DisCharge(pvr.Value, telegram); } } else { double CurrentTime = Time.time; telegram.DispatchTime = CurrentTime + delay; PriorityQ.Add(telegram);//把信息加入到链表中 } }
public void updateState() { this.state = this.msg.state; switch (state) { case MessageEnum.EDIT: this.ButtonEdit.SetActive(false); this.ButtonSend.SetActive(true); this.ButtonOk.SetActive(false); this.ButtonNo.SetActive(false); setActiveButton(true); break; case MessageEnum.SEND: this.ButtonEdit.SetActive(true); this.ButtonSend.SetActive(false); this.ButtonOk.SetActive(false); this.ButtonNo.SetActive(false); setActiveButton(false); break; case MessageEnum.RECIEVE: this.ButtonEdit.SetActive(true); this.ButtonSend.SetActive(false); this.ButtonOk.SetActive(true); this.ButtonNo.SetActive(true); setActiveButton(false); break; } }
public void Read(__BinaryParser input) { this.messageEnum = (MessageEnum) input.ReadInt32(); if (IOUtil.FlagTest(this.messageEnum, MessageEnum.NoReturnValue)) { this.returnValue = null; } else if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueVoid)) { this.returnValue = instanceOfVoid; } else if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueInline)) { this.returnValue = IOUtil.ReadWithCode(input); } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInline)) { this.scallContext = (string) IOUtil.ReadWithCode(input); LogicalCallContext context = new LogicalCallContext { RemotingData = { LogicalCallID = this.scallContext } }; this.callContext = context; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInline)) { this.args = IOUtil.ReadArgs(input); } }
public void Read(__BinaryParser input) { this.messageEnum = (MessageEnum)input.ReadInt32(); if (IOUtil.FlagTest(this.messageEnum, MessageEnum.NoReturnValue)) { this.returnValue = (object)null; } else if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueVoid)) { this.returnValue = BinaryMethodReturn.instanceOfVoid; } else if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueInline)) { this.returnValue = IOUtil.ReadWithCode(input); } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInline)) { this.scallContext = (string)IOUtil.ReadWithCode(input); this.callContext = (object)new LogicalCallContext() { RemotingData = { LogicalCallID = this.scallContext } }; } if (!IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInline)) { return; } this.args = IOUtil.ReadArgs(input); }
public void Read(BinaryReader input) { messageEnum = (MessageEnum)input.ReadInt32(); if (BinaryConverter.FlagTest(messageEnum, MessageEnum.NoReturnValue)) { returnValue = invalidReturn; } else if (BinaryConverter.FlagTest(messageEnum, MessageEnum.ReturnValueVoid)) { returnValue = invalidReturn; } else if (BinaryConverter.FlagTest(messageEnum, MessageEnum.ReturnValueInline)) { returnValue = BinaryConverter.ReadWithCode(input); } if (BinaryConverter.FlagTest(messageEnum, MessageEnum.ContextInline)) { scallContext = (String)BinaryConverter.ReadWithCode(input); } if (BinaryConverter.FlagTest(messageEnum, MessageEnum.ArgsInline)) { args = BinaryConverter.ReadArgs(input); } }
//Message.SendMessage(MyEventNum.HitEvent, gameObject, otherGameobject) public static void SendMessage(MessageEnum ev, params GameObject[] objs) { if (ev == MessageEnum.NONE) { Debug.Log("Message sender is not setup for Event! " + ev.ToString()); return; } if (messages.ContainsKey(ev)) { if (objs.Length > 0) { for (int i = objs.Length - 1; i >= 0; i--) { GameObject obj = objs[i]; if (messages[ev].ContainsKey(obj)) { messages[ev][obj].Invoke(); } } } else { List <KeyValuePair <GameObject, Action> > values = messages[ev].ToList(); for (int i = values.Count - 1; i >= 0; i--) //foreach (KeyValuePair<GameObject, Action> kv in messages[ev]) { values[i].Value.Invoke(); } } } else { Debug.Log("No listeners for event: " + ev.ToString()); } }
/// <summary> /// 显示输出 /// </summary> /// <param name="msg"></param> /// <param name="me"></param> /// <returns></returns> public static string OutPutShow(string key, object data = null, MessageEnum me = MessageEnum.Success) { if (data == null) { data = ""; } string mestr = me.ToString(); MessageState ms = new MessageState() { key = key }; System.Type t = me.GetType(); FieldInfo[] filist = t.GetFields(); foreach (var fi in filist) { if (fi.Name == mestr) { MsgStateAttribute ai = (MsgStateAttribute)System.Attribute.GetCustomAttribute(fi, typeof(MsgStateAttribute), false); ms.SetMsgState(ai.GetMsg()); break; } } ms.data = data; ms.state = me.ConvertData <int>(); return(MakeJson.ObjectToJson(new { ms.state, ms.key, ms.data }, "yyyy-MM-dd HH:mm:ss")); }
static public async Task <IMessage> ReceiveMessage(WebSocket socket) { IMessage result = null; MessageEnum type = (MessageEnum) await ReceiveInt16(socket); int messageLength = await ReceiveInt16(socket); if (messageLength > buffer.Length) { throw new SharedDataException($"message length[{messageLength} is greater than buffer.Length[{buffer.Length}]"); } await ReceiveBuffer(socket, buffer, buffer.Length); using (MemoryStream ms = new MemoryStream(buffer, 0, messageLength)) { switch (type) { case MessageEnum.Heartbeat: result = Deserialize <Heartbeat>(ms); break; case MessageEnum.LED: result = Deserialize <LEDMessage>(ms); break; case MessageEnum.Temperature: result = Deserialize <Temperature>(ms); break; } } return(result); }
public void SetTelegram(double time, int sender, int receiver, MessageEnum msg) { DispatchTime = time; Sender = sender; Receiver = receiver; Msg = msg; }
/// <summary> /// This allows messages to adapt based on the Being involved and /// what messages have already been seen, how many times, et c. /// </summary> public void Message(IBeing being, MessageEnum messageKey) { Guard.Against(messageKey == MessageEnum.Unset, "Must set message key"); if (!being.IsPlayer) { return; } switch (messageKey) { case MessageEnum.BarehandRotDamage: if (FirstTimeFor(messageKey)) { //0.2 promote to alert WriteLine("I tear a chunk off the ground. It fights back--burns my hands."); WriteLine("The stuff withers away from where I grab it."); } else { WriteLine("I hit it, and the stuff withers."); } break; case MessageEnum.RotDamageSpreads: WriteLine("The damage I did to this stuff spreads outward. Good."); break; default: var need_message_for_key = $"Must code message for key [{messageKey}]."; WriteLine(need_message_for_key); throw new Exception(need_message_for_key); } }
public override bool OnMessage(Follower follower, MessageEnum msg) { switch (msg) { default: return(false); } return(true); }
public override bool OnMessage(Player player, MessageEnum msg) { switch (msg) { case MessageEnum.StopWalking: player.GetFSM().ChangeState(player.States.IdleState); break; } return(true); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { base.GetPropertyHeight(property, label); messageEnum = property.GetValue<MessageEnum>(); return lineHeight; }
/// <summary> /// send a chat message /// </summary> public Message(string fromUserName, string toUserName, string content, MessageEnum type) : this(fromUserName, type) { this.ToUserName = ToUserName; this.Content = content; this.Type = type; this.SendTime = DateTime.Now; }
public override bool OnMessage(MyCamera camera, MessageEnum msg) { switch (msg) { case MessageEnum.StartSpeech: camera.GetFSM().ChangeState(camera.States.LeaderViewState); break; } return(true); }
public override bool OnMessage(MyCamera camera, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderCloseToPlayer: camera.GetFSM().ChangeState(camera.States.CloseSceneState); break; } return(true); }
public void SendMsg(MessageEnum msg, params object[] objs) { if (true) { tempFormatDataSend = FormatDataSend(msg, GamePlayer.Inst, objs); ReceiveMsg(tempFormatDataSend); } }
public override bool OnMessage(Leader leader, MessageEnum msg) { switch (msg) { default: return(false); } return(true); }
public override bool OnMessage(People people, MessageEnum msg) { //switch (msg) //{ // default: return false; //} return(true); }
public override bool OnMessage(Leader leader, MessageEnum msg) { //switch (msg) //{ // default: return false; //} return(true); }
private MessageDataSend FormatDataSend(MessageEnum msg, params object[] objs) { return(new MessageDataSend { Msg = msg, Objs = objs, }); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { base.GetPropertyHeight(property, label); messageEnum = property.GetValue <MessageEnum>(); return(lineHeight); }
public override bool OnMessage(MyCamera camera, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderStopInteractive: camera.GetFSM().ChangeState(camera.States.PlayerViewState); break; } return(true); }
public override bool OnMessage(Player player, MessageEnum msg) { switch (msg) { //case MessageEnum.StartWalking: player.GetFSM().ChangeState(player.States.WalkingState); break; case MessageEnum.StartSpeech: player.GetFSM().ChangeState(player.States.ListeningState); break; } return(true); }
public override bool OnMessage(Player player, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderStopShakeHands: player.GetFSM().ChangeState(player.States.WaitingState); break; case MessageEnum.LeaderReturned: MessageDispatcher.Instance().DisparcherMessage(Const.PLAYER_SHAKEHANDS_TIME, player.ID(), player.ID(), MessageEnum.LeaderReturned); break; } return(true); }
public override bool OnMessage(Player player, MessageEnum msg) { switch (msg) { case MessageEnum.StartWalking: player.GetFSM().ChangeState(player.States.WalkingState); break; default: return(false); } return(true); }
public override bool OnMessage(People people, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderStopSpeech: people.GetFSM().ChangeState(people.States.HandClapingState); break; default: return(false); } return(true); }
public override bool OnMessage(Follower follower, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderGotoInteractive: follower.GetFSM().ChangeState(follower.States.WalkingState); break; default: return(false); } return(true); }
public override bool OnMessage(Player player, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderStopSpeech: ClapHandsSwitch = true; break; default: return(false); } return(true); }
public override bool OnMessage(Follower follower, MessageEnum msg) { switch (msg) { case MessageEnum.LeaderStopSpeech: follower.GetFSM().ChangeState(follower.States.HandClapingState); break; default: return(false); } return(true); }
internal void Read(__BinaryParser input) { this.messageEnum = (MessageEnum) input.ReadInt32(); this.methodName = (string) IOUtil.ReadWithCode(input); this.typeName = (string) IOUtil.ReadWithCode(input); if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInline)) { this.scallContext = (string) IOUtil.ReadWithCode(input); LogicalCallContext context = new LogicalCallContext { RemotingData = { LogicalCallID = this.scallContext } }; this.callContext = context; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInline)) { this.args = IOUtil.ReadArgs(input); } }
public void Read(__BinaryParser input) { messageEnum = (MessageEnum)input.ReadInt32(); if (IOUtil.FlagTest(messageEnum, MessageEnum.NoReturnValue)) returnValue = null; else if (IOUtil.FlagTest(messageEnum, MessageEnum.ReturnValueVoid)) { returnValue = FormatterServices.GetUninitializedObject(Converter.typeofSystemVoid); } else if (IOUtil.FlagTest(messageEnum, MessageEnum.ReturnValueInline)) returnValue = IOUtil.ReadWithCode(input); if (IOUtil.FlagTest(messageEnum, MessageEnum.ContextInline)) { scallContext = (String)IOUtil.ReadWithCode(input); LogicalCallContext lcallContext = new LogicalCallContext(); lcallContext.RemotingData.LogicalCallID = scallContext; callContext = lcallContext; } if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline)) args = IOUtil.ReadArgs(input); }
public EntityMessage(MessageEnum message, HierarchyScopes scope = HierarchyScopes.Self) { Message = message; this.scope = (int)scope; }
internal static bool FlagTest(MessageEnum flag, MessageEnum target) { return ((flag & target) == target); }
/// <summary> /// Connect or disconnect to server /// </summary> /// <param name="fromUserName">my user name</param> /// <param name="type">chat | signin | signout</param> public Message(string fromUserName, MessageEnum type) { this.FromUserName = fromUserName; this.Type = type; }
internal object[] WriteArray(object returnValue, object[] args, Exception exception, object callContext, object[] properties) { this.returnValue = returnValue; this.args = args; this.exception = exception; this.callContext = callContext; this.properties = properties; int num = 0; if ((args == null) || (args.Length == 0)) { this.messageEnum = MessageEnum.NoArgs; } else { this.argTypes = new Type[args.Length]; this.bArgsPrimitive = true; for (int i = 0; i < args.Length; i++) { if (args[i] != null) { this.argTypes[i] = args[i].GetType(); if (!this.argTypes[i].IsPrimitive && !object.ReferenceEquals(this.argTypes[i], Converter.typeofString)) { this.bArgsPrimitive = false; break; } } } if (this.bArgsPrimitive) { this.messageEnum = MessageEnum.ArgsInline; } else { num++; this.messageEnum = MessageEnum.ArgsInArray; } } if (returnValue == null) { this.messageEnum |= MessageEnum.NoReturnValue; } else if (returnValue.GetType() == typeof(void)) { this.messageEnum |= MessageEnum.ReturnValueVoid; } else { this.returnType = returnValue.GetType(); if (this.returnType.IsPrimitive || object.ReferenceEquals(this.returnType, Converter.typeofString)) { this.messageEnum |= MessageEnum.ReturnValueInline; } else { num++; this.messageEnum |= MessageEnum.ReturnValueInArray; } } if (exception != null) { num++; this.messageEnum |= MessageEnum.ExceptionInArray; } if (callContext == null) { this.messageEnum |= MessageEnum.NoContext; } else if (callContext is string) { this.messageEnum |= MessageEnum.ContextInline; } else { num++; this.messageEnum |= MessageEnum.ContextInArray; } if (properties != null) { num++; this.messageEnum |= MessageEnum.PropertyInArray; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInArray) && (num == 1)) { this.messageEnum ^= MessageEnum.ArgsInArray; this.messageEnum |= MessageEnum.ArgsIsArray; return args; } if (num <= 0) { return null; } int index = 0; this.callA = new object[num]; if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInArray)) { this.callA[index++] = args; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueInArray)) { this.callA[index++] = returnValue; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ExceptionInArray)) { this.callA[index++] = exception; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInArray)) { this.callA[index++] = callContext; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.PropertyInArray)) { this.callA[index] = properties; } return this.callA; }
internal object[] WriteArray(string uri, string methodName, string typeName, Type[] instArgs, object[] args, object methodSignature, object callContext, object[] properties) { this.uri = uri; this.methodName = methodName; this.typeName = typeName; this.instArgs = instArgs; this.args = args; this.methodSignature = methodSignature; this.callContext = callContext; this.properties = properties; int num = 0; if ((args == null) || (args.Length == 0)) { this.messageEnum = MessageEnum.NoArgs; } else { this.argTypes = new Type[args.Length]; this.bArgsPrimitive = true; for (int i = 0; i < args.Length; i++) { if (args[i] != null) { this.argTypes[i] = args[i].GetType(); if ((!this.argTypes[i].IsPrimitive && !object.ReferenceEquals(this.argTypes[i], Converter.typeofString)) || (args[i] is ISerializable)) { this.bArgsPrimitive = false; break; } } } if (this.bArgsPrimitive) { this.messageEnum = MessageEnum.ArgsInline; } else { num++; this.messageEnum = MessageEnum.ArgsInArray; } } if (instArgs != null) { num++; this.messageEnum |= MessageEnum.GenericMethod; } if (methodSignature != null) { num++; this.messageEnum |= MessageEnum.MethodSignatureInArray; } if (callContext == null) { this.messageEnum |= MessageEnum.NoContext; } else if (callContext is string) { this.messageEnum |= MessageEnum.ContextInline; } else { num++; this.messageEnum |= MessageEnum.ContextInArray; } if (properties != null) { num++; this.messageEnum |= MessageEnum.PropertyInArray; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInArray) && (num == 1)) { this.messageEnum ^= MessageEnum.ArgsInArray; this.messageEnum |= MessageEnum.ArgsIsArray; return args; } if (num <= 0) { return null; } int index = 0; this.callA = new object[num]; if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInArray)) { this.callA[index++] = args; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.GenericMethod)) { this.callA[index++] = instArgs; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.MethodSignatureInArray)) { this.callA[index++] = methodSignature; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInArray)) { this.callA[index++] = callContext; } if (IOUtil.FlagTest(this.messageEnum, MessageEnum.PropertyInArray)) { this.callA[index] = properties; } return this.callA; }
/// <summary> /// Supply english error messages. At the moment this method is invoked only by <see cref="RenderParsingErrorsText"/>. /// </summary> /// <param name="messageType">The type of message to return.</param> /// <returns>The <see cref="System.String"/> that contains the parsing error formattable text.</returns> protected string GetMessageText(MessageEnum messageType) { switch (messageType) { case MessageEnum.ParsingErrorViolatesRequired: return "The option {0} is mandatory, you must define it."; case MessageEnum.ParsingErrorViolatesFormat: return "The format of the entered value for the option {0} is invalid."; case MessageEnum.ParsingErrorViolatesExclusiveness: return "Two or more options are mutually exclusive with each other."; default: throw new InvalidOperationException(); } }
// If the argument list contains only primitive or strings it is written out as part of the header // if not the args are written out as a separate array internal Object[] WriteArray(Object returnValue, Object[] args, Exception exception, Object callContext, Object[] properties) { SerTrace.Log(this, "WriteArray returnValue ",returnValue, "exception ", exception, " callContext ",callContext," properties ", properties); this.returnValue = returnValue; this.args = args; this.exception = exception; this.callContext = callContext; this.properties = properties; int arraySize = 0; if (args == null || args.Length == 0) messageEnum = MessageEnum.NoArgs; else { argTypes = new Type[args.Length]; // Check if args are all string or primitives bArgsPrimitive = true; for (int i =0; i<args.Length; i++) { if (args[i] != null) { argTypes[i] = args[i].GetType(); if (!(argTypes[i].IsPrimitive || Object.ReferenceEquals(argTypes[i], Converter.typeofString))) { bArgsPrimitive = false; break; } } } if (bArgsPrimitive) messageEnum = MessageEnum.ArgsInline; else { arraySize++; messageEnum = MessageEnum.ArgsInArray; } } if (returnValue == null) messageEnum |= MessageEnum.NoReturnValue; else if (returnValue.GetType() == typeof(void)) messageEnum |= MessageEnum.ReturnValueVoid; else { returnType = returnValue.GetType(); if (returnType.IsPrimitive || Object.ReferenceEquals(returnType, Converter.typeofString)) messageEnum |= MessageEnum.ReturnValueInline; else { arraySize++; messageEnum |= MessageEnum.ReturnValueInArray; } } if (exception != null) { arraySize++; messageEnum |= MessageEnum.ExceptionInArray; } if (callContext == null) messageEnum |= MessageEnum.NoContext; else if (callContext is String) messageEnum |= MessageEnum.ContextInline; else { arraySize++; messageEnum |= MessageEnum.ContextInArray; } if (properties != null) { arraySize++; messageEnum |= MessageEnum.PropertyInArray; } if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInArray) && (arraySize == 1)) { messageEnum ^= MessageEnum.ArgsInArray; messageEnum |= MessageEnum.ArgsIsArray; return args; } if (arraySize > 0) { int arrayPosition = 0; callA = new Object[arraySize]; if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInArray)) callA[arrayPosition++] = args; if (IOUtil.FlagTest(messageEnum, MessageEnum.ReturnValueInArray)) callA[arrayPosition++] = returnValue; if (IOUtil.FlagTest(messageEnum, MessageEnum.ExceptionInArray)) callA[arrayPosition++] = exception; if (IOUtil.FlagTest(messageEnum, MessageEnum.ContextInArray)) callA[arrayPosition++] = callContext; if (IOUtil.FlagTest(messageEnum, MessageEnum.PropertyInArray)) callA[arrayPosition] = properties; return callA; } else return null; }
[System.Security.SecurityCritical] // auto-generated internal void Read(__BinaryParser input) { messageEnum = (MessageEnum)input.ReadInt32(); //uri = (String)IOUtil.ReadWithCode(input); methodName = (String)IOUtil.ReadWithCode(input); typeName = (String)IOUtil.ReadWithCode(input); #if FEATURE_REMOTING if (IOUtil.FlagTest(messageEnum, MessageEnum.ContextInline)) { scallContext = (String)IOUtil.ReadWithCode(input); LogicalCallContext lcallContext = new LogicalCallContext(); lcallContext.RemotingData.LogicalCallID = scallContext; callContext = lcallContext; } #endif if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline)) args = IOUtil.ReadArgs(input); }
// If the argument list contains only primitive or strings it is written out as part of the header // if not the args are written out as a separate array internal Object[] WriteArray(String uri, String methodName, String typeName, Type[] instArgs, Object[] args, Object methodSignature, Object callContext, Object[] properties) { this.uri = uri; this.methodName = methodName; this.typeName = typeName; this.instArgs = instArgs; this.args = args; this.methodSignature = methodSignature; this.callContext = callContext; this.properties = properties; int arraySize = 0; if (args == null || args.Length == 0) messageEnum = MessageEnum.NoArgs; else { argTypes = new Type[args.Length]; // Check if args are all string or primitives bArgsPrimitive = true; for (int i =0; i<args.Length; i++) { if (args[i] != null) { argTypes[i] = args[i].GetType(); if (!(argTypes[i].IsPrimitive || Object.ReferenceEquals(argTypes[i], Converter.typeofString)) || args[i] is ISerializable) { bArgsPrimitive = false; break; } } } if (bArgsPrimitive) messageEnum = MessageEnum.ArgsInline; else { arraySize++; messageEnum = MessageEnum.ArgsInArray; } } if (instArgs != null) { arraySize++; messageEnum |= MessageEnum.GenericMethod; } if (methodSignature != null) { arraySize++; messageEnum |= MessageEnum.MethodSignatureInArray; } if (callContext == null) messageEnum |= MessageEnum.NoContext; else if (callContext is String) messageEnum |= MessageEnum.ContextInline; else { arraySize++; messageEnum |= MessageEnum.ContextInArray; } if (properties != null) { arraySize++; messageEnum |= MessageEnum.PropertyInArray; } if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInArray) && arraySize == 1) { messageEnum ^= MessageEnum.ArgsInArray; messageEnum |= MessageEnum.ArgsIsArray; return args; } if (arraySize > 0) { int arrayPosition = 0; callA = new Object[arraySize]; if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInArray)) callA[arrayPosition++] = args; if (IOUtil.FlagTest(messageEnum, MessageEnum.GenericMethod)) callA[arrayPosition++] = instArgs; if (IOUtil.FlagTest(messageEnum, MessageEnum.MethodSignatureInArray)) callA[arrayPosition++] = methodSignature; if (IOUtil.FlagTest(messageEnum, MessageEnum.ContextInArray)) callA[arrayPosition++] = callContext; if (IOUtil.FlagTest(messageEnum, MessageEnum.PropertyInArray)) callA[arrayPosition] = properties; return callA; } else return null; }
[System.Security.SecurityCritical] // auto-generated public void Read(__BinaryParser input) { messageEnum = (MessageEnum)input.ReadInt32(); if (IOUtil.FlagTest(messageEnum, MessageEnum.NoReturnValue)) returnValue = null; else if (IOUtil.FlagTest(messageEnum, MessageEnum.ReturnValueVoid)) { returnValue = instanceOfVoid; } else if (IOUtil.FlagTest(messageEnum, MessageEnum.ReturnValueInline)) returnValue = IOUtil.ReadWithCode(input); #if FEATURE_REMOTING if (IOUtil.FlagTest(messageEnum, MessageEnum.ContextInline)) { scallContext = (String)IOUtil.ReadWithCode(input); LogicalCallContext lcallContext = new LogicalCallContext(); lcallContext.RemotingData.LogicalCallID = scallContext; callContext = lcallContext; } #endif if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline)) args = IOUtil.ReadArgs(input); }
internal static bool FlagTest(MessageEnum flag, MessageEnum target) { if ((flag & target) == target) return true; else return false; }