当前位置: 首页>>代码示例>>C#>>正文


C# Tag.getAttribute方法代码示例

本文整理汇总了C#中Tag.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Tag.getAttribute方法的具体用法?C# Tag.getAttribute怎么用?C# Tag.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tag的用法示例。


在下文中一共展示了Tag.getAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
//.........这里部分代码省略.........
开发者ID:biegomar,项目名称:nuodb-dotnet,代码行数:101,代码来源:NuoDbConnectionInternal.cs

示例2: 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)
                {
//.........这里部分代码省略.........
开发者ID:nuodb,项目名称:nuodb-dotnet,代码行数:101,代码来源:NuoDbConnectionInternal.cs


注:本文中的Tag.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。