示例#1
0
        public ServerComponent(Component component)
        {
            this.component  = component;
            this.instanceID = this.component.GetInstanceID();

            Type type = this.component.GetType();

            ComponentExposer[] exposers = ComponentExposersManager.GetComponentExposers(type);
            PropertyInfo[]     pis      = RemoteUtility.GetExposedProperties(type, exposers);
            FieldInfo[]        fis      = RemoteUtility.GetExposedFields(type, exposers);
            int i = 0;

            ServerComponent.tempFields.Clear();

            for (; i < pis.Length; ++i)
            {
                if (ServerComponent.ExcludedProperties.Contains(pis[i].Name) == false)
                {
                    ServerComponent.tempFields.Add(new PropertyModifier(pis[i]));
                }
            }

            for (int j = 0; j < fis.Length; ++i, ++j)
            {
                ServerComponent.tempFields.Add(new FieldModifier(fis[j]));
            }

            this.fields = ServerComponent.tempFields.ToArray();

            List <MethodInfo> methods = new List <MethodInfo>(type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public));

            for (int j = 0; j < methods.Count; j++)
            {
                if (methods[j].IsGenericMethod == true)
                {
                    methods.RemoveAt(j--);
                }
            }

            this.methods = new ServerMethodInfo[methods.Count];

            for (i = 0; i < methods.Count; i++)
            {
                this.methods[i] = new ServerMethodInfo(methods[i]);
            }
        }
示例#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]));
                        }
                    }
                }
            }
        }