Beispiel #1
0
 /// <summary>
 /// Free global instance of
 /// <see cref="IrbisUpperCaseTable"/>.
 /// </summary>
 public static void ResetInstance()
 {
     lock (_lock)
     {
         _instance = null;
     }
 }
Beispiel #2
0
        public static IrbisUpperCaseTable ParseText
        (
            [NotNull] Encoding encoding,
            [NotNull] string text
        )
        {
            Sure.NotNull(encoding, "encoding");
            Sure.NotNullNorEmpty(text, "text");

            List <byte> table = new List <byte>(256);

            MatchCollection matches = Regex.Matches(text, @"\d+");

            foreach (Match match in matches)
            {
                byte b = byte.Parse(match.Value);
                table.Add(b);
            }

            IrbisUpperCaseTable result = new IrbisUpperCaseTable
                                         (
                encoding,
                table.ToArray()
                                         );

            return(result);
        }
Beispiel #3
0
        public static IrbisUpperCaseTable FromServer
        (
            [NotNull] IrbisConnection connection,
            [NotNull] string fileName
        )
        {
            Sure.NotNull(connection, "connection");
            Sure.NotNullNorEmpty(fileName, "fileName");

            FileSpecification specification
                = new FileSpecification
                  (
                      IrbisPath.System,
                      fileName
                  );

            string text = connection.ReadTextFile
                          (
                specification
                          );

            if (string.IsNullOrEmpty(text))
            {
                Log.Error
                (
                    "IrbisUpperCaseTable::FromServer: "
                    + "no file "
                    + fileName.ToVisibleString()
                );

                throw new IrbisNetworkException
                      (
                          "No file " + fileName
                      );
            }

            IrbisUpperCaseTable result = ParseText
                                         (
                IrbisEncoding.Ansi,
                text
                                         );

            return(result);
        }
Beispiel #4
0
        public static IrbisUpperCaseTable GetInstance
        (
            [NotNull] IrbisConnection connection
        )
        {
            Sure.NotNull(connection, "connection");

            if (ReferenceEquals(_instance, null))
            {
                lock (_lock)
                {
                    if (ReferenceEquals(_instance, null))
                    {
                        _instance = FromServer
                                    (
                            connection,
                            FileName
                                    );
                    }
                }
            }

            return(_instance);
        }