Activator 를 이용한 Type Instance 생성

 

이러한 표현을 하고 싶을 때가 있다

public void setType( Class TTT)

{

var t = new TTT(...);

t.a = 123;

t.b = "azc";

}

 

하지만 C# 에서 위와 같은 표현은 허락 하지 않는다.

 

현제

로컬 DB 라이브러리를 만들고 있다. 불러들일 로컬 DB의 Column 을 개발자는 미리 알고 있지만 생성기를 통하지 않고서는

각 로우에 맞는 클래스를 자동으로 만들어 주지는 않는다.

그래서 위와 같은 표현이 아쉬운것이다. TTT 라는 클래스에 DB의 테이블에 맞는 클래스를 작성한다음 활용 하면 좋은데..

 

그래서 아래와 같은 방법을 생각했다. 가능하다. 하지만 많은 UnBoxing 과 리플렉션이 사용됨으로 사용횟수에 따라

성능차이가 날것이다.

 

 

 
//

            Type type = typeof(TEST);
            var inst = Activator.CreateInstance(type);

            PropertyInfo info = type.GetProperty("TestProperty1");
            info.SetValue(inst, "testname123", null);

            //결과 확인
            Console.WriteLine(((TEST)inst).TestProperty1);

'C#' 카테고리의 다른 글

[SQL2012] DB 생성부터 사용자 만들기 그리고 SQL 접속하기  (4) 2013.01.14
sqlMetal 사용법  (10) 2013.01.11
Activator 를 이용한 Type Instance 생성  (32) 2012.12.29
[Broadcast Video Streaming]  (149) 2012.11.27
[Tcp] 연속적인 정보를 송출시 유의점  (91) 2012.11.04
[MEMO]  (58) 2012.10.14
Yamecoder 야매코더_
C# 2012. 12. 29. 22:41

댓글을 달아 주세요

  1. 이전 댓글 더보기
  2. BlogIcon buy Guild Wars 2 Gold 2013.01.08 15:49  수정/삭제  댓글쓰기

      If things continued a little as though cash I could don't hear all of this story,everywhere in the the contrary, I may pass away all around the going to be the Snow Mountains, and all your family members may or may not under no circumstances hear the story back and forth from my hand But going to be the miracle which liked going to be the Guild Wars 2 expensive jewelry in most situations appeared when a resource box was needed: for those times when my friend may be taken into going to be the blaze,a shining light weight came out back and forth from going to be the heavens all of the sudden The light - weight stood for going to be the absolute an outlet and a resource box made going to be the soul savior ran away. The light weight helped him to learn more about can get off going to be the bondage, and drawn to my own personal friend or family member into going to be the air My family member or friend was attracted on such basis as an all in one develop Finally, http://www.ugw2gold.net Guild Wars 2 Gold, they came back the white - colored world again, and to the left about regarding the hell, http://www.ugw2gold.net buy Guild Wars 2 Gold.


      Consciousness came back for more information regarding the side of things about my very own friend again. First,he / she you feel warm. The warm what liked going to be the Guild Wars 2 gold gave going to be the an outlet for more information about kale and be of assistance kale for more information about open his or her eyes again. It seemed that going to be the snow stopped and a multi function beautiful on the human body appeared. That was an all in one white goddess; she was stroking his / her face providing some one her supple hands. He lots of so quiet and slept again. When she or he woke up again,the glaciers has already stopped throughout His do you experience feeling was wrapped all over the a multi function beautiful shower robe The bathrobe gave him going to be the warm what that person had to have and a resource box will allow kale to live through as part of your glaciers He were familiar with somebody decide to put going to be the shower robe throughout the her or his do you experience feeling He i searched even more than straight away but take heart he or she may not care either make an appointment with almost nothing at all.

  3. BlogIcon borse hermes 2013.01.08 19:16  수정/삭제  댓글쓰기

    "......" birkin hermes prezzo all'improvviso non so senza dirglielo, alla fine, di che cosa.Da prima di mia sorella e mi sembra che non riesci a trovare il futuro affidabile deve essere molto difficile, in che modo? Davvero hermes? "Qin Hong Mese Dopo molte discussioni, è anche confronto hermes possibile.

    "...... Beh, questa volta borse hermes si limitò ad annuire con la testa.". Questo è abbastanza buono, se le facce della conoscenza sono degno di te" hermes annuì, poi chiese, curioso: "Quando si inizia lo stai facendo?""...... Lo scorso Natale, molto buono." hermes rispose.

    "Finché non ho mai notato prima," borsa hermes birkin scuro osservato con sufficiente attenzione ad incolpare se stessi, "ci vediamo in stato confusionale negli ultimi tempi, come, lo vuoi?" "Se vuoi che vada indietro tutto il giorno per vederti un sognatore, e non mi sento a mio agio." La hermes ha interrotto la sua irritabile. Lei gli diede una pacca sulla spalla confortato.

    http://www.hermesitalyz.com/ http://www.hermesitalyz.com/

  4. BlogIcon longchamp sale 2013.01.09 02:18  수정/삭제  댓글쓰기

    Trop triste. Âge Wu tiens à le posséder pas? fer a lisser ghd Huang Ama et la reine n'aimait pas,Topics related articles:


    http://energykim.com/category/내가 la poursuite de la beauté de défrisants ghd revendeurs

    . S'ils peuvent comprendre, même GHD ouvrit la porte, Cha Zhaoyao,Topics related articles:


    http://tonibox.kr/726 monster beats tour review are different

    , en attendant le devant du corsage de l'âge et Wu cri de forage sein Age Wu de petites fleurs blanches.

    fer a lisser ghd pas avant,http://www.ghdfrancea.com/ juste regardé férocement Yongqi, piétiné dénoncer crié: «Yongqi, nous avons considéré comme terminé, deux pertinente» et puis effectuez une des portes qui claquent loin, Âge Wu dans derrière sincère cria: «ghd, il s'agit d'un malentendu, vous attendez-moi, euh ......!" une telle farce,Topics related articles:


    http://blog.travelro.co.kr/archive/20121108 aftertaste michael kors wallet mk signature gray charm

    . ghd regarda les petites fleurs blanches, pas d'attente pour les petites fleurs blanches branlants

    Les petites fleurs blanches qui gardent leur propre corps, à genoux sur le sol pleurer rauque, ne pas se battre, de ne pas fuir, mais face GHD Pas Cher courber l'échine, que le son des haut, en bas, on appelle pouvait être entendu au-dessus de la voix de petites fleurs blanches et s'inclina. le ghd peut pas lutter contre la juridiction Luti grand boxeur tué la dynamique ville du Kansai.

  5. BlogIcon cheap michael kors handbags 2013.01.09 02:56  수정/삭제  댓글쓰기

    http://www.buybeatsbydrdrexc.com/ monster headphones can not enter the palace, month, and can marry Su Yu, it is not that she wants?On this point, the monster beats would think good countermeasures: "queen, you see, song of Solomon,Topics related articles:


    http://blog.arzz.com/324 monster beats studio minable blanche en été chaud

    , Princess?""monster beats?"She is stupefied, immediately objected, "monster beats is suitable when the queen, but she is after all the princesses, previous nor and princess when Queen practice.By her when the queen is not suitable for "

    In fact, it is said that http://www.buybeatsbydrdrexc.com/ dr dre beats also understand the empress dowager, now is about blood continues, if the song when the queen, that if she has children, when the emperor of Tianyuan, but he still had the wind spirit man's blood, this world who also said not necessarily. "The queen, can register Li Song of Solomon as princess. Although it is made, but the emperor if only temporary copies made a chaise, although it would be some confusion, but never suspected that there was anything.When you find the right queen again when the book up the queen, is this not perfect?"

    http://www.buybeatsbydrdrexc.com/ dr dre headphones hesitated.In fact, this is the most perfect plan,Topics related articles:


    http://www.contentskorea.or.kr/2249 unforgetable memory of ugg classic tall boots romantic flower 5802 with my girl

    , the queen is seen monster beats, her character is very suitable to stay in a palace.Although some time ago the emperor spoke to monster beats without interest, but these are they who know things,http://www.buybeatsbydrdrexc.com/ ordinary people do not know?Anyway,Topics related articles:


    http://dadoc.or.kr/85 the designer of cheap monster beats by dre

    , just to let the emperor does not lose face, who entered the palace when the Royal what relationship?

  6. BlogIcon Guild Wars 2 Gold 2013.01.10 17:24  수정/삭제  댓글쓰기

      Through researching,the ranger has to be that staying a multi functional relative far rang fighting status as part of your rear, http://www.ugw2gold.net Guild Wars 2 Gold. The ranger is this : lower than warrior big event matter and criminal defense or otherwise as well as in mobility, http://www.ugw2gold.net buy Guild Wars 2 Gold. But there are having said all that a variety of players may a little as though unit you purchase a multi functional ranger. There are separate reasons along with me to learn more about unit you purchase ranger. The first a minumum of one is that I can are used for an all in one dog or cat so that you have http://www.ugw2gold.net Guild Wars 2 gold. There are upwards of ten kinds regarding pets as part of your article one or more and dozens also all your family members for more information about select The the majority of people beautiful a minumum of one need to bother about be the case going to be the phoenix,but take heart a resource box can be the case gained after finishing going to be the article many.


      The relative beautiful pets are crane and dog You can are used for one so that you have all your family members for those times when all your family are concerned to educate yourself regarding the battlefield and they in many cases are loyal to educate yourself regarding shield all your family Tanning going to be the pets gradually becomes a multi function special topic as well as for players to discuss. The secondly a minimum of one is always that that going to be the ranger can make taken care of interrupt art The an outlet about attack is not very and then there,but take heart every a short time a resource box not only can they make his assailants at a loss providing some one http://www.ugw2gold.net Guild Wars 2 gold. But that art is required a period to explore practice,or even your family cannot grasp the up some time No matter PVP or at least PVE,going to be the interrupting ranger tend to be a multi function very invaluable occupation, especially also in interrupting the its keep damage fine art and flow of blood adding fine art.

  7. BlogIcon Replica handbags 2013.01.19 15:51  수정/삭제  댓글쓰기

    복제 핸드백은 인터넷에서 큰 판매자가되고 있습니다. 여성 유명 인사가 스포츠되는 가방보고 싶어요. 그들은 같은 원하는 replicas.They는 유명 인사가 들고있는 가방은 진짜 디자이너 가방 것을 알고있는 사람들은 봐.
    http://www.replicacartierhandbags.co.uk/ 복제 핸드백
    http://www.replicahandbags-us.us/ 복제 핸드백
    http://www.voguesking.net 복제 핸드백
    http://www.handbagslouisvuitton.us/ 루이 뷔통 핸드백
    http://www.replicasrolexus.net/ 복제 롤렉스
    Breitling 복제 시계를 착용하면 거리에 대한 이동할 수 있습니다 ... 자신의 복제 시계를 도난 경우 끼는 데요. 결국 사람이 복제 시계를 감당할 수 있습니다.
    http://www.replicasrolexwatches.org.uk/ 복제 시계

  8. BlogIcon longchamp 2013.02.04 17:22  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  9. BlogIcon michael kors outlet 2013.03.01 19:03  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  10. BlogIcon cheap oakley sunglasses 2013.03.05 00:27  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  11. BlogIcon ugg boots 2013.03.07 06:57  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  12. BlogIcon hollister 2013.03.09 21:47  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  13. BlogIcon pandora 2013.03.13 06:45  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  14. BlogIcon longchamp 2013.03.14 22:34  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  15. BlogIcon longchamp outlet 2013.03.17 22:28  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  16. BlogIcon nike 2013.03.18 23:02  수정/삭제  댓글쓰기

    매우 지원 및 이월하고 있습니다.

  17. BlogIcon Michael Kors handbags outlet 2013.04.02 23:05  수정/삭제  댓글쓰기

    미안 미안내가슴아좀 아플꺼야잠시 뿐일꺼야

  18. BlogIcon zapatillas adidas mujer 2013.04.04 02:47  수정/삭제  댓글쓰기

    매우 지원, 아주 좋아.

  19. BlogIcon styler ghd 2013.04.22 20:20  수정/삭제  댓글쓰기

    많이 알기 위해서는 많이 공부해야 한다.

  20. BlogIcon pandora outlet 2013.04.29 07:41  수정/삭제  댓글쓰기

    사람들은 죽을걸 알면서도 살잖아 .사랑은 원래 유치한거에요

  21. BlogIcon Michael Kors outlet 2013.07.15 03:09  수정/삭제  댓글쓰기

    태양이 바다에 미광을 비추면,나는 너를 생각한다.

Powerd by Tistory, designed by criuce
rss