/// <summary> /// Gets the mapping. /// </summary> /// <returns>An instance of the DatabaseNameMapping class.</returns> public static DatabaseNameMapping GetMapping() { if (instance == null) { instance = new DatabaseNameMapping(); } return(instance); }
/// <summary> /// Initializes a new instance of the <see cref="DataFileInfo" /> class. /// </summary> /// <param name="dataFileName">Name of the data file.</param> public DataFileInfo(string dataFileName) { this.dataFileFullPath = dataFileName; this.name = Path.GetFileNameWithoutExtension(dataFileName); int index1 = name.IndexOf('.'); if (index1 > 0) { this.database = name.Substring(0, index1); DatabaseNameMapping mapping = DatabaseNameMapping.GetMapping(); if (!mapping.Map.TryGetValue(this.database, out this.targetDatabase)) { this.targetDatabase = this.database; this.targetServer = "localhost"; } else { string[] a = this.targetDatabase.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); if (a.Length >= 2) { this.targetServer = a[0]; this.targetDatabase = a[1]; } else { this.targetDatabase = a[0]; } } int index2 = name.IndexOf('.', index1 + 1); if (index2 > 0) { this.owner = name.Substring(index1 + 1, index2 - index1 - 1); int index3 = name.IndexOf('(', index2 + 1); if (index3 > 0) { this.table = name.Substring(index2 + 1, index3 - index2 - 1); } else { this.table = name.Substring(index2 + 1); } } else { this.owner = name.Substring(index1 + 1); } } }