public static void Convert( System.Type conversionClass, Bam.Core.Settings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { var moduleType = typeof(Bam.Core.Module); var vsSettingsGroupType = typeof(VSSolutionBuilder.VSSettingsGroup); var stringType = typeof(string); foreach (var i in settings.Interfaces()) { var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, vsSettingsGroupType, stringType }); if (null == method) { throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})", conversionClass.ToString(), i.ToString(), moduleType, vsSettingsGroupType, stringType); } try { method.Invoke(null, new object[] { settings, module, vsSettingsGroup, condition }); } catch (System.Reflection.TargetInvocationException exception) { throw new Bam.Core.Exception(exception.InnerException, "VisualStudio conversion error:"); } } }
public static void Convert( System.Type conversionClass, Bam.Core.Settings toolSettings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { var moduleType = typeof(Bam.Core.Module); var xcodeConfigurationType = typeof(XcodeBuilder.Configuration); foreach (var i in toolSettings.Interfaces()) { var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, xcodeConfigurationType }); if (null == method) { throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})", conversionClass.ToString(), i.ToString(), moduleType, xcodeConfigurationType); } try { method.Invoke(null, new object[] { toolSettings, module, configuration }); } catch (System.Reflection.TargetInvocationException exception) { throw new Bam.Core.Exception(exception.InnerException, "Xcode conversion error:"); } } }
Convert( System.Type conversionClass, Bam.Core.Settings toolSettings, Bam.Core.StringArray commandLine) { var stringArrayType = typeof(Bam.Core.StringArray); foreach (var i in toolSettings.Interfaces()) { var method = conversionClass.GetMethod("Convert", new[] { i, stringArrayType }); if (null == method) { throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2})", conversionClass.ToString(), i.ToString(), stringArrayType); } var commands = new Bam.Core.StringArray(); try { method.Invoke(null, new object[] { toolSettings, commands }); } catch (System.Reflection.TargetInvocationException exception) { throw new Bam.Core.Exception(exception.InnerException, "Command line conversion error:"); } commandLine.AddRange(commands); } }
CreateDeltaSettings( Bam.Core.Settings sharedSettings, Bam.Core.Module module) { var attributeType = typeof(Bam.Core.SettingsExtensionsAttribute); var moduleSpecificSettings = System.Activator.CreateInstance(module.Settings.GetType(), module, false) as SettingsBase; var sharedInterfaces = sharedSettings.Interfaces(); foreach (var i in module.Settings.Interfaces()) { var attributeArray = i.GetCustomAttributes(attributeType, false); if (0 == attributeArray.Length) { throw new Bam.Core.Exception("Settings interface {0} is missing attribute {1}", i.ToString(), attributeType.ToString()); } var attribute = attributeArray[0] as Bam.Core.SettingsExtensionsAttribute; // if we match any of the shared interfaces, get a delta // otherwise, just clone the interface if (sharedInterfaces.Any(item => item == i)) { var deltaMethod = attribute.GetMethod("Delta", new[] { i, i, i }); if (null != deltaMethod) { Bam.Core.Log.DebugMessage("Executing {0}", deltaMethod.Name); deltaMethod.Invoke(null, new[] { moduleSpecificSettings, this, sharedSettings }); } else { throw new Bam.Core.Exception("Unable to find method {0}.Delta(this {1}, {1}, {1)", attribute.ExtensionsClassName, i.ToString()); } } else { var cloneMethod = attribute.GetMethod("Clone", new[] { i, i }); if (null != cloneMethod) { Bam.Core.Log.DebugMessage("Executing {0}", cloneMethod.Name); cloneMethod.Invoke(null, new[] { moduleSpecificSettings, this }); } else { throw new Bam.Core.Exception("Unable to find method {0}.Clone(this {1}, {1})", attribute.ExtensionsClassName, i.ToString()); } } } return moduleSpecificSettings; }