示例#1
0
        public void LogErrorCheckResult()
        {
            MultiMapSet <string, string> dict = Check();

            if (dict.Count == 0)
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("not reset field:\n");
            foreach (KeyValuePair <string, HashSet <string> > pair in dict.GetDictionary())
            {
                sb.Append(pair.Key + ": ");
                foreach (string value in pair.Value)
                {
                    sb.Append(value + ", ");
                }
                sb.Append("\n");
            }
            Log.Error(sb.ToString());
        }
示例#2
0
        public override string ToString()
        {
            StringBuilder          sb        = new StringBuilder();
            Dictionary <Type, int> typeCount = new Dictionary <Type, int>();

            foreach (var kv in this.dictionary)
            {
                typeCount[kv.Key] = kv.Value.Count;
            }

            IOrderedEnumerable <KeyValuePair <Type, int> > orderByDescending = typeCount.OrderByDescending(s => s.Value);

            sb.AppendLine("ObjectPool Count: ");
            foreach (var kv in orderByDescending)
            {
                if (kv.Value == 1)
                {
                    continue;
                }
                sb.AppendLine($"\t{kv.Key.Name}: {kv.Value}");
            }

            MultiMapSet <string, string> dict = Check();

            sb.Append("not reset field:\n");
            foreach (KeyValuePair <string, HashSet <string> > pair in dict.GetDictionary())
            {
                sb.Append(pair.Key + ": ");
                foreach (string value in pair.Value)
                {
                    sb.Append(value + ", ");
                }
                sb.Append("\n");
            }

            return(sb.ToString());
        }
示例#3
0
        public MultiMapSet <string, string> Check()
        {
            MultiMapSet <string, string> dict = new MultiMapSet <string, string>();

            foreach (ComponentQueue queue in this.dictionary.Values)
            {
                foreach (Entity entity in queue.Queue)
                {
                    Type type = entity.GetType();

                    FieldInfo[] fieldInfos = type.GetFields();
                    foreach (FieldInfo fieldInfo in fieldInfos)
                    {
                        if (fieldInfo.IsLiteral)
                        {
                            continue;
                        }

                        if (fieldInfo.GetCustomAttributes(typeof(NoMemoryCheck)).Count() > 0)
                        {
                            continue;
                        }

                        Type fieldType = fieldInfo.FieldType;
                        if (fieldType == typeof(int))
                        {
                            if ((int)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(uint))
                        {
                            if ((uint)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(long))
                        {
                            if ((long)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(ulong))
                        {
                            if ((ulong)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(short))
                        {
                            if ((short)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(ushort))
                        {
                            if ((ushort)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(float))
                        {
                            if (Math.Abs((float)fieldInfo.GetValue(entity)) > 0.0001)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(double))
                        {
                            if (Math.Abs((double)fieldInfo.GetValue(entity)) > 0.0001)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(bool))
                        {
                            if ((bool)fieldInfo.GetValue(entity) != false)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (typeof(ICollection).IsAssignableFrom(fieldType))
                        {
                            object fieldValue = fieldInfo.GetValue(entity);
                            if (fieldValue == null)
                            {
                                continue;
                            }
                            if (((ICollection)fieldValue).Count != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        PropertyInfo propertyInfo = fieldType.GetProperty("Count");
                        if (propertyInfo != null)
                        {
                            if ((int)propertyInfo.GetValue(fieldInfo.GetValue(entity)) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType.IsClass)
                        {
                            if (fieldInfo.GetValue(entity) != null)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }
                    }
                }
            }

            return(dict);
        }