{"id":931,"date":"2017-02-12T14:46:51","date_gmt":"2017-02-12T05:46:51","guid":{"rendered":"http:\/\/okamurax.com\/?p=931"},"modified":"2020-05-05T01:03:16","modified_gmt":"2020-05-04T16:03:16","slug":"c-flyweight","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=931","title":{"rendered":"C# Flyweight"},"content":{"rendered":"<pre class=\"lang:c# decode:true  \">namespace ConsoleApplication2\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n\r\n        }\r\n    }\r\n\r\n    \/* Flyweight \r\n    \u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30af\u30e9\u30b9(\u30d5\u30a3\u30fc\u30eb\u30c9\u5024\u304c\u4e0d\u5909\u306e\u3088\u3046\u306a)\u3092\u518d\u5229\u7528\u3059\u308b\u3002 *\/\r\n\r\n    public class Flyweight{ }\r\n\r\n    public class FlyweightFactory\r\n    {\r\n        private FlyweightFactory f = new FlyweightFactory();\r\n        private FlyweightFactory(){ }\r\n\r\n        private System.Collections.Generic.Dictionary&lt;int,Flyweight&gt; dic = new System.Collections.Generic.Dictionary&lt;int, Flyweight&gt;();\r\n\r\n        public FlyweightFactory GetInstance()\r\n        {\r\n            return f;\r\n        }\r\n\r\n        public Flyweight GetFlyweight(int key)\r\n        {\r\n            Flyweight f = dic[key];\r\n            if(f == null)\r\n            {\r\n                f = new Flyweight();\r\n                dic.Add(key, f);\r\n            }\r\n            return f;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>namespace ConsoleApplication2 { class Program { static void Main(string[] args) { } } \/* Flyweight \u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30af\u30e9\u30b9 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=931\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# Flyweight&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9,144],"class_list":["post-931","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net","tag-144"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=931"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/931\/revisions"}],"predecessor-version":[{"id":932,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/931\/revisions\/932"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}