プロパティを検証するコード @MVVM

投稿日 : 2009年2月25日 20:01

 今朝 通勤途中、紙のMSDNマガジン(英語)を読んでいたのだけど(あまり読めないので(英語的な意味で)内容がどんなのあるか確認する程度)、WPF MVVMパターン良さそうですね → WPF のための MODEL-VIEW-VIEWMODEL (MVVM) デザイン パターン すでにkazukiさんがエントリされてました(流石)→ [WPF][C#]Model View ViewModelパターンでハローワールド

 パターンとは少し関係ないかもだけど、記事中のプロパティを検証するコードが良い感じですね。INotifyPropertyChangedインターフェースを使うと、プロパティ名を文字列で扱うのでスペルミスしてしまうことがあるんですよね。それの対策コード。

Public Event PropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged

Public Sub OnPropertyChanged(ByVal propertyName As String)
    Me.VerifyPropertyName(propertyName)
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub

<Conditional("DEBUG"), DebuggerStepThrough()> _
Public Sub VerifyPropertyName(ByVal propertyName As String)
    If TypeDescriptor.GetProperties(Me)(propertyName) Is Nothing Then
        Dim msg As String = "Invalid property name: " & propertyName
        If Me.ThrowOnInvalidPropertyName Then
            Throw New Exception(msg)
        Else
            Debug.Fail(msg)
        End If
    End If
End Sub

Private privateThrowOnInvalidPropertyName As Boolean = True
Protected Overridable Property ThrowOnInvalidPropertyName() As Boolean
    Get
        Return privateThrowOnInvalidPropertyName
    End Get
    Set(ByVal value As Boolean)
        privateThrowOnInvalidPropertyName = value
    End Set
End Property

 

 詳しくは記事&コードで(まだ読んでない)。VB.NETでもコードサンプルが提供されていることに少し感動したw

Code for "WPF Apps With the Model-View-ViewModel Design Pattern" - Release: Initial Release

フィードバック

# re: プロパティを検証するコード @MVVM

2009/02/26 7:59 by T.Hirase
自分、Conditional("DEBUG") 属性にシビレました。
ここで使うのかって感じ。

# re: プロパティを検証するコード @MVVM

2009/02/26 20:27 by JZ5
コメありがとうございます。
しびれましたか。
私だと#IF DEBUGって書いちゃいそう。今度からはこれ使おう。

# ODtIkAqdJfbQQMficsp

2012/01/04 7:18 by http://www.kosherbeefjerky.com/
1aaxNo Informative, but not convincing. Something is missing but what I can not understand. But I will say frankly: bright and benevolent thoughts!...

# DrbetXsTCHGbGaXF

2014/08/06 22:18 by http://crorkz.com/
jPA7It I appreciate you sharing this post.Really looking forward to read more. Really Great.

# AoGmkrmEcRXnzCJj

2014/09/03 10:49 by http://ecommerce-for-business.com/marine-safety-eq
Hello! I've been following your website for a while now and finally got the courage to go ahead and give you a shout out from Humble Texas! Just wanted to mention keep up the excellent work!

# yMgwRROThcydQna

2014/09/06 21:55 by http://metrocontests.com
An fascinating dialogue is value comment. I feel that you must write extra on this topic, it won't be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers

# mtqPWuROAGcAZeh

2014/09/09 11:48 by http://vender-na-internet.com/luis-souto/
I enjoy, result in I found exactly what I used to be taking a look for. You've ended my four day long hunt! God Bless you man. Have a great day. Bye

# nouJkTqrVqHdfHwkpG

2014/09/10 21:17 by http://www.canadanobis.com
Very well written story. It will be useful to everyone who employess it, including me. Keep doing what you are doing - for sure i will check out more posts.

# vVRXqwpXScHeAfRoZWs

2014/09/11 19:50 by http://www.optimiseonline.com.au/
Usually I do not learn article on blogs, however I would like to say that this write-up very pressured me to check out and do so! Your writing taste has been amazed me. Thanks, very great article.

# GwNkAkTflzESeMLxIe

2014/09/11 21:14 by http://www.ukessays.com
This site is mostly a stroll-by way of for all the information you wished about this and didn't know who to ask. Glimpse here, and also you'll definitely uncover it.

# sPCBwlFaWxUP

2014/09/15 11:43 by http://www.theboatonlinestore.com/
Thanks for the auspicious writeup. It in fact used to be a enjoyment account it. Look advanced to far added agreeable from you! By the way, how could we keep up a correspondence?

# vgDmXnOdMZIO

2014/09/16 18:55 by https://www.youtube.com/watch?v=6BlpsZ7LHRQ
you have an incredible blog here! would you like to make some invite posts on my blog?

# XGRVWLluzUIqkiGM

2018/08/16 3:01 by http://www.suba.me/
ZgnooL I truly appreciate this article.Thanks Again. Keep writing.

# hQoirVtVmKEV

2018/08/18 2:47 by https://www.dropbox.com/s/fecz822n7ouqzkq/VA%20Loa
Some really select content on this site, saved to fav.

# nVPAOjfKmlcjDctLca

2018/08/19 3:49 by http://systemafrica52.jiliblog.com/15902849/good-t
Thanks for the auspicious writeup. It in reality was once a

# AnHZAeFSeVPshYGQeD

2018/08/19 4:54 by http://caldaro.space/story.php?title=hoc-bong-du-h
I truly appreciate this post. I ave been looking everywhere for this! Thank goodness I found it on Bing. You ave made my day! Thx again!

# mlwgeSoDdpQimLFQfWQ

2018/08/20 15:51 by https://www.yelp.co.uk/biz/instabeauty-cambridge
The sketch is tasteful, your authored material stylish.

# HVwGPcyxsyJBWDb

2018/08/21 23:12 by https://lymiax.com/
This unique blog is without a doubt entertaining and factual. I have picked many handy tips out of this source. I ad love to go back over and over again. Thanks a lot!

# vhICBqXkOpd

2018/08/22 4:35 by http://mearkidsandteens.online/story/35891
Very good article.Really looking forward to read more. Fantastic.

# FjpTVMdXsTKE

2018/08/22 23:07 by https://www.floridasports.club/members/loafgram0/a
Wanted to drop a remark and let you know your Feed isnt working today. I tried including it to my Google reader account but got nothing.

# GgwSajLGAHQCXCCx

2018/08/23 14:03 by http://high-mountains-tourism.com/2018/08/19/get-p
space to unravel my problem. May be that as you! Looking forward to look you.

# nvlwHhSJZsgT

2018/08/23 16:37 by http://whitexvibes.com
Its hard to find good help I am forever proclaiming that its hard to get good help, but here is

# bJQmTERkHabrfoogb

2018/08/23 19:06 by https://www.christie.com/properties/hotels/a2jd000
this I have discovered It absolutely useful and it has aided me out loads.

# TbAkaNIAYDkDFThA

2018/08/23 21:35 by http://severina.xyz/story.php?title=agen-sbobet-75
Some genuinely quality posts on this web site , saved to my bookmarks.

# arGFGkemwOCCVvHECB

2018/08/24 9:56 by http://prodonetsk.com/users/SottomFautt541
Thanks a lot for the article post.Much thanks again. Awesome.

# cIapVKGtZGuVaEySpd

2018/08/24 16:28 by https://www.youtube.com/watch?v=4SamoCOYYgY
Wonderful post! We are linking to this particularly great post on our website. Keep up the great writing.

# CXEXosEcEFvlqGlo

2018/08/27 20:15 by https://www.prospernoah.com
There is certainly a great deal to learn about this issue. I really like all of the points you ave made.

# DrxnpuatlYgH

2018/08/27 23:42 by http://demo.socia.us/blog/view/11883/how-to-get-yo
very good submit, i actually love this web site, carry on it

# drYmCKsTijdPsFkzdj

2018/08/28 0:27 by https://www.scribd.com/user/421937125/subsmautithe
Spot on with this write-up, I actually feel this website needs a lot more attention. I all probably be back again to see more, thanks for the info!

# XGxaZznUkhCvCRdxtX

2018/08/28 1:08 by https://www.off2holiday.com/members/arearifle06/ac
in the near future. Take a look at my website as well and let me

# KppPqDWKbYM

2018/08/28 1:44 by https://www.off2holiday.com/members/wealthmelody8/
Really appreciate you sharing this blog.Thanks Again. Really Great.

# tBdFyRwLgRFThSG

2018/08/28 2:46 by https://khoisang.vn/members/pikezebra5/activity/27
There as definately a great deal to learn about this issue. I really like all the points you made.

# oHtQDYBCCkXsNVzpJ

2018/08/28 5:50 by http://we-insurance.xyz/story.php?id=34915
Im obliged for the blog article.Really looking forward to read more. Really Great.

# zmcHnezgBpxEP

2018/08/28 10:57 by http://metallom.ru/board/tools.php?event=profile&a
This website truly has all the information I wanted about this subject and didn at know who to ask.

# oRjRNPwaRlHQipM

2018/08/28 22:16 by https://www.youtube.com/watch?v=4SamoCOYYgY
It as actually a great and useful piece of info. I am happy that you simply shared this useful info with us. Please stay us up to date like this. Thanks for sharing.

# XHZHcobzyFZAMH

2018/08/29 1:34 by http://www.authorstream.com/dextconpipia/
This is a good tip especially to those new to the blogosphere. Brief but very precise information Appreciate your sharing this one. A must read post!

# tCECgBfgevqd

2018/08/29 3:59 by http://ihourdesing.world/story/37881
I was suggested this blog by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem. You are amazing! Thanks!

# LTcsZaUpYzVZCgB

2018/08/29 19:54 by https://www.zotero.org/trucininis
Thanks for some other great post. Where else may anybody get that kind of information in such an ideal method of writing? I ave a presentation next week, and I am at the look for such information.

# wubbClnEWdpczNLCKtG

2018/08/29 21:39 by https://socialbusinessworld.org/blog/view/1067897/
I simply couldn at depart your web site prior to suggesting that I really enjoyed the

# UzAYSIFSwFYSqj

2018/08/30 3:09 by https://youtu.be/j2ReSCeyaJY
Really enjoyed this post.Much thanks again. Much obliged.

# bUCmtelMkiPFy

2018/08/30 19:50 by http://findhelmet19.host-sc.com/2018/08/30/importa
This is my first time pay a visit at here and i am really impressed to read all at alone place.

# HyJalbofTrpHSwdCiy

2018/08/30 22:10 by http://westernauctionco.com/idaho-irrigation-equip
Incredible! This blog looks just like my old one! It as on a totally different topic but it has pretty much the same page layout and design. Excellent choice of colors!

# TZRNXfGlEXynoszH

2018/08/31 18:47 by http://www.kamecon.org/app_form/367510
You have brought up a very superb details , thanks for the post.

# wyxPhklNjcDUFZDIM

2018/09/01 10:57 by http://banki59.ru/forum/index.php?showuser=2419934
Womens Ray Ban Sunglasses Womens Ray Ban Sunglasses

# wsqaAJqPaSLSgkRdHz

2018/09/01 19:59 by http://sla6.com/moon/profile.php?lookup=284558
Thanks for the article post.Really looking forward to read more. Great.

# nzTMHnsKVaGt

2018/09/01 22:32 by http://filmux.eu/user/agonvedgersed939/
You have brought up a very wonderful points , thankyou for the post.

# hESwyGGcnjW

2018/09/02 21:06 by https://topbestbrand.com/&#3610;&#3619;&am
Many thanks! Exactly where are your contact details though?

# MfQVBoHPJVYlPc

2018/09/03 19:42 by http://www.seoinvancouver.com/
time here at web, however I know I am getting knowledge all the time by

# cKYqmjYjHsOPPPqZuvx

2018/09/05 0:34 by http://solphia.com/community/blog/view/162865/the-
much healthier than its been in some time. Manning,

# cPqReQmwDRWDss

2018/09/05 6:29 by https://www.youtube.com/watch?v=EK8aPsORfNQ
Wow, superb weblog layout! How lengthy have you been running a

# CyhvkxiFvpYZppdrWMM

2018/09/06 17:02 by https://chillrhythm7.asblog.cc/2018/09/04/flexible
There is definately a lot to learn about this issue. I like all of the points you have made.

# lUFKqujWUYa

2018/09/10 18:10 by https://www.youtube.com/watch?v=kIDH4bNpzts
What as up, I just wanted to say, I disagree. Your point doesn at make any sense.

# afjREIimOOeA

2018/09/12 0:54 by https://weedgoat99.crsblog.org/2018/09/09/history-
really excellent post, i undoubtedly actually like this incredible web-site, go on it

# MARyVvFMYf

2018/09/12 16:11 by https://www.wanitacergas.com/produk-besarkan-payud
You ave made some decent points there. I looked on the web for additional information about the issue

# RiznHLMCGxbZnDna

2018/09/12 19:24 by http://traveleverywhere.org/2018/09/11/buruan-daft
Major thankies for the post.Much thanks again. Want more.

# osOjChPIwWtjrIxjx

2018/09/13 0:12 by https://www.youtube.com/watch?v=EK8aPsORfNQ
Really informative blog article.Really looking forward to read more. Really Great.

# LhoIdPuVgWpuvF

2018/09/13 1:46 by https://www.youtube.com/watch?v=5mFhVt6f-DA
wonderful points altogether, you simply gained a brand new reader. What might you recommend in regards to your publish that you simply made a few days in the past? Any positive?

# hkPbSLIExmUkRoY

2018/09/13 6:27 by http://bolnysha.ru/?option=com_k2&view=itemlis
moment this time I am browsing this website and reading very informative

# WkNScyOArijT

2018/09/13 11:10 by https://customwindowinstallationnyc.my-free.websit
Thanks , I ave recently been searching for information approximately this subject for a long

# sSEoXVQtQt

2018/09/14 23:48 by http://www.authorstream.com/spiricosur/
This is my first time go to see at here and i am really happy to read everthing at alone place.|

# qlTIvxnjrjyBxXpamw

2018/09/15 4:01 by http://blogcatalog.org/story.php?title=ezvitalityh
wow, awesome article post.Thanks Again. Want more.

# FfIAhMBEBncPhzoPW

2018/09/17 20:30 by http://www.dfwwow.com/stradhatter/members/heavenge
Im obliged for the blog.Really looking forward to read more. Really Great.

# lAGZuxHFENhHFY

2018/09/18 4:18 by https://tabletennis4u.wordpress.com/
This actually answered my problem, thanks!

# LNgfZeDAgKbZkM

2018/09/20 1:27 by https://victorspredict.com/
JAPAN JERSEY ??????30????????????????5??????????????? | ????????

# mUopRBARfJqzfUobtZo

2018/09/20 9:59 by https://www.youtube.com/watch?v=XfcYWzpoOoA
Wow, great article post.Thanks Again. Fantastic.

# IjucKGCWNNZCa

2018/09/21 19:20 by https://www.youtube.com/watch?v=rmLPOPxKDos
When Someone googles something that relates to one of my wordpress blogs how can I get it to appear on the first page of their serach results?? Thanks!.

# lzvwIlXYrURT

2018/09/24 21:57 by http://areinvesting.online/story/40620
I think this is one of the most important information for me.

# KqmpCaiedGucnpPB

2018/09/26 0:57 by http://immensewise.com/story.php?title=remove-stre
tiffany rings Secure Document Storage Advantages | West Coast Archives

# VQlvHJyYGKTZMGO

2018/09/26 14:06 by https://digitask.ru/
This website certainly has all of the info I wanted about thus subject aand didn at know who

# vyeBcjkYUxvpNqBQ

2018/09/26 18:44 by http://blockotel.com/
Looking forward to reading more. Great blog.Really looking forward to read more. Want more.

# zaFSbqfkJNq

2018/09/28 1:53 by http://www.globalintelhub.com
What as Happening i am new to this, I stumbled upon this I ave found It absolutely helpful and it has helped me out loads. I hope to contribute & aid other users like its helped me. Good job.

# agsuHiHiFjnrqbGuIF

2018/10/01 23:58 by http://joomla.kamptec.de/index.php?option=com_blog
You ave made some good points there. I looked on the internet for more information about the issue and found most individuals will go along with your views on this site.

# wByCwPmRtMNnAS

2018/10/02 19:00 by https://www.youtube.com/watch?v=kIDH4bNpzts
Whoa! This blog looks just like my old one! It as on a entirely different subject but it has pretty much the same page layout and design. Great choice of colors!

# tyMlwCKpot

2018/10/02 22:08 by http://www.pickmeweb.com/info/instagram_reseller_p
Loving the info on this website , you have done outstanding job on the blog posts.

# pLRKejKwBnPFZDHWdpo

2018/10/06 4:52 by https://www.premedlife.com/members/coffeecoke2/act
I would really like you to turn out to be a guest poster on my blog.-; a-

# YPiRweDQskG

2018/10/07 20:23 by http://kliqqi.xyz/story.php?title=van-phong-cho-th
Im thankful for the article.Thanks Again. Much obliged.

# XaLKBbDFss

2018/10/07 22:01 by https://northcoastvolleyball.org/elgg2/blog/view/6
It as hard to search out knowledgeable folks on this matter, but you sound like you recognize what you are talking about! Thanks

# TwZaJrGTIjwRv

2018/10/08 3:12 by https://www.youtube.com/watch?v=vrmS_iy9wZw
Tiffany Jewelry Secure Document Storage Advantages | West Coast Archives

# oKTJMKHsFnop

2018/10/08 12:21 by https://www.jalinanumrah.com/pakej-umrah
motorcycle accident claims What college-university has a good creative writing program or focus on English?

# youetQLemaLgZuY

2018/10/08 15:09 by https://www.jalinanumrah.com/pakej-umrah
That is a very good tip especially to those fresh to the blogosphere. Brief but very precise information Thanks for sharing this one. A must read post!

# dTUZwQQDDhYqth

2018/10/09 8:15 by https://izabael.com/
you continue this in future. A lot of people will be benefited from your writing.

# EKMPssosuudO

2018/10/09 10:08 by https://occultmagickbook.com/on-the-difficulty-lev
loans will be the method where you will get your cash.

# JiDSiweiHXjAh

2018/10/09 14:49 by http://concours-facebook.fr/story.php?title=phuket
Thanks again for the blog.Thanks Again. Much obliged.

# OdIniItXXcMMT

2018/10/09 17:27 by https://streamauthor68.phpground.net/2018/10/06/sp
I think this is a real great blog article. Keep writing.

# TKmVOrLfOW

2018/10/09 19:36 by https://www.youtube.com/watch?v=2FngNHqAmMg
Please forgive my English.Wow, fantastic blog layout! How lengthy have you been running a blog for? you made blogging glance easy. The entire look of your website is fantastic, let alone the content!

# wDnreqOrOdFKqLNUdq

2018/10/10 1:08 by http://genie-demon.com/
you have a great weblog right here! would you like to make some invite posts on my weblog?

# BkrnRGfIOPaIO

2018/10/10 3:21 by http://couplelifegoals.com
What as up, just wanted to mention, I enjoyed this post. It was funny. Keep on posting!

# WotwnUzoagmsCquDPLq

2018/10/10 9:09 by https://www.sparknotes.com/account/jihnxx001
wow, awesome post.Really looking forward to read more. Will read on...

# zxwMJtEVrCTPLmWp

2018/10/10 15:06 by https://yourmoneyoryourlife.com/members/hammerguit
This is a great tip especially to those fresh to the blogosphere. Brief but very precise information Appreciate your sharing this one. A must read article!

# EeZRjpTTNAQwTUSIdM

2018/10/10 19:01 by https://123movie.cc/
pretty practical stuff, overall I consider this is worth a bookmark, thanks

# jSsorjYiTBj

2018/10/11 0:57 by http://odbo.biz/users/MatPrarffup533
Perfectly composed articles, Really enjoyed studying.

# VlmzdOaLJeoxMm

2018/10/11 17:22 by http://blog.hukusbukus.com/blog/view/102275/downlo
Very neat post.Really looking forward to read more. Much obliged.

# sqEgijTwzCQwTPMiJ

2018/10/11 18:34 by https://www.minds.com/blog/view/896259450586300416
Im obliged for the article.Really looking forward to read more. Much obliged.

# HfDRCpbSJqgh

2018/10/13 7:29 by https://www.youtube.com/watch?v=bG4urpkt3lw
Wow, awesome blog layout! How lengthy have you been blogging for? you make blogging look easy. The entire look of your website is magnificent, let alone the content material!

# qXutFXefRngzjaDyEoe

2018/10/13 13:15 by https://www.peterboroughtoday.co.uk/news/crime/pet
you heard about this new site ? Dallas SEO

# CsoURTzeqkKCfYuzAJ

2018/10/13 16:19 by https://getwellsantander.com/
will be back to read a lot more, Please do keep up the awesome

# dJYhbAizkUpw

2018/10/13 22:07 by https://telegra.ph/What-Is-Airdrop-Cryptocurrency-
Pretty! This has been an incredibly wonderful article. Many thanks for providing this info.

# qJzxdMIrfRglOm

2018/10/14 13:57 by http://www.costidell.com/forum/member.php?action=p
That is a good tip particularly to those fresh to the blogosphere. Brief but very precise info Appreciate your sharing this one. A must read post!

# hellow dude

2019/01/06 18:19 by RandyLub
hello with love!!
http://imlgrpllc.org/__media__/js/netsoltrademark.php?d=www.301jav.com/ja/video/8440757373576929479/

# Air Jordan 12 Gym Red

2019/04/13 3:08 by tunoaws@hotmaill.com
txyexi,If you want a hassle free movies downloading then you must need an app like showbox which may provide best ever user friendly interface.

# Yeezy

2019/04/21 9:23 by uxowbjw@hotmaill.com
the Provincial Civil Affairs Department, the Provincial Poverty Alleviation Office, the Provincial Development and Reform Commission, the Provincial Finance Department, and the Provincial Disabled Persons' Federation have gone to Baicheng. , went to Weinan City for a field investigation.

# Pandora Official Site

2019/04/23 13:53 by zomxqa@hotmaill.com
Dalio said that capitalism has developed into a system that promotes the widening gap between the rich and the poor, thus leaving the United States at risk of survival. Dalio published a two-part series on the professional social networking site, pointing out that capitalism is now in urgent need of reform and proposed a reform approach.

# Nike React Element 87

2019/04/26 1:29 by rdsdzahe@hotmaill.com
The Zoom Alpha from 1995 unfortunately falls in that category, but those in the know have been keeping their eyes peeled on what Swoosh plans to do with the first-ever Zoom cushioning running shoe in history.

# re: ??????????????@MVVM

2021/08/07 10:45 by hydroxychloroquine sulfate 200mg
is chloroquine available over the counter https://chloroquineorigin.com/# hydroxycloquine
コメントの入力
タイトル
名前
Url
コメント