{"id":471,"date":"2022-05-19T07:59:09","date_gmt":"2022-05-18T22:59:09","guid":{"rendered":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=471"},"modified":"2022-05-19T07:59:09","modified_gmt":"2022-05-18T22:59:09","slug":"net-reflection","status":"publish","type":"post","link":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=471","title":{"rendered":".NET Reflection"},"content":{"rendered":"\n<p>.NET\u306b\u3057\u308dJava\u306b\u3057\u308d\u3001\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u306e\u306f\u3001\u3042\u307e\u308a\u5b9f\u884c\u6642\u306e\u52b9\u7387\u304c\u826f\u304f\u306a\u3044\u306e\u3060\u308d\u3046\u304c\u3001\u547c\u51fa\u56de\u6570\u304c\u591a\u304f\u306a\u3051\u308c\u3070\u3001\u305d\u308c\u307b\u3069\u6c17\u306b\u306a\u3089\u306a\u3044\u3002<\/p>\n\n\n\n<p>\u79c1\u306e\u5834\u5408\u3001\u3069\u3093\u306a\u3068\u304d\u306b\u4f7f\u3046\u304b\u3068\u3044\u3046\u3068\u3001\u30af\u30e9\u30b9\u3092\u7279\u5b9a\u3057\u306a\u3044\u3001\u30b3\u30f3\u30d0\u30fc\u30bf\u30fc\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u306b\u4f7f\u7528\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001CSV\u3068\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u3001\u30af\u30e9\u30b9\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306bCSV\u306e\u9805\u76ee\u3092\u52d5\u7684\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u305b\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u4f7f\u7528\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-html\" data-file=\"\u30de\u30c3\u30d4\u30f3\u30b0\u5b9a\u7fa9\" data-lang=\"HTML\"><code>&lt;!--\n\t\u30de\u30c3\u30d4\u30f3\u30b0\u5b9a\u7fa9\n\tColumn -- CSV\u30ab\u30e9\u30e0\n\t\tIndex : \u30ab\u30e9\u30e0\u4f4d\u7f6e\n\t\tMapProperty : \u8a2d\u5b9a\u3059\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\n\t\tFuncName : \u5909\u63db\u30e1\u30bd\u30c3\u30c9\n--&gt;\n&lt;Mapping OutputColumns=&quot;5&quot;&gt;\n  &lt;Column Index=&quot;0&quot; MapProperty=&quot;EmpNo&quot; FuncName=&quot;ConvertEmpNo&quot;\/&gt;\n  &lt;Column Index=&quot;1&quot; MapProperty=&quot;ExecDate&quot; \/&gt;\n\t\u30fb\u30fb\u30fb\n&lt;\/Mapping&gt;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u6307\u5b9a\u30af\u30e9\u30b9\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5024\u3092\u30bb\u30c3\u30c8\" data-lang=\"C#\"><code>\/\/\/ &lt;summary&gt;\n\/\/\/ \u30af\u30e9\u30b9\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078\u306e\u5024\u30bb\u30c3\u30c8(Reflection\u7248)\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;instance&quot;&gt;\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;prop&quot;&gt;\u30d7\u30ed\u30d1\u30c6\u30a3\u60c5\u5831&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;value&quot;&gt;\u5024&lt;\/param&gt;\n\/\/\/ &lt;typeparam name=&quot;U&quot;&gt;\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u578b&lt;\/typeparam&gt;\npublic static void SetProp&lt;U&gt;(U instance, string prop, object value) {\n    var p = typeof(U).GetProperty(prop);\n    if (p == null) {\n        throw new ArgumentException($&quot;\u30af\u30e9\u30b9\u300c{typeof(U).ToString()}\u300d\u306b\u306f\u30d7\u30ed\u30d1\u30c6\u30a3{prop}\u304c\u5b58\u5728\u3057\u307e\u305b\u3093&quot;);\n    }\n    p!.SetValue(instance,value);\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u3001FuncName\u306e\u30e1\u30bd\u30c3\u30c9\u3082\u540c\u69d8\u306bReflection\u3092\u4f7f\u7528\u3057\u3066\u547c\u3073\u51fa\u3059\u3002<\/p>\n\n\n\n<p>\u4ed6\u306bExpression\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308b\u306e\u3060\u304c\u3001\u5f0f\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u7269\u3092\u3069\u3053\u304b\u306b\u4fdd\u5b58\u3057\u306a\u3044\u5834\u5408\u306fReflection\u306e\u65b9\u304c\u307e\u3060\u52b9\u7387\u304c\u826f\u3044\u304b\u306a\u3068\u30fb\u30fb\u30fb<\/p>\n\n\n\n<p>\u307e\u3041\u3001\u30c7\u30fc\u30bf\u6570\u304c\u305d\u308c\u307b\u3069\u591a\u304f\u306a\u3051\u308c\u3070\u5b9f\u884c\u901f\u5ea6\u306f\u3042\u307e\u308a\u6c17\u306b\u306a\u3089\u306a\u3044\u7a0b\u5ea6\u3002\u4f5c\u308a\u3084\u3059\u3055\u3084\u4f5c\u6210\u6642\u9593\u3068\u5b9f\u884c\u6642\u9593\u3068\u306e\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u304b\u306a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>.NET\u306b\u3057\u308dJava\u306b\u3057\u308d\u3001\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u306e\u306f\u3001\u3042\u307e\u308a\u5b9f\u884c\u6642\u306e\u52b9\u7387\u304c\u826f\u304f &hellip; <a href=\"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=471\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,9,4],"tags":[],"class_list":["post-471","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-4"],"_links":{"self":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=471"}],"version-history":[{"count":3,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":474,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/471\/revisions\/474"}],"wp:attachment":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}