private static Configuration CreateDefaultConfiguration() { Configuration config = new Configuration(); config.EnableDataBinding = true; config.GenerateOrder= true; config.GenerateProperties = true; config.GenerateComplexTypes = true; config.GenerateComplexTypesSpecified = true; config.CodeModifiers.Add(new AssemblyType(typeof(CodeGeneration.CodeModifiers.ConvertArraysToCollections))); config.CodeModifiers.Add(new AssemblyType(typeof(CodeGeneration.CodeModifiers.RemoveDebuggerAttribute))); //config.CodeModifiers.Add(new AssemblyType(typeof(CodeGeneration.CodeModifiers.RemoveSpecifiedTypes))); //config.CodeModifiers.Add(new AssemblyType(typeof(CodeGeneration.CodeModifiers.ModifyImports))); AssemblyType importFixer = new AssemblyType(typeof(CodeGeneration.CodeModifiers.ImportFixer)); importFixer.Any = CodeGeneration.CodeModifiers.ImportFixer.DefaultOptions; config.CodeModifiers.Add(importFixer); return config; }
/// <summary> /// Load the configuration from the output file if it exists /// Otherwise, create a new configuration /// </summary> /// <param name="fileName"></param> public static void Load(string fileName) { try { string configFile = GetConfigFileName(fileName); #if REPLACEORIGINAL if (!File.Exists(configFile)) m_configuration = new Configuration(); StringBuilder sb = new StringBuilder(); // parse the input file and look for the configuration using (StreamReader sr = new StreamReader(configFile)) { string line; while ((line = sr.ReadLine()) != null) { if (line.StartsWith(Resources.Configuration_StartDelimeter)) { while ((line = sr.ReadLine()) != null) { if (line.StartsWith(Resources.Configuration_EndDelimeter)) break; sb.Append(line); } break; } } } // if we found the configuration, deserialize it if (sb.Length > 0) { try { m_configuration = Serializer.Deserialize<Configuration>(sb.ToString()); } catch (Exception ex) { Trace.TraceError(ex.ToString()); m_configuration = new Configuration(); } } else { m_configuration = new Configuration(); } #else if (File.Exists(configFile)) { m_configuration = Serializer.DeserializeFromFile<Configuration>(configFile); } else { m_configuration = CreateDefaultConfiguration(); } #endif } catch (Exception ex) { string message = string.Format("Error loading XmlToClasses configuration file {0}. See Inner Exception below for details", fileName); throw new Exception(message, ex); } }