본문 바로가기

C#29

27# C# RestSharp 사용해서 restapi 샘플데이터 만들기 자바로 rest api 만들면서 C#으로 테스트하던 도중 포스팅을 하려 한다. 간단한 자바 rest api 이메일 중복 검사 코드 @PostMapping(value = "/duplicate_email") @ApiOperation(value="이메일 중복검사", notes="회원 가입 시 이메일 중복 확인용.") public String emailDuplicate(@RequestParam(value = "email", required = true) String email) throws Exception { if(StringUtils.isEmpty(email) == true) throw new RestapiInvalidRequestException(CustomErrorCode.Email_Blank, Cust.. 2020. 8. 6.
26# Winform ListView Focus 잃었을 때도 선택 고정 ListView를 사용할 일이 생겼는데, 포커스를 잃었을 때 선택 내용이 너무 눈에 띄지 않는다. 그러다가 양형 코드를 찾아봤는데 뭔가 흠... 한국 사이트 코드를 찾았을땐 이건 아닌거 같아서 대충 만들어 봤다. 누군가에겐 도움이 되길. private void ListView_LostFocus(object sender, EventArgs e) { ListView listView = sender as ListView; listViewLastIndex = listView.FocusedItem.Index; for (int i = 0; i -1) { ListView listView = sender as ListView; listView.Items[listViewLastIndex].BackColor = Syste.. 2019. 10. 25.
25# 비트 연산 어떤 숫자를 암호화하기는 낭비고 조금 귀찮게 만들기 위해 비트 연산을 사용하기로 했다. static void Main(string[] args) { int user = 1; int key = 34284388; int crtpograph = user ^ key; Console.WriteLine(crtpograph); int decrpt = crtpograph ^ key; Console.WriteLine(decrpt); int a = 1; var b = a 8; Console.WriteLine(c); Console.Read(); } 내가 채택한 방식은 XOR과 Shift 연산이다. 성능에 대해 찾아봤더니 닷넷 구조상 별 다른 차이는 없는것 같다. 아래는 양형의 실행 결과 AND operator: 797968.. 2019. 10. 11.
24# 서버와 접속 중일 때 자신 포트 찾기 서버에 접속하려면 서버 ip와 포트를 알아야 한다. 그런데 클라이언트에서 자기 포트를 알아야 하는 경우가 생겼는데, 별 다른 글이 없는 도중 양형의 좋은 글을 발견. IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners(); TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections(); foreach (TcpConnectionInformation info in tcpConnections) { if(info.RemoteEndPoi.. 2019. 10. 3.