public override void Process(Command command) { Exception e = null; var options = (CommandOptions)this.LoadOptions((TextCommand)command); var nodeType = NodeType.FromName(options.NodeType); var node = this.Connection.FileSystemManager.Resolve(options.Uri, nodeType); node.Refresh(); if (!node.Exists) { throw new NodeNotFoundException(node.Address); } if (!NodeTypeSupported(node.NodeType)) { Connection.WriteError(ErrorCodes.INVALID_PARAM); return; } Connection.WriteOk(); Connection.Flush(); using (node.Attributes.AquireUpdateContext()) { var lastLineRead = new ValueBox <string>(); foreach (var attribute in TextNetworkProtocol.ReadAttributes(Connection.ReadTextBlock, lastLineRead)) { var attributeName = attribute.Name; var attributeValue = attribute.Value; if (!(attributeName.EqualsIgnoreCase("exists") || attributeName.EqualsIgnoreCase("length"))) { e = ActionUtils.IgnoreExceptions(delegate { node.Attributes[attributeName] = attributeValue; }); } } } if (e != null) { throw e; } this.Connection.WriteOk(); }
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); } } }