Ejemplo n.º 1
0
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            PayLoad PL = new PayLoad(PayLoadNameTextBox.Text);

            PL.ClosePackage();
            mGingerSocketClient.SendPayLoad(PL);
        }
Ejemplo n.º 2
0
        public static PayLoad Error(String ErrorMessage)
        {
            PayLoad PL = new PayLoad("ERROR");

            PL.AddValue(ErrorMessage);
            PL.ClosePackage();
            return(PL);
        }
Ejemplo n.º 3
0
        public PayLoad GetObjectAsPayLoad(string PLName, Attribute attr)
        {
            PayLoad PL = new PayLoad(PLName);

            PL.AddValue(mObj.GetType().FullName);
            List <PropertyInfo> list = GetProperties(attr);

            foreach (PropertyInfo PI in list)
            {
                dynamic v = PI.GetValue(mObj);

                // Enum might be unknown = not set - so no need to write to xml, like null for object
                if (PI.PropertyType.IsEnum)
                {
                    string vs = v.ToString();
                    // No need to write enum unknown = null
                    if (vs != "Unknown")
                    {
                        PL.AddEnumValue(v);
                    }
                }
                else if (v is IObservableList)
                {
                    List <PayLoad> lst = new List <PayLoad>();
                    foreach (object o in v)
                    {
                        ObjectReflectionHelper ORHItem = new ObjectReflectionHelper();
                        ORHItem.obj = o;
                        PayLoad PL1 = ORHItem.GetObjectAsPayLoad("Item", attr);
                        lst.Add(PL1);
                    }
                    PL.AddListPayLoad(lst);
                }
                else if (PI.PropertyType.Name == "String")
                {
                    PL.AddValue((string)v);
                }
                else
                {
                    throw new Exception("Unknown type to handle - " + v);
                }
            }

            PL.ClosePackage();
            return(PL);
        }