Пример #1
0
 //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());
     }
 }
Пример #2
0
        /// <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"));
        }
Пример #3
0
 public StepAttribute(StageEnum stage, MessageEnum message, string primaryEntityName)
 {
     this.Stage             = (int)stage;
     this.Message           = message.ToString();
     this.PrimaryEntityName = primaryEntityName;
 }
Пример #4
0
 public void Write(XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("methodCall", XmlNamespaces.BinaryFormatDefinitions);
     xmlWriter.WriteAttributeString("methodName", XmlNamespaces.BinaryFormatDefinitions, methodName);
     xmlWriter.WriteAttributeString("typeName", XmlNamespaces.BinaryFormatDefinitions, typeName);
     xmlWriter.WriteAttributeString("callType", XmlNamespaces.BinaryFormatDefinitions, messageEnum.ToString());
     xmlWriter.WriteAttributeString("scallContext", XmlNamespaces.BinaryFormatDefinitions, scallContext);
     xmlWriter.WriteStartElement("args", XmlNamespaces.BinaryFormatDefinitions);
     for (int i = 0; i < args.Length; i++)
     {
         xmlWriter.WriteStartElement("arg", XmlNamespaces.BinaryFormatDefinitions);
         xmlWriter.WriteString(EncodeNull(args[0]));
         xmlWriter.WriteEndElement();
     }
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndElement();
 }