public ContentEncodingBuilder Add(ContentEncodingType encoding) { _encodings ??= new ConstantGrowArray <ContentEncodingType>(1); _encodings.Add(encoding); return(this); }
/// <summary> /// 게시판의 상세 보기 페이지(Details, BoardView) /// </summary> public IActionResult Details(int id) { // 넘겨온 Id 값에 해당하는 레코드 하나 읽어서 Note 클래스에 바인딩 var note = _repository.GetNoteById(id); //[!] 인코딩 방식에 따른 데이터 출력: // 직접 문자열 비교해도 되지만, 학습목적으로 열거형으로 비교 ContentEncodingType encoding = (ContentEncodingType)Enum.Parse(typeof(ContentEncodingType), note.Encoding); string encodedContent = ""; switch (encoding) { // Text : 소스 그대로 표현 case ContentEncodingType.Text: encodedContent = Dul.HtmlUtility.EncodeWithTabAndSpace(note.Content); break; // Html : HTML 형식으로 출력 case ContentEncodingType.Html: encodedContent = note.Content; // 변환없음 break; // Mixed : 엔터처리만 case ContentEncodingType.Mixed: encodedContent = note.Content.Replace("\r\n", "<br />"); break; // Html : 기본 default: encodedContent = note.Content; // 변환없음 break; } ViewBag.Content = encodedContent; //[!] // 첨부된 파일 확인 if (note.FileName.Length > 1) { //[a] 파일 다운로드 링크: String.Format()으로 표현해 봄 ViewBag.FileName = String.Format("<a href='/DotNetNote/BoardDown?Id={0}'>" + "{1}{2} / 전송수: {3}</a>", note.Id, "<img src=\"/images/ext/ext_zip.gif\" border=\"0\">", note.FileName, note.DownCount); //[b] 이미지 미리보기: C# 6.0 String 보간법으로 표현해 봄 if (Dul.BoardLibrary.IsPhoto(note.FileName)) { ViewBag.ImageDown = $"<img src=\'/DotNetNote/ImageDown/{note.Id}\'><br />"; } } else { ViewBag.FileName = "(업로드된 파일이 없습니다.)"; } // 현재 글에 해당하는 댓글 리스트와 현재 글 번호를 담아서 전달 NoteCommentViewModel vm = new NoteCommentViewModel(); vm.NoteCommentList = _commentRepository.GetNoteComments(note.Id); vm.BoardId = note.Id; ViewBag.CommentListAndId = vm; return(View(note)); }
public static string GetMemberValue(this ContentEncodingType type) { if (type == ContentEncodingType.Unknown) { throw new ArgumentOutOfRangeException(nameof(type), type, null); } if (type == ContentEncodingType.Brotli) { return("br"); } return(type.ToString().ToLowerInvariant()); }
public Upload WithContentEncoding(ContentEncodingType type) { _request.ContentEncoding.Add(type); return(this); }