本文介绍了在 Visual C# 2008 中解析 tnsnames.ora的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用 Visual C#(Visual Studio 2008 Express 版)解析 tnsnames.ora 文件以获取 tnsnames ?例如,我的 tnsnames.ora 文件包含

How I parse tnsnames.ora file using Visual C# (Visual Studio 2008 Express edition) to get the tnsnames ?For instance, my tnsnames.ora file contains

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = shaman)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
BILL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.58)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

我如何解析此文件以获取 TNSNAMES(即 ORCL、BILL 等).如果这个问题听起来太明显,请原谅我,我正在学习 &尝试使用 C#

How can I parse this file to get the TNSNAMES (ie, ORCL, BILL etc). Forgive me if this question sounds too obvious, I'm learning & trying my hand in C#

推荐答案

首先,您需要 此文件的语法规则.

这可能有一个 hack,但我个人会使用完整的解析器,例如 ANTLR结合正确的语法(完整的ANTLR语法列表可以在这里找到).

There is probably a hack for this, but I would personally go with a full parser, like ANTLR combined with the proper grammar (a complete list of ANTLR grammars can be found here).

这篇关于在 Visual C# 2008 中解析 tnsnames.ora的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 00:21