본문 바로가기

씨샵8

10# 데이터 압축 유니티 통신용으로 호환될 수 있는 SharpZipLib 사용 1234567891011121314151617181920212223242526272829303132using ICSharpCode.SharpZipLib.BZip2; /// /// byte[] compress 압축/// public byte[] GenericToByteZip(T generic){ MemoryStream buffer = new MemoryStream(); MemoryStream outBuffer = new MemoryStream(); protobuf.Serialize(buffer, ref generic); buffer.Position = 0; BZip2.Compress(buffer, outBuffer, false, 3); retur.. 2017. 5. 19.
09# 중복 없는 랜덤키 값 추출 1234567891011121314151617181920212223242526272829303132public static class UniqueKey{ private static readonly char[] chars = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }; public static Int64 GetKey(Int32 keyLength) { Int64 uniqueKey = 0; const Int32 count = 100; for(Int32 i = 0; i result.Length) continue; uniqueKey = Convert.ToInt64(result); break; } return uniqueKey; }}Colore.. 2017. 4. 18.
05# 소켓 비동기식 처리 삼성 어딘가에서 쓰고 있을 내가 만든 소켓 비동기식 dll... 점층적 생성자를 사용하고 있지만, 이펙티브 자바를 일찍 봤다면 builder 패턴을 여기다 적용 해봤을 수도 있었을 것 같다.그나마 5달 지난 최근 코드 스타일인데.. 년수가 지날 수록 점점 코드 스타일이 변형되어 가는듯 ^^ 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141.. 2016. 4. 18.
04# 속성(Property) 객체 생성 시 초기화 클래스 생성 시, 객체 초기화 방법 1234567891011121314151617181920212223242526272829303132public class DefaultValuesTest{ public DefaultValuesTest() { foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) { DefaultValueAttribute myAttribute = (DefaultValueAttribute)property.Attributes[typeof(DefaultValueAttribute)]; if (myAttribute != null) { property.SetValue(this, myAttribute.Value); } .. 2016. 4. 18.