예제 #1
0
        public static void AddModelLoader(Type type, int interval = -1)
        {
            TypeInfo             typeInfo        = type.GetTypeInfo();
            ModelLoaderAttribute customAttribute = typeInfo.GetCustomAttribute <ModelLoaderAttribute>(false);

            if (customAttribute != null)
            {
                if (typeInfo.DeclaredConstructors.FirstOrDefault <ConstructorInfo>((ConstructorInfo p) => p.GetParameters().Length == 0) == null)
                {
                    throw new Exception(string.Concat(type.FullName, " not exist default constructor"));
                }
                ModelLoader modelLoader = new ModelLoader(type, customAttribute);
                ModelLoader.Loaders.Add(type, modelLoader);
                if (interval == -1)
                {
                    interval = customAttribute.Interval;
                }
                modelLoader.Start(interval, true);
            }
        }
예제 #2
0
 internal void SetModelLoader(ModelLoader loader)
 {
     this.loader = loader;
 }