{"id":1345,"date":"2012-09-11T08:38:00","date_gmt":"2012-09-11T07:38:00","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=1345"},"modified":"2012-09-11T08:39:55","modified_gmt":"2012-09-11T07:39:55","slug":"nullable-tipusok-attributumokban","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2012\/09\/11\/nullable-tipusok-attributumokban\/","title":{"rendered":"Nullable t\u00edpusok attributumokban"},"content":{"rendered":"<p>CLR attributumokban sajnos nem lehet haszn\u00e1lni nullable t\u00edpusokat, mivel ezeket metaadatk\u00e9nt t\u00e1rolja el a compiler, \u00e9s az nincs felk\u00e9sz\u00edtve strukt\u00far\u00e1kra. Igaz\u00e1b\u00f3l m\u00e9g a decimalt sem eszi, ami el\u00e9g bosszant\u00f3, ez az\u00e9rt belef\u00e9rhetett volna.<br \/>\nMost m\u00e9gis kellett nullable \u00e9s r\u00e1ad\u00e1sul decimal att param, \u00edgy ker\u00fcltem ki:<\/p>\n<p>public class SteppingSpecificationAttribute : Attribute<br \/>\n{<br \/>\n    private double increment;<br \/>\n    private double startValue;<br \/>\n    private double endValue;<\/p>\n<p>    public SteppingSpecificationAttribute(double defaultValue)<br \/>\n    {<br \/>\n        DefaultValue = defaultValue;<br \/>\n    }<\/p>\n<p>    public bool HasValueIncrement { get; private set; }<br \/>\n    public bool HasValueStartValue { get; private set; }<br \/>\n    public bool HasValueEndValue { get; private set; }<\/p>\n<p>    public double Increment<br \/>\n    {<br \/>\n        get { return increment; }<br \/>\n        set<br \/>\n        {<br \/>\n            increment = value;<br \/>\n            HasValueIncrement = true;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    public double StartValue<br \/>\n    {<br \/>\n        get { return startValue; }<br \/>\n        set<br \/>\n        {<br \/>\n            startValue = value;<br \/>\n            HasValueStartValue = true;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    public double EndValue<br \/>\n    {<br \/>\n        get { return endValue; }<br \/>\n        set<br \/>\n        {<br \/>\n            endValue = value;<br \/>\n            HasValueEndValue = true;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    public double DefaultValue { get; set; }<br \/>\n}<\/p>\n<p>Nem eleg\u00e1ns, de m\u0171k\u00f6dik. Valakinek van jobb \u00f6tlete?<\/p>\n<p>K\u00e9s\u0151bb, amikor kiveszem a property-k \u00e9rt\u00e9k\u00e9t, akkor n\u00e9zem meg, mi null \u00e9s mi nem, valamint akkor konvert\u00e1lok decimalra. A double-decimal konverzi\u00f3 okozhat adatveszt\u00e9st, de ismerem milyen sz\u00e1mok mennek be, ezekkel nincs ilyen gond.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CLR attributumokban sajnos nem lehet haszn\u00e1lni nullable t\u00edpusokat, mivel ezeket metaadatk\u00e9nt t\u00e1rolja el a compiler, \u00e9s az nincs felk\u00e9sz\u00edtve strukt\u00far\u00e1kra. Igaz\u00e1b\u00f3l m\u00e9g&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,10,4],"tags":[],"class_list":["post-1345","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-szakmai-elet"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1345"}],"version-history":[{"count":3,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1345\/revisions"}],"predecessor-version":[{"id":1347,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1345\/revisions\/1347"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}