本文整理汇总了C#中Tag.parse方法的典型用法代码示例。如果您正苦于以下问题:C# Tag.parse方法的具体用法?C# Tag.parse怎么用?C# Tag.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag.parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: messageReceived
public virtual void messageReceived()
{
string message = "";
try
{
Tag tag = new Tag();
message = dataInput.readString();
//System.out.println(message);
tag.parse(message);
messageReceived(tag);
}
catch (XmlException exception)
{
throw new IOException("", exception);
}
}
示例2: doOpen
private void doOpen(string hostName)
{
string databaseName = parsedConnectionString.Database;
int index = hostName.IndexOf(':');
int port = PORT;
if (index != -1)
{
try
{
port = Int32.Parse(hostName.Substring(index + 1));
}
catch (FormatException e)
{
throw new ArgumentException("Invalid port number in connection string", "ConnectionString", e);
}
hostName = hostName.Substring(0, index);
}
dataStream = new EncodedDataStream();
authenticating = false;
try
{
StringDictionary properties = new StringDictionary();
Tag tag = new Tag("Connection");
tag.addAttribute("Service", "SQL2");
tag.addAttribute("Database", databaseName);
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.ServerKey))
{
tag.addAttribute("Server", parsedConnectionString.Server);
properties["Server"] = parsedConnectionString.Server;
}
string userName = null;
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.UserKey))
{
properties["User"] = userName = parsedConnectionString.User;
tag.addAttribute("User", userName);
}
string password = null;
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.PasswordKey))
{
password = parsedConnectionString.Password;
}
string cipher = DEFAULT_CIPHER;
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.SchemaKey))
{
tag.addAttribute("Schema", parsedConnectionString.Schema);
properties["Schema"] = parsedConnectionString.Schema;
}
// see comment below ... for now these are the only two types that
// we can support in the client code
if ((!cipher.Equals("RC4")) && (!cipher.Equals("None")))
throw new NuoDbSqlException("Unknown cipher: " + cipher);
tag.addAttribute("Cipher", cipher);
string xml = tag.ToString();
CryptoSocket brokerSocket = new CryptoSocket(hostName, port);
inputStream = brokerSocket.InputStream;
outputStream = brokerSocket.OutputStream;
dataStream.write(xml);
dataStream.send(outputStream);
dataStream.getMessage(inputStream);
string response = dataStream.readString();
brokerSocket.Close();
Tag responseTag = new Tag();
responseTag.parse(response);
if (responseTag.Name.Equals("Error"))
{
throw new NuoDbSqlException(responseTag.getAttribute("text", "error text not found"));
}
serverAddress = responseTag.getAttribute("Address", null);
serverPort = responseTag.getIntAttribute("Port", 0);
if (serverAddress == null || serverPort == 0)
{
throw new NuoDbSqlException("no NuoDB nodes are available for database \"" + databaseName + "\"");
}
socket = new CryptoSocket(serverAddress, serverPort);
//socket.TcpNoDelay = true;
inputStream = socket.InputStream;
outputStream = socket.OutputStream;
dataStream.reset();
dataStream.write(xml);
dataStream.send(outputStream);
RemotePassword remotePassword = new RemotePassword();
string userKey = remotePassword.genClientKey();
dataStream.startMessage(Protocol.OpenDatabase);
dataStream.encodeInt(Protocol.PROTOCOL_VERSION);
dataStream.encodeString(databaseName);
getProcessConnection(databaseName);
//.........这里部分代码省略.........
示例3: doOpen
private void doOpen(string hostName)
{
networkErrorOccurred = false;
string databaseName = parsedConnectionString.Database;
int index = hostName.IndexOf(':');
int port = PORT;
if (index != -1)
{
try
{
port = Int32.Parse(hostName.Substring(index + 1));
}
catch (FormatException e)
{
throw new ArgumentException("Invalid port number in connection string", "ConnectionString", e);
}
hostName = hostName.Substring(0, index);
}
dataStream = new EncodedDataStream();
authenticating = false;
try
{
StringDictionary properties = new StringDictionary();
Tag tag = new Tag("Connection");
tag.addAttribute("Service", "SQL2");
tag.addAttribute("Database", databaseName);
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.ServerKey))
{
tag.addAttribute("Server", parsedConnectionString.Server);
properties["Server"] = parsedConnectionString.Server;
}
string userName = null;
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.UserKey))
{
properties["User"] = userName = parsedConnectionString.User;
tag.addAttribute("User", userName);
}
else
{
throw new ArgumentException("Username is missing in connection string", "ConnectionString");
}
string password = "";
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.PasswordKey))
{
password = parsedConnectionString.Password;
}
string cipher = DEFAULT_CIPHER;
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.CipherKey))
{
properties["Cipher"] = cipher = parsedConnectionString.Cipher;
}
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.SchemaKey))
{
tag.addAttribute("Schema", parsedConnectionString.Schema);
properties["Schema"] = parsedConnectionString.Schema;
}
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.LBTagKey))
{
properties["LBTag"] = parsedConnectionString.LBTag;
}
if (parsedConnectionString.ContainsKey(NuoDbConnectionStringBuilder.ClientInfoKey))
{
properties["clientInfo"] = parsedConnectionString.ClientInfo;
}
properties["clientProcessID"] = Process.GetCurrentProcess().Id.ToString();
// see comment below ... for now these are the only two types that
// we can support in the client code
if ((!cipher.Equals("RC4")) && (!cipher.Equals("None")))
throw new NuoDbSqlException("Unknown cipher: " + cipher);
tag.addAttribute("Cipher", cipher);
string xml = tag.ToString();
CryptoSocket brokerSocket = new CryptoSocket(hostName, port);
inputStream = brokerSocket.InputStream;
outputStream = brokerSocket.OutputStream;
dataStream.write(xml);
dataStream.send(outputStream);
dataStream.getMessage(inputStream);
string response = dataStream.readString();
brokerSocket.Close();
Tag responseTag = new Tag();
responseTag.parse(response);
if (responseTag.Name.Equals("Error"))
{
throw new NuoDbSqlException(responseTag.getAttribute("text", "error text not found"));
}
serverAddress = responseTag.getAttribute("Address", null);
serverPort = responseTag.getIntAttribute("Port", 0);
if (serverAddress == null || serverPort == 0)
{
//.........这里部分代码省略.........