// Singleton Constructor. static Options() { instance = new Options(); }
/// <summary> /// Check the Parameter Format for validity /// </summary> /// <param name = "str"></param> /// <param name = "formattype"></param> /// <returns></returns> public static bool CheckParameterFormat(string str, Options.ParameterFormat formattype) { if (formattype == Options.ParameterFormat.FileNameToTag || formattype == Options.ParameterFormat.TagToFileName || formattype == Options.ParameterFormat.RipFileName || formattype == Options.ParameterFormat.Organise) { str = str.Replace("<A>", "\x0001"); // Artist str = str.Replace("<T>", "\x0001"); // Title str = str.Replace("<B>", "\x0001"); // Album str = str.Replace("<G>", "\x0001"); // Genre str = str.Replace("<Y>", "\x0001"); // Year str = str.Replace("<O>", "\x0001"); // Album Artist / Orchestra / Band str = str.Replace("<K>", "\x0001"); // Track } if (formattype == Options.ParameterFormat.FileNameToTag || formattype == Options.ParameterFormat.TagToFileName || formattype == Options.ParameterFormat.Organise) { str = str.Replace("<C>", "\x0001"); // Comment str = str.Replace("<D>", "\x0001"); // Disk (Position in Mediaset) str = str.Replace("<d>", "\x0001"); // Total # of Disks str = str.Replace("<k>", "\x0001"); // Total # of Tracks str = str.Replace("<U>", "\x0001"); // Content Group str = str.Replace("<N>", "\x0001"); // Conductor str = str.Replace("<R>", "\x0001"); // Composer str = str.Replace("<S>", "\x0001"); // Subtitle str = str.Replace("<E>", "\x0001"); // BPM str = str.Replace("<M>", "\x0001"); // Modified by / remixed by } if (formattype == Options.ParameterFormat.TagToFileName) { str = str.Replace("<F>", "\x0001"); // FileName str = str.Replace("<#>", "\x0001"); // Enumerate in File int index = str.IndexOf("<K:"); // Track Number with a given length of digits if (index > -1 && !CheckParmWithLengthIndicator(index, str, out str)) { return false; } index = str.IndexOf("<k:"); // Total Number Tracks with a given length of digits if (index > -1 && !CheckParmWithLengthIndicator(index, str, out str)) { return false; } index = str.IndexOf("<D:"); // Disc Number with a given length of digits if (index > -1 && !CheckParmWithLengthIndicator(index, str, out str)) { return false; } index = str.IndexOf("<d:"); // Total Number Discs with a given length of digits if (index > -1 && !CheckParmWithLengthIndicator(index, str, out str)) { return false; } } if (formattype == Options.ParameterFormat.Organise) { str = str.Replace("<I>", "\x0001"); // Bitrate int index = str.IndexOf("<A:"); if (index > -1 && !CheckParmWithLengthIndicator(index, str, out str)) { return false; } index = str.IndexOf("<O:"); if (index > -1 && !CheckParmWithLengthIndicator(index, str, out str)) { return false; } } if (formattype == Options.ParameterFormat.FileNameToTag) { str = str.Replace("<X>", "\x0001"); // Unused } if ((str.IndexOf("<") >= 0 || str.IndexOf(">") >= 0) || (str.IndexOf("\x0001\x0001") >= 0 && formattype == Options.ParameterFormat.FileNameToTag)) return false; return true; }