본문 바로가기

C#39

00# 추상 팩토리(Abstract Factory) 패턴 2012년 6월 쯤, 디자인패턴에 관심이 생겼을 때 C#으로 구현된 코드를 찾아보기가 쉽지 않아 개념적인 것을 보고 혼자 구현해봤던추상 팩토리입니다. 1234567891011121314151617using System;using System.Collections.Generic;using System.Text; class AbstractFactory{ static void Main(string[] args) { Restaurant restaurant1 = new Restaurant(CookType.Korea); Console.WriteLine(restaurant1.Cooking()); Restaurant restaurant2 = new Restaurant(CookType.Japen); Console.Wri.. 2016. 4. 18.
02#INI 파일 읽기 쓰기 C#에서 INI에 읽기 쓰기 12345678910111213141516171819202122232425using System.Runtime.InteropServices;using Microsoft.Win32; //ini 파일 API 함수[DllImport("kernel32.dll")] //Readprivate static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); [DllImport("kernel32.dll")] //Writeprivate static extern long WritePrivateProfileString(stri.. 2016. 4. 18.
01# 공유메모리를 통한 프로그램 호출, 종료, 메시지 전송 신입 시절 구현했던 공유메모리를 통한 프로그램 실행 및 종료이다.WMI 제어를 통한 네트워크 연결을 활성화, 비활성화 하는 프로그램을 제어하는데 사용했다.Visual Studio로 코드 짠게 아니라, 코드 스크립트에서 예전에 구현했던 걸 보고 다시 한거라 오타가 있을수도 ^^; 코드는 다음과 같다. 프로그램이 실행상태인지 확인 후, 정보를 보내는 코드 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192using System;using System.. 2016. 4. 18.