Ejemplo n.º 1
0
            public static void UpdateDLL(System.Reflection.Assembly assembly = null)
            {
                if (assembly != null)
                {
                    s_Assemblies[assembly.ManifestModule.ScopeName] = assembly;
                }

                //foreach (System.Reflection.Assembly value in s_Assemblies.Values)
                //{
                //    Log.Info(" Load: " + value.ManifestModule.ScopeName, LogCategory.Start);
                //}

                s_Types.Clear();

                foreach (System.Reflection.Assembly value in s_Assemblies.Values)
                {
                    foreach (Type type in value.GetTypes())
                    {
                        if (type.IsAbstract)
                        {
                            continue;
                        }

                        object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), true);
                        if (objects.Length == 0)
                        {
                            continue;
                        }

                        BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                        s_Types.Add(baseAttribute.AttributeType, type);
                    }
                }
            }
Ejemplo n.º 2
0
        public CFMultiMapSet <string, string> Check()
        {
            CFMultiMapSet <string, string> dict = new CFMultiMapSet <string, string>();

            foreach (ObjectQueue 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);
        }