public CppTestProjectBuilder(string buildNamespace, ConfigureOrder configureOrder = ConfigureOrder.New) : base(InitType.Cpp, buildNamespace, configureOrder) { }
private static IEnumerable <MethodInfo> GetConfigureMethods(Type type, ConfigureOrder baseOrder) { Dictionary <string, MethodInfo> configureMethodDictionary = new Dictionary <string, MethodInfo>(); List <MethodInfo> configureMethodInfos = new List <MethodInfo>(); Type currentType = type; while (currentType != typeof(object)) { MethodInfo[] methodInfos = currentType.GetMethods(); foreach (MethodInfo methodInfo in methodInfos) { bool defineConfigure = methodInfo.IsDefined(typeof(Configure), true); if (!methodInfo.IsAbstract && !methodInfo.IsConstructor && !methodInfo.IsGenericMethod && defineConfigure) { string signature = methodInfo.ToString(); if (!configureMethodDictionary.ContainsKey(signature)) { configureMethodDictionary.Add(signature, methodInfo); configureMethodInfos.Add(methodInfo); } } } currentType = currentType.BaseType; } List <MethodInfo> filterMethods = new List <MethodInfo>(); Dictionary <Type, List <MethodInfo> > typeMethodInfo = new Dictionary <Type, List <MethodInfo> >(); currentType = type; while (currentType != typeof(object)) { typeMethodInfo.Add(currentType, new List <MethodInfo>()); currentType = currentType.BaseType; } foreach (MethodInfo method in configureMethodInfos) { // Get the first declaring type Type rootDeclaringType = method.DeclaringType; while (rootDeclaringType.BaseType.GetMethod(method.Name) != null) { rootDeclaringType = rootDeclaringType.BaseType; } typeMethodInfo[rootDeclaringType].Add(method); } currentType = type; while (currentType != typeof(object)) { var typeConfigure = typeMethodInfo[currentType].AsEnumerable(); if (baseOrder == ConfigureOrder.New) { typeConfigure = typeConfigure.OrderBy(configure => configure.MetadataToken); } filterMethods.InsertRange(0, typeConfigure); currentType = currentType.BaseType; } return(filterMethods); }