public void Process(Instruction instruction) { Command command; switch (instruction.InstructionType) { case InstructionType.NamespaceDeclaration: command = new NamespaceDeclarationCommand(instruction.NamespaceDeclaration, StateCommuter); break; case InstructionType.StartObject: command = new StartObjectCommand(StateCommuter, TypeSource, instruction.XamlType, rootInstance); break; case InstructionType.StartMember: command = new StartMemberCommand(StateCommuter, GetActualMemberFromMemberSpecifiedInInstruction(instruction.Member)); break; case InstructionType.Value: command = new ValueCommand(StateCommuter, this.TypeSource, TopDownValueContext, (string)instruction.Value); break; case InstructionType.EndObject: command = new EndObjectCommand(StateCommuter, stateCommuter => Result = stateCommuter.Current.Instance); break; case InstructionType.EndMember: command = new EndMemberCommand(TypeSource, StateCommuter); break; case InstructionType.GetObject: command = new GetObjectCommand(StateCommuter); break; default: throw new ParseException($"The XamlInstructionType {instruction.InstructionType} has an unexpected value"); } command.Execute(); }
public ICommandResult Handle(GetObjectCommand command) { ICommandResult result = new GetObjectCommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Object, command.RequestHost }, "ObjectCommandHandler.Handle(Get)"); try { if (_objectRepository.CheckExists(command.Object)) { Object obj = _objectRepository.Get(command.Object); if (obj != null) { result = new GetObjectCommandResult(200, obj.Title, obj.Description, obj.Creator, obj.Father, obj.Path, obj.Type, obj.Status, obj.CreationDate); } } else if (_objectRepository.Valid) { result = new GetObjectCommandResult(400, new Notification("Object", "Could not be found")); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Object, command.RequestHost }, e); } return(result); }
/// <inheritdoc/> public OssObject GetObject(GetObjectRequest getObjectRequest) { ThrowIfNullRequest(getObjectRequest); var cmd = GetObjectCommand.Create(GetServiceClient(), _endpoint, CreateContext(HttpMethod.Get, getObjectRequest.BucketName, getObjectRequest.Key), getObjectRequest); return(cmd.Execute()); }
/// <inheritdoc/> public IAsyncResult BeginGetObject(GetObjectRequest getObjectRequest, AsyncCallback callback, Object state) { ThrowIfNullRequest(getObjectRequest); var cmd = GetObjectCommand.Create(GetServiceClient(), _endpoint, CreateContext(HttpMethod.Get, getObjectRequest.BucketName, getObjectRequest.Key), getObjectRequest); return(OssUtils.BeginOperationHelper(cmd, callback, state)); }
/// <summary> /// 根据主键获取对象 /// </summary> /// <param name="keys">主键,多个主键按照主键名顺序排列</param> /// <returns>对象,若不存在则返回null</returns> public virtual T GetObject(params object[] keys) { ThrowExceptionIfWrongKeys(keys); int i = 0; foreach (IDataParameter param in GetObjectCommand.Parameters) { param.Value = ConvertToDBValue(keys[i], Table.Definition.Keys[i]); i++; } using (IDataReader reader = GetObjectCommand.ExecuteReader()) { return(ReadOne(reader)); } }
public GetObjectCommandResult Get(Guid id) { GetObjectCommand command = new GetObjectCommand() { Object = id }; command.setRequestHost(HttpContext.Request.Host.ToString()); _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { Object = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method }); GetObjectCommandResult result = (GetObjectCommandResult)_objectHandler.Handle(command); _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { Object = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode }); HttpContext.Response.StatusCode = result.Code; return(result); }
public void Process(Instruction instruction) { Command command; switch (instruction.InstructionType) { case InstructionType.NamespaceDeclaration: command = new NamespaceDeclarationCommand(instruction.NamespaceDeclaration, StateCommuter); break; case InstructionType.StartObject: command = new StartObjectCommand(StateCommuter, TypeSource, instruction.XamlType, rootInstance); break; case InstructionType.StartMember: command = new StartMemberCommand(StateCommuter, GetActualMemberFromMemberSpecifiedInInstruction(instruction.Member)); break; case InstructionType.Value: command = new ValueCommand(StateCommuter, valueContext, (string)instruction.Value); break; case InstructionType.EndObject: command = new EndObjectCommand(StateCommuter, stateCommuter => Result = stateCommuter.Current.Instance, LifecycleListener); break; case InstructionType.EndMember: command = new EndMemberCommand(TypeSource, StateCommuter, valueContext); break; case InstructionType.GetObject: command = new GetObjectCommand(StateCommuter); break; default: throw new ParseException($"The XamlInstructionType {instruction.InstructionType} has an unexpected value"); } command.Execute(); }
public void Process(XamlInstruction instruction) { Command command; switch (instruction.InstructionType) { case XamlInstructionType.NamespaceDeclaration: command = new NamespaceDeclarationCommand(this, instruction.NamespaceDeclaration); break; case XamlInstructionType.StartObject: command = new StartObjectCommand(this, instruction.XamlType, rootInstance); break; case XamlInstructionType.StartMember: command = new StartMemberCommand(this, GetMember(instruction.Member)); break; case XamlInstructionType.Value: command = new ValueCommand(this, topDownValueContext, (string)instruction.Value); break; case XamlInstructionType.EndObject: command = new EndObjectCommand(this); break; case XamlInstructionType.EndMember: command = new EndMemberCommand(this, topDownValueContext); break; case XamlInstructionType.GetObject: command = new GetObjectCommand(this); break; default: throw new XamlParseException($"The XamlInstructionType {instruction.InstructionType} has an unexpected value"); } command.Execute(); }
/// <summary> /// 下载对象 /// </summary> /// <param name="bucket"></param> /// <param name="key"></param> /// <param name="parameters"></param> /// <returns></returns> public async Task <OssResult <GetObjectResult> > GetObjectAsync(BucketInfo bucket, string key, GetObjectParams parameters = null) { var cmd = new GetObjectCommand(_requestContext, bucket, key, parameters); return(await cmd.ExecuteAsync()); }
public void Process(XamlNode node) { Command command; switch (node.NodeType) { case XamlNodeType.NamespaceDeclaration: command = new NamespaceDeclarationCommand(this, node.NamespaceDeclaration); break; case XamlNodeType.StartObject: command = new StartObjectCommand(this, node.XamlType, rootInstance); break; case XamlNodeType.StartMember: command = new StartMemberCommand(this, GetMember(node.Member)); break; case XamlNodeType.Value: command = new ValueCommand(this, (string)node.Value); break; case XamlNodeType.EndObject: command = new EndObjectCommand(this); break; case XamlNodeType.EndMember: command = new EndMemberCommand(this, topDownMemberValueContext); break; case XamlNodeType.GetObject: command = new GetObjectCommand(this); break; default: throw new InvalidOperationException(); } command.Execute(); }