Exemplo n.º 1
0
 public rdtTcpMessageComponents.Property Clone()
 {
     rdtTcpMessageComponents.Property property = new rdtTcpMessageComponents.Property();
     property.m_name = this.m_name;
     property.m_type = this.m_type;
     return(property);
 }
Exemplo n.º 2
0
        private void OnMessageGameObjectComponents(rdtTcpMessage message)
        {
            this.m_components = new rdtTcpMessageComponents?((rdtTcpMessageComponents)message);
            List <rdtTcpMessageComponents.Component> components = this.m_components.Value.m_components;

            for (int i = 0; i < components.Count; i++)
            {
                rdtTcpMessageComponents.Component component = components[i];
                if (component.m_properties == null)
                {
                    rdtDebug.Debug(this, "Component '{0}' has no properties", new object[] { component.m_name });
                }
                else
                {
                    for (int j = 0; j < component.m_properties.Count; j++)
                    {
                        rdtTcpMessageComponents.Property property = component.m_properties[j];
                        property.Deserialise(this.m_serializerRegistry);
                        component.m_properties[j] = property;
                    }
                    components[i] = component;
                }
            }
            base.Repaint();
        }
Exemplo n.º 3
0
        private List <rdtTcpMessageComponents.Property> CloneAndSerialize(Stack <rdtTcpMessageComponents.Property> hierarchy)
        {
            List <rdtTcpMessageComponents.Property> list = new List <rdtTcpMessageComponents.Property>();

            rdtTcpMessageComponents.Property property = hierarchy.Peek();
            rdtTcpMessageComponents.Property item     = property.Clone();
            item.m_value = this.m_serializerRegistry.Serialize(property.m_value);
            bool flag = true;

            foreach (rdtTcpMessageComponents.Property property3 in hierarchy)
            {
                if (flag)
                {
                    flag = false;
                }
                else
                {
                    rdtTcpMessageComponents.Property        property4 = property3.Clone();
                    List <rdtTcpMessageComponents.Property> list2     = new List <rdtTcpMessageComponents.Property>();
                    list2.Add(item);
                    property4.m_value = list2;
                    item = property4;
                }
            }
            list.Add(item);
            return(list);
        }
Exemplo n.º 4
0
        private void AddField(List <rdtTcpMessageComponents.Property> allFields, string name, object value, rdtTcpMessageComponents.Property.Type type, RangeAttribute rangeAttribute)
        {
            object obj2;

            if ((rangeAttribute != null) && (value is float))
            {
                obj2 = new rdtSerializerSlider((float)value, rangeAttribute.min, rangeAttribute.max);
            }
            else
            {
                obj2 = this.Serialize(value);
                if ((value != null) && (obj2 == null))
                {
                    return;
                }
            }
            rdtTcpMessageComponents.Property item = new rdtTcpMessageComponents.Property();
            item.m_name  = name;
            item.m_value = obj2;
            item.m_type  = type;
            allFields.Add(item);
        }
Exemplo n.º 5
0
 public void SetExpanded(bool expanded, rdtTcpMessageComponents.Component component, rdtTcpMessageComponents.Property property)
 {
     this.SetExpanded(expanded, component.m_instanceId, property.m_name);
 }
Exemplo n.º 6
0
 public bool IsExpanded(rdtTcpMessageComponents.Component component, rdtTcpMessageComponents.Property property)
 {
     return(this.IsExpanded(component.m_instanceId, property.m_name));
 }
Exemplo n.º 7
0
 public void WriteAllFields(object owner, List <rdtTcpMessageComponents.Property> allFields)
 {
     rdtDebug.Debug(this, "WriteAllFields", new object[0]);
     for (int i = 0; i < allFields.Count; i++)
     {
         rdtTcpMessageComponents.Property property = allFields[i];
         object obj2 = property.m_value;
         object obj3 = this.Deserialize(obj2);
         if (obj3 != null)
         {
             if (obj3 is rdtSerializerSlider)
             {
                 obj3 = ((rdtSerializerSlider)obj3).Value;
             }
             if (property.m_type == rdtTcpMessageComponents.Property.Type.Property)
             {
                 PropertyInfo info = owner.GetType().GetProperty(property.m_name);
                 if (info != null)
                 {
                     List <rdtTcpMessageComponents.Property> list = property.m_value as List <rdtTcpMessageComponents.Property>;
                     if (list != null)
                     {
                         object obj4 = info.GetValue(owner, null);
                         this.WriteAllFields(obj4, list);
                         info.SetValue(owner, obj4, null);
                     }
                     else
                     {
                         try
                         {
                             rdtDebug.Debug(this, "Setting property {0} to {1}", new object[] { property.m_name, obj3.ToString() });
                             info.SetValue(owner, obj3, null);
                         }
                         catch (Exception exception)
                         {
                             rdtDebug.Warning(this, "Property '{0}' could not be set: {1}!", new object[] { property.m_name, exception.Message });
                         }
                     }
                 }
             }
             else if (property.m_type == rdtTcpMessageComponents.Property.Type.Field)
             {
                 FieldInfo fieldInHierarchy = rdtTypeExtensions.GetFieldInHierarchy(owner.GetType(), property.m_name);
                 if (fieldInHierarchy != null)
                 {
                     List <rdtTcpMessageComponents.Property> list2 = property.m_value as List <rdtTcpMessageComponents.Property>;
                     if (list2 != null)
                     {
                         object obj5 = fieldInHierarchy.GetValue(owner);
                         this.WriteAllFields(obj5, list2);
                         fieldInHierarchy.SetValue(owner, obj5);
                     }
                     else
                     {
                         try
                         {
                             rdtDebug.Debug(this, "Setting field {0} to {1}", new object[] { property.m_name, obj3.ToString() });
                             fieldInHierarchy.SetValue(owner, obj3);
                         }
                         catch (ArgumentException exception2)
                         {
                             rdtDebug.Error(this, "'{0}' could not be assigned: {1}!", new object[] { property.m_name, exception2.Message });
                         }
                     }
                 }
             }
             else
             {
                 MethodInfo method = owner.GetType().GetMethod(property.m_name);
                 if (method != null)
                 {
                     try
                     {
                         if (((rdtSerializerButton)property.m_value).Pressed)
                         {
                             method.Invoke(owner, null);
                         }
                     }
                     catch (Exception exception3)
                     {
                         rdtDebug.Error(this, "'{0}' could not be invoked: {1}!", new object[] { property.m_name, exception3.Message });
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        public List <rdtTcpMessageComponents.Property> ReadAllFields(object owner)
        {
            System.Type item = owner.GetType();
            if (this.m_skipTypes.Contains(item))
            {
                return(null);
            }
            List <rdtTcpMessageComponents.Property> allFields = new List <rdtTcpMessageComponents.Property>();

            PropertyInfo[] properties = item.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            bool           flag       = owner is MonoBehaviour;
            string         name       = item.Name;

            if (!flag && !this.m_dontReadProperties.Contains(item))
            {
                for (int i = 0; i < properties.Length; i++)
                {
                    PropertyInfo memberInfo = properties[i];
                    if ((memberInfo.CanRead && memberInfo.CanWrite) && (memberInfo.GetIndexParameters().Length <= 0))
                    {
                        string memberInfoName = memberInfo.Name;
                        bool   flag2          = !this.HasIncludePerType(name);
                        if ((flag2 || this.IncludeMember(name, memberInfoName)) && (!flag2 || !this.SkipMember(name, memberInfoName)))
                        {
                            MethodInfo getMethod = memberInfo.GetGetMethod();
                            if ((getMethod != null) && getMethod.IsPublic)
                            {
                                MethodInfo setMethod = memberInfo.GetSetMethod();
                                if (((setMethod != null) && setMethod.IsPublic) && this.CanAddMember(owner, memberInfo, memberInfo.PropertyType))
                                {
                                    RangeAttribute rangeAttribute = null;
                                    object         obj2           = memberInfo.GetValue(owner, null);
                                    this.AddField(allFields, memberInfoName, obj2, rdtTcpMessageComponents.Property.Type.Property, rangeAttribute);
                                }
                            }
                        }
                    }
                }
            }
            foreach (FieldInfo info4 in rdtTypeExtensions.GetAllFields(item).ToArray())
            {
                bool           flag3      = info4.IsDefined(typeof(SerializeField), false);
                RangeAttribute attribute2 = null;
                if (info4.IsPublic || flag3)
                {
                    string str3  = info4.Name;
                    bool   flag4 = !this.HasIncludePerType(name);
                    if (((flag4 || this.IncludeMember(name, str3)) && (!flag4 || !this.SkipMember(name, str3))) && this.CanAddMember(owner, info4, info4.FieldType))
                    {
                        object obj3 = info4.GetValue(owner);
                        this.AddField(allFields, str3, obj3, rdtTcpMessageComponents.Property.Type.Field, attribute2);
                    }
                }
            }
            foreach (MethodInfo info5 in item.GetMethods(BindingFlags.Public | BindingFlags.Instance))
            {
                if (info5.IsDefined(typeof(ButtonAttribute), false))
                {
                    rdtTcpMessageComponents.Property property = new rdtTcpMessageComponents.Property();
                    property.m_name  = info5.Name;
                    property.m_value = new rdtSerializerButton(false);
                    property.m_type  = rdtTcpMessageComponents.Property.Type.Method;
                    allFields.Add(property);
                }
            }
            return(allFields);
        }