{"id":118,"date":"2008-01-26T00:37:31","date_gmt":"2008-01-25T15:37:31","guid":{"rendered":"http:\/\/dev.activebasic.com\/egtra\/?p=118"},"modified":"2015-05-05T20:31:40","modified_gmt":"2015-05-05T11:31:40","slug":"unbound%e3%81%aadelegate","status":"publish","type":"post","link":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/","title":{"rendered":"Unbound\u306aDelegate"},"content":{"rendered":"<p>\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002<\/p>\n<p>C++\/CLI\u306b\u306fUnbound delegate\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u3001this\u3092\u7b2c\u4e00\u5f15\u6570\u306b\u6301\u3063\u3066\u304d\u305f\u5f62\u306e\u30c7\u30ea\u30b2\u30fc\u30c8\u3092\u8a8d\u3081\u3066\u3044\u307e\u3059\u3002 &#8211; \u53c2\u8003: <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ms177195(v=vs.90).aspx\">Unbound Delegates<\/a> &#8211; Visual C++ Language Reference (MSDN Library)\u3002\u4f55\u304c\u8a00\u3044\u305f\u3044\u304b\u3068\u3044\u3046\u3068\u3001<a href=\"http:\/\/d.hatena.ne.jp\/NyaRuRu\/20080125\/p2\">\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30e1\u30bd\u30c3\u30c9\uff0cthis, \u30c7\u30ea\u30b2\u30fc\u30c8\u3078\u306e\u675f\u7e1b\u53ef\u80fd\u6027 &#8211; NyaRuRu\u306e\u65e5\u8a18<\/a>\u3001\u305d\u306e\u30b3\u30fc\u30c9\u3001C++\/CLI\u3067\u306f\u3001\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u308f\u305a\u3068\u3082\u66f8\u3051\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u3068\u3053\u308d\u3069\u3053\u308d\u9069\u5f53\u306b\u66f8\u304d\u63db\u3048\u3066\u3001\u540c\u3058\u51fa\u529b\u3068\u306a\u308b\u30b3\u30fc\u30c9\u306b\u306a\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u51fa\u529b\u306f\u3088\u308d\u3057\u304f\u5bdf\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre lang=\"cpp\">using System::String;\r\n\r\nref class Foo\r\n{\r\npublic:\r\n\tproperty String^ Name;\r\n\tString^ GetStr(int)\r\n\t{\r\n\t\tif (this != nullptr)\r\n\t\t\treturn String::Format(\"My name is {0}\", this->Name);\r\n\t\telse\r\n\t\t\treturn String::Format(\"this is null!\");\r\n\t}\r\n\r\n\tvirtual String^ ToString() override\r\n\t{\r\n\t\treturn \"I'm Foo\";\r\n\t}\r\n};\r\n\r\ndelegate String^ GetStrDelegate(Foo^, int);\r\n\r\nint main()\r\n{\r\n\tusing namespace System;\r\n\r\n\tFoo^ foo = gcnew Foo;\r\n\tfoo->Name = \"tekitou\";\r\n\r\n\t\/\/Unbound\u306a\u30c7\u30ea\u30b2\u30fc\u30c8\r\n\tGetStrDelegate^ f1 = gcnew GetStrDelegate(&Foo::GetStr);\r\n\r\n\tConsole::WriteLine(f1(foo, 1));\r\n\tConsole::WriteLine(f1(nullptr, 2));\r\n\r\n\t\/\/\u6bd4\u8f03\u7528\u306b\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u4f7f\u3063\u305f\u7248\r\n\tReflection::MethodInfo^ mi = Foo::typeid->GetMethod(\"GetStr\");\r\n\tGetStrDelegate^ f2 = dynamic_cast<GetStrDelegate^>(\r\n\t\tDelegate::CreateDelegate(GetStrDelegate::typeid, mi));\r\n\r\n\tConsole::WriteLine(f2(foo, 1));\r\n\tConsole::WriteLine(f2(nullptr, 0));\r\n\r\n\tConsole::WriteLine();\r\n\r\n\t\/\/\u4eee\u60f3\u30e1\u30bd\u30c3\u30c9\u7de8\r\n\ttypedef Func<Object^, String^> FN;\r\n\r\n\tFN^ toString = gcnew FN(&Object::ToString);\r\n\tConsole::WriteLine(toString(gcnew Object));\r\n\tConsole::WriteLine(toString(gcnew Foo));\r\n\treturn 0;\r\n}<\/pre>\n<p>VC++ 2008 EE\u3060\u3068VC#\u3068\u9055\u3044\u3001\u81ea\u5206\u3067System.Core.dll\u3092\u53c2\u7167\u3092\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002LINQ\uff08\u306e\u30af\u30a8\u30ea\u69cb\u6587\uff09\u304c\u4f7f\u3048\u306a\u3044\u8a00\u8a9e\u3060\u304b\u3089\u3067\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound delegate\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u3001this\u3092\u7b2c\u4e00\u5f15\u6570\u306b\u6301\u3063\u3066\u304d\u305f\u5f62\u306e\u30c7\u30ea\u30b2\u30fc\u30c8\u3092\u8a8d\u3081\u3066\u3044\u307e\u3059\u3002 &#8211; \u53c2\u8003: Unbound Delegat [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8,15],"tags":[259],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-dot-net","category-cpp-cli","tag-delegate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Unbound\u306aDelegate - \u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d<\/title>\n<meta name=\"description\" content=\"\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unbound\u306aDelegate - \u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d\" \/>\n<meta property=\"og:description\" content=\"\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/\" \/>\n<meta property=\"og:site_name\" content=\"\u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ysk.noh\" \/>\n<meta property=\"article:published_time\" content=\"2008-01-25T15:37:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-05-05T11:31:40+00:00\" \/>\n<meta name=\"author\" content=\"egtra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@egtra\" \/>\n<meta name=\"twitter:site\" content=\"@egtra\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"egtra\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/\",\"url\":\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/\",\"name\":\"Unbound\u306aDelegate - \u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d\",\"isPartOf\":{\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/#website\"},\"datePublished\":\"2008-01-25T15:37:31+00:00\",\"dateModified\":\"2015-05-05T11:31:40+00:00\",\"author\":{\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/#\/schema\/person\/8de756b2ff20b964f64594dfe8f18164\"},\"description\":\"\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound\",\"breadcrumb\":{\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\/\/dev.activebasic.com\/egtra\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unbound\u306aDelegate\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/#website\",\"url\":\"https:\/\/dev.activebasic.com\/egtra\/\",\"name\":\"\u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d\",\"description\":\"\u982d\u306e\u4e2d\u306e\u304b\u3051\u3089\u3002ActiveBasic\u3092\u4e2d\u5fc3\u306b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u8a71\u3092\u307c\u3061\u307c\u3061\u3068\u3002\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dev.activebasic.com\/egtra\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/dev.activebasic.com\/egtra\/#\/schema\/person\/8de756b2ff20b964f64594dfe8f18164\",\"name\":\"egtra\",\"sameAs\":[\"https:\/\/x.com\/egtra\"],\"url\":\"https:\/\/dev.activebasic.com\/egtra\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unbound\u306aDelegate - \u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d","description":"\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/","og_locale":"ja_JP","og_type":"article","og_title":"Unbound\u306aDelegate - \u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d","og_description":"\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound","og_url":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/","og_site_name":"\u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d","article_publisher":"https:\/\/www.facebook.com\/ysk.noh","article_published_time":"2008-01-25T15:37:31+00:00","article_modified_time":"2015-05-05T11:31:40+00:00","author":"egtra","twitter_card":"summary_large_image","twitter_creator":"@egtra","twitter_site":"@egtra","twitter_misc":{"\u57f7\u7b46\u8005":"egtra","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"1\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/","url":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/","name":"Unbound\u306aDelegate - \u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d","isPartOf":{"@id":"https:\/\/dev.activebasic.com\/egtra\/#website"},"datePublished":"2008-01-25T15:37:31+00:00","dateModified":"2015-05-05T11:31:40+00:00","author":{"@id":"https:\/\/dev.activebasic.com\/egtra\/#\/schema\/person\/8de756b2ff20b964f64594dfe8f18164"},"description":"\u305f\u3081\u8fbc\u3093\u3067\u3044\u305f\u30cd\u30bf\u306e1\u3064\u653e\u51fa\u3067\u3059\u3002 C++\/CLI\u306b\u306fUnbound","breadcrumb":{"@id":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dev.activebasic.com\/egtra\/2008\/01\/26\/118\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/dev.activebasic.com\/egtra\/"},{"@type":"ListItem","position":2,"name":"Unbound\u306aDelegate"}]},{"@type":"WebSite","@id":"https:\/\/dev.activebasic.com\/egtra\/#website","url":"https:\/\/dev.activebasic.com\/egtra\/","name":"\u30a4\u30b0\u30c8\u30e9\u30f3\u30b9\u306e\u982d\u306e\u4e2d","description":"\u982d\u306e\u4e2d\u306e\u304b\u3051\u3089\u3002ActiveBasic\u3092\u4e2d\u5fc3\u306b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u8a71\u3092\u307c\u3061\u307c\u3061\u3068\u3002","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dev.activebasic.com\/egtra\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/dev.activebasic.com\/egtra\/#\/schema\/person\/8de756b2ff20b964f64594dfe8f18164","name":"egtra","sameAs":["https:\/\/x.com\/egtra"],"url":"https:\/\/dev.activebasic.com\/egtra\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/posts\/118"}],"collection":[{"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":0,"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.activebasic.com\/egtra\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}