示例#1
0
        public MonitorComponent(string path, ServerComponent component) : base(path, MonitorComponent.GetClosureComponent(component.component))
        {
            this.component            = component;
            this.gameObjectInstanceID = this.component.component.gameObject.GetInstanceID();
            this.instanceID           = this.component.instanceID;

            this.children = new List <MonitorData>(this.component.fields.Length);

            for (int i = 0; i < this.component.fields.Length; i++)
            {
                CustomMonitorData customMonitor = MonitorDataManager.CreateMonitorData(this.component.fields[i].Type, this.path + NGServerScene.ValuePathSeparator + i, getInstance, this.component.fields[i]);

                if (customMonitor != null)
                {
                    this.children.Add(customMonitor);
                }
                else if (this.component.fields[i].Type.IsUnityArray() == true)
                {
                    this.children.Add(new MonitorArray(this.path + NGServerScene.ValuePathSeparator + i, this.component.fields[i], getInstance));
                }
                else if (this.component.fields[i] is FieldModifier)
                {
                    this.children.Add(new MonitorField(this.path + NGServerScene.ValuePathSeparator + i, getInstance, (this.component.fields[i] as FieldModifier).fieldInfo));
                }
                else if (this.component.fields[i] is PropertyModifier)
                {
                    this.children.Add(new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + i, getInstance, (this.component.fields[i] as PropertyModifier).propertyInfo));
                }
            }
        }
示例#2
0
        protected void  MonitorSubData(Type type, Func <object> getInstance)
        {
            object instance = getInstance();

            if (instance == null || typeof(Object).IsAssignableFrom(type) == true)
            {
                return;
            }

            if (type.IsUnityArray() == true)
            {
                this.children = new List <MonitorData>();

                IEnumerable array = instance as IEnumerable;
                IEnumerator it    = array.GetEnumerator();
                int         i     = 0;

                while (it.MoveNext())
                {
                    this.children.Add(new MonitorArrayItem(this.path + NGServerScene.ValuePathSeparator + i.ToString(), getInstance, i));
                    ++i;
                }
            }
            else if (type.IsClass() == true ||
                     type.IsStruct() == true)
            {
                ComponentExposer[] exposers   = ComponentExposersManager.GetComponentExposers(type);
                PropertyInfo[]     properties = RemoteUtility.GetExposedProperties(type, exposers);
                FieldInfo[]        fields     = RemoteUtility.GetExposedFields(type, exposers);

                this.children = new List <MonitorData>(properties.Length + fields.Length);

                for (int i = 0; i < properties.Length; ++i)
                {
                    CustomMonitorData customMonitor = MonitorDataManager.CreateMonitorData(properties[i].PropertyType, this.path + NGServerScene.ValuePathSeparator + properties[i].Name, getInstance, new PropertyModifier(properties[i]));

                    if (customMonitor != null)
                    {
                        this.children.Add(customMonitor);
                    }
                    else
                    {
                        if (properties[i].PropertyType.IsUnityArray() == true)
                        {
                            this.children.Add(new MonitorArray(this.path + NGServerScene.ValuePathSeparator + properties[i].Name, new PropertyModifier(properties[i]), getInstance));
                        }
                        else
                        {
                            this.children.Add(new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + properties[i].Name, getInstance, properties[i]));
                        }
                    }
                }

                for (int i = 0; i < fields.Length; ++i)
                {
                    CustomMonitorData customMonitor = MonitorDataManager.CreateMonitorData(fields[i].FieldType, this.path + NGServerScene.ValuePathSeparator + fields[i].Name, getInstance, new FieldModifier(fields[i]));

                    if (customMonitor != null)
                    {
                        this.children.Add(customMonitor);
                    }
                    else
                    {
                        if (fields[i].FieldType.IsUnityArray() == true)
                        {
                            this.children.Add(new MonitorArray(this.path + NGServerScene.ValuePathSeparator + fields[i].Name, new FieldModifier(fields[i]), getInstance));
                        }
                        else
                        {
                            this.children.Add(new MonitorField(this.path + NGServerScene.ValuePathSeparator + fields[i].Name, getInstance, fields[i]));
                        }
                    }
                }
            }
        }
示例#3
0
        public MonitorType(string path, Type type) : base(path, () => null)
        {
            this.type = type;

            if (this.type.IsGenericTypeDefinition == true)
            {
                this.children = new List <MonitorData>(0);
                return;
            }

            FieldInfo[]    fields     = this.type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            PropertyInfo[] properties = this.type.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            this.children = new List <MonitorData>(fields.Length + properties.Length);

            for (int i = 0; i < fields.Length; i++)
            {
                FieldModifier     modifier      = new FieldModifier(fields[i]);
                CustomMonitorData customMonitor = MonitorDataManager.CreateMonitorData(fields[i].FieldType, this.path + NGServerScene.ValuePathSeparator + fields[i].Name, getInstance, modifier);

                if (customMonitor != null)
                {
                    this.children.Add(customMonitor);
                }
                else if (fields[i].FieldType.IsUnityArray() == true)
                {
                    this.children.Add(new MonitorArray(this.path + NGServerScene.ValuePathSeparator + fields[i].Name, modifier, getInstance));
                }
                else
                {
                    this.children.Add(new MonitorField(this.path + NGServerScene.ValuePathSeparator + fields[i].Name, getInstance, fields[i]));
                }
            }

            for (int i = 0; i < properties.Length; i++)
            {
                if (properties[i].GetGetMethod() == null)
                {
                    continue;
                }

                PropertyModifier  modifier      = new PropertyModifier(properties[i]);
                CustomMonitorData customMonitor = MonitorDataManager.CreateMonitorData(properties[i].PropertyType, this.path + NGServerScene.ValuePathSeparator + properties[i].Name, getInstance, modifier);

                if (customMonitor != null)
                {
                    this.children.Add(customMonitor);
                }
                else if (properties[i].PropertyType.IsUnityArray() == true)
                {
                    this.children.Add(new MonitorArray(this.path + NGServerScene.ValuePathSeparator + properties[i].Name, modifier, getInstance));
                }
                else
                {
                    try
                    {
                        this.children.Add(new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + properties[i].Name, getInstance, properties[i]));
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("Monitoring Type \"" + type + "\" failed at property \"" + properties[i].Name + "\".", ex);
                    }
                }
            }
        }