IEnumerable<CryScript> ProcessAssembly(Assembly assembly) { var scripts = new List<CryScript>(); foreach (var type in assembly.GetTypes()) { IScriptRegistrationParams registrationParams = null; CryScript script; if (!type.ContainsAttribute<ExcludeFromCompilationAttribute>() && CryScript.TryCreate(type, out script)) { if (script.ScriptType.ContainsFlag(ScriptType.Actor)) TryGetActorParams(ref registrationParams, script.Type); else if (script.ScriptType.ContainsFlag(ScriptType.GameRules)) TryGetGamemodeParams(ref registrationParams, script.Type); else if (script.ScriptType.ContainsFlag(ScriptType.Entity)) TryGetEntityParams(ref registrationParams, script.Type); else if (script.ScriptType.ContainsFlag(ScriptType.FlowNode)) { if (!TryGetFlowNodeParams(ref registrationParams, script.Type)) continue; } // else if (script.ScriptType.ContainsFlag(ScriptType.UIEventSystem)) // UIEventSystem.Load(script); if (script.ScriptType.ContainsFlag(ScriptType.CryScriptInstance)) { foreach (var member in type.GetMethods(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public)) { ConsoleCommandAttribute attribute; if (member.TryGetAttribute(out attribute)) ConsoleCommand.Register(attribute.Name ?? member.Name, Delegate.CreateDelegate(typeof(ConsoleCommandDelegate), member as MethodInfo) as ConsoleCommandDelegate, attribute.Comment, attribute.Flags); } } script.RegistrationParams = registrationParams; scripts.Add(script); } if(type.ContainsAttribute<TestCollectionAttribute>()) { var ctor = type.GetConstructor(Type.EmptyTypes); if(ctor != null) { var collection = new TestCollection { Instance = ctor.Invoke(Type.EmptyTypes), Tests = from method in type.GetMethods() where method.ContainsAttribute<TestAttribute>() && method.GetParameters().Length == 0 select method }; TestManager.TestCollections.Add(collection); } } } return scripts; }
IEnumerable<Type> ProcessAssembly(Assembly assembly) { var types = new List<Type>(); if (assembly == null) return types; foreach (var type in assembly.GetTypes()) { if (!type.ContainsAttribute<ExcludeFromCompilationAttribute>() && !type.IsAbstract && !type.IsEnum) types.Add(type); if (type.ContainsAttribute<TestCollectionAttribute>()) { var ctor = type.GetConstructor(Type.EmptyTypes); if (ctor != null) { var collection = new TestCollection { Instance = ctor.Invoke(Type.EmptyTypes), Tests = from method in type.GetMethods() where method.ContainsAttribute<TestAttribute>() && method.GetParameters().Length == 0 select method }; TestManager.TestCollections.Add(collection); } } } return types; }