public object Read(IInputData input, Stream stream) { foreach (CreatorInfo item in fList) { if (item.Function(input)) { IPostObjectCreator source = item.Creator.CreateObject(input); if (source == null) { return(null); } else { return(source.Read(input, stream)); } } } TkDebug.ThrowToolkitException("当前的状态下,没有一个注册的PostObjectCreator满足其条件,请检查条件", this); return(null); }
protected virtual void PreparePostData() { MemoryStream stream = new MemoryStream(); byte[] data = null; try { IPostObjectCreator creator = PostObjectCreator; if (creator == null) { PostObject = null; } else { //FileUtil.CopyStream(Request.Body, stream); Request.Body.CopyToAsync(stream).GetAwaiter().GetResult(); if (BaseAppSetting.Current.IsDebug) { data = stream.ToArray(); stream.Position = 0; } PostObject = creator.Read(this, stream); } } catch (Exception ex) { TkDebug.ThrowIfNoAppSetting(); if (BaseAppSetting.Current.IsDebug) { string file = Path.Combine(BaseAppSetting.Current.XmlPath, "Post.txt"); string content = Encoding.UTF8.GetString(data); FileUtil.WriteFileUseWorkThread(file, content); } TkDebug.ThrowToolkitException("提交上来的数据不是XML,如果Debug开启,可以查看Post.txt中的内容", ex, this); } finally { stream.Dispose(); } }