public override void SetAttributes(string uri, NodeType nodeType, IEnumerable <Pair <string, object> > attributes)
        {
            using (this.AcquireCommandContext())
            {
                var attributesList = attributes.Where(x => !x.Left.EqualsIgnoreCase("length") && !x.Left.EqualsIgnoreCase("exists")).ToList();

                SendCommandWithoutResponse(@"setattributes -t={0} ""{1}""", TextNetworkProtocol.GetNodeTypeName(nodeType), uri);

                ReadResponse().ProcessError();

                try
                {
                    foreach (var attribute in attributesList)
                    {
                        WriteTextBlock(@"{0}=""{1}:{2}""", attribute.Name, ProtocolTypes.GetTypeName(attribute.Value.GetType()), ProtocolTypes.ToEscapedString(attribute.Value));
                    }
                }
                finally
                {
                    WriteTextBlock(ResponseCodes.READY);
                }

                ReadResponse().ProcessError();
            }
        }
        public override void Delete(string uri, NodeType nodeType, bool recursive)
        {
            using (this.AcquireCommandContext())
            {
                try
                {
                    SendCommand(DefaultTryCount, "delete -t={0} {1} \"{2}\"", TextNetworkProtocol.GetNodeTypeName(nodeType), recursive ? "-r" : "", uri).ProcessError();
                }
                catch (Exception)
                {
                    this.connected = false;

                    throw;
                }
            }
        }
        public override void Create(string uri, NodeType nodeType, bool createParent)
        {
            using (this.AcquireCommandContext())
            {
                try
                {
                    SendCommand(DefaultTryCount, "create -t={0} {1} \"{2}\"", TextNetworkProtocol.GetNodeTypeName(nodeType), createParent && nodeType.IsLikeDirectory ? "-p" : "", uri).ProcessError();
                }
                catch (TextNetworkProtocolException)
                {
                    this.connected = false;

                    throw;
                }
                catch (IOException)
                {
                    this.connected = false;

                    throw;
                }
            }
        }
        public override HashValue ComputeHash(string uri, NodeType nodeType, string algorithm, bool recursive, long offset, long length, IEnumerable <string> fileAttributes, IEnumerable <string> dirAttributes)
        {
            StringBuilder dirAttributesString  = null;
            StringBuilder fileAttributesString = null;

            using (this.AcquireCommandContext())
            {
                try
                {
                    if (dirAttributes != null)
                    {
                        dirAttributesString = new StringBuilder();

                        foreach (string s in dirAttributes)
                        {
                            dirAttributesString.Append(s);
                            dirAttributesString.Append(',');
                        }

                        if (dirAttributesString.Length > 0)
                        {
                            dirAttributesString.Length--;
                        }
                        else
                        {
                            dirAttributesString = null;
                        }
                    }

                    if (fileAttributes != null)
                    {
                        fileAttributesString = new StringBuilder();

                        foreach (string s in fileAttributes)
                        {
                            fileAttributesString.Append(s);
                            fileAttributesString.Append(',');
                        }

                        if (fileAttributesString.Length > 0)
                        {
                            fileAttributesString.Length--;
                        }
                        else
                        {
                            fileAttributesString = null;
                        }
                    }

                    StringBuilder commandText = new StringBuilder(128);

                    commandText.Append("computehash -hex");
                    commandText.Append(" -t=\"").Append(TextNetworkProtocol.GetNodeTypeName(nodeType)).Append('\"');

                    if (offset != 0)
                    {
                        commandText.Append(" -o=\"").Append(offset).Append('\"');
                    }

                    if (recursive)
                    {
                        commandText.Append(" -r");
                    }

                    if (length != -1)
                    {
                        commandText.Append(" -l=\"").Append(length).Append('\"');
                    }

                    if (algorithm != "md5")
                    {
                        commandText.Append(" -a=\"").Append(algorithm).Append('\"');
                    }

                    if (fileAttributesString != null)
                    {
                        commandText.Append(" -fileattribs=\"").Append(fileAttributesString).Append('\"');
                    }

                    if (dirAttributesString != null)
                    {
                        commandText.Append(" -dirattribs=\"").Append(dirAttributesString).Append('\"');
                    }

                    commandText.Append(" \"").Append(uri).Append('\"');

                    var response = SendCommand(DefaultTryCount, commandText.ToString()).ProcessError();

                    return(new HashValue
                           (
                               TextConversion.FromHexString(response.ResponseTuples["hash"]),
                               algorithm,
                               0,
                               length
                           ));
                }
                catch (TextNetworkProtocolException)
                {
                    this.connected = false;

                    throw;
                }
                catch (IOException)
                {
                    this.connected = false;

                    throw;
                }
            }
        }
        public override void Copy(string srcUri, string desUri, NodeType nodeType, bool overwrite)
        {
            using (this.AcquireCommandContext())
            {
                try
                {
                    SendCommand(DefaultTryCount, "copy -t={0} -o={1} \"{2}\" \"{3}\"", TextNetworkProtocol.GetNodeTypeName(nodeType), overwrite, srcUri, desUri).ProcessError();
                }
                catch (TextNetworkProtocolException)
                {
                    this.connected = false;

                    throw;
                }
                catch (IOException)
                {
                    this.connected = false;

                    throw;
                }
            }
        }
        public override IEnumerable <Pair <string, object> > GetAttributes(string uri, NodeType nodeType)
        {
            using (this.AcquireCommandContext(false))
            {
                var lastReadLine = new ValueBox <string>(this.lastLineRead);

                try
                {
                    this.SendCommand(DefaultTryCount, @"getattributes -t={0} ""{1}""", TextNetworkProtocol.GetNodeTypeName(nodeType), uri).ProcessError();
                }
                catch
                {
                    ReadReady();

                    throw;
                }

                foreach (var attribute in TextNetworkProtocol.ReadAttributes(this.ReadNextLine, lastReadLine))
                {
                    yield return(attribute);
                }
            }
        }