Filter Control for Visual Studio LightSwitch是MS开源的LS扩展,可以实现高级的用户自定义查询。可在http://code.msdn.microsoft.com/Filter-Control-for-Visual-90fb8e93下载,提供的是VB.NET的版本下载,不过也没关系,下载后自己编绎一下即可,不过在此之前,还要下载LightSwitch Extensibility Toolkit,请到此处下载http://visualstudiogallery.msdn.microsoft.com/0dfaa2eb-3951-49e7-ade7-b9343761e1d2。该工具主要为实现LS自定义扩展提供环境.
Filter Control 的使用教程可参考http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/22/Using-The-LightSwitch-Filter-Extension.aspx.在此就不多说了,现在我们要解决的是Filter Control本地化的问题,在下载版本安装到VS后,实际运行时效果如下:
大家可以看到Description, callType这二个框,这二个是数据实体的属性,对于我们来说,要的是设计实体时所定义的DisplayName,我想用户应该更习惯于使用中文,而不是E文吧,否则我估计软件很难卖。,其他的本地化操作,应该不难都可以在代码中直接找到。
对于VB.NET的语法有点了解,但都忘的差不多了,下面我把一开始进行调试实验的代码公开一下,写的比较烂。(没有LS的技术手册,对于对象运行时结构一无所知)
打开FilterControl.Client项目,找到FieldDefinition.vb,我们要做的修改就在这里。
Private Sub New(ByVal propDef As IEntityPropertyDefinition, ByVal currentDepth As Int32, ByVal maxDepth As Int32) 在此构造中定位到原始处理代码中,如下:
'get displayName
'Replace this with appropriate call in RTM
' Me.DisplayName = propDef.Name 这个地方就是处理查询条件显示名称的地方,请注释掉
下面是调试代码,不知VB.NET的Linq语法怎么写,,只能来个循环了。
For Each o As Microsoft.LightSwitch.Model.IAttribute In propDef.Attributes
MessageBox.Show(o.Class.ToString())
If o.Class.Name.ToLower = "displayname" Then
MessageBox.Show("Found DisplayName")
Dim dn As IDisplayNameAttribute
dn = DirectCast(o, Microsoft.LightSwitch.Model.IDisplayNameAttribute)
If dn Is Nothing Then
MessageBox.Show("Not DisplayName")
Me.DisplayName = propDef.Name
Else
MessageBox.Show(dn.Value)
Me.DisplayName = dn.Value
End If
End If
Next
通过观察对象运行实际情况判断出IDisplayNameAttribute,有了这个就好办了,这就是我们的中文名。功能基本达到,但通过反编译C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\LightSwitch\1.0\Client\Microsoft.LightSwitch.dll,才知道有更好的办法,一句代码就可以解决该问题,全部代码如下:
其他本地化的工作还没有做,等全部完了后,再提供完整汉化版本吧
分享到:
相关推荐
centric business applications for the desktop, cloud, web, and mobile devices in just a few clicks―with no code required―using Visual Studio Lightswitch 2015. This book explains the basics of Visual...
Visual Studio LightSwitch 2015 answers these questions and more as author Tim Leung―winner of a Microsoft 2011 Community Contributor Award for his LightSwitch expertise―covers this breakthrough ...
Visual Studio LightSwitch Beta2 离线安装 iso
[Apress] Visual Studio Lightswitch 2012 开发教程 (英文版) [Apress] Visual Studio Lightswitch 2012 (E-Book) ☆ 出版信息:☆ [作者信息] Tim Leung [出版机构] Apress [出版日期] 2013年07月31日 [图书...
visual studio lightswitch 2011 中文版 MSDN的版本 不需要序列号
使用 Microsoft Visual Studio LightSwitch 建立应用程序
本书重点介绍了Visual Studio LightSwitch的相关功能,这些功能可以使您在很短的时间内编写以数据为中心的LOB应用程序。本书不会涉及细微的功能详细信息,也不会试图讲解有关LightSwitch的一切知识,而只是说明并...
☆☆ 资料说明: ☆☆ [Sams] Microsoft Visual Studio LightSwitch Unleashed
内容丰富,还是值得一...• Part 1: LightSwitch Concepts • Part 2: Working with Data • Part 3: Interacting with Data • Part 4: Getting Data Out • Part 5: Securing Your Application • Part 6: Deploymen
This book covers using Visual Studio LightSwitch 2013 to create LightSwitch HTML Client, and Cloud Business Applications. This book describes creating ...
ComponentOne 2012 V2 Studio for LightSwitch 文件名称:C1StudioLightSwitch.1.0.20122.24.msi A collection of ready-to-use Visual Studio LightSwitch extensions that snap right into your applications ...
[Pro.Visual.Studio.LightSwitch.2011.Development].Tim.Leung.文字版.pdf
您可以在AngularJs中使用后端OData Visual Studio LightSwitch服务
Visual-Studio-LightSwitch-2011-Reviewers-Guide.pdf
本文介绍了如何将饼图控件从Silverlight Toolkit绑定到LightSwitch屏幕
Wrox Beginning Microsoft Visual Studio LightSwitch Development
本文介绍了如何从扫描仪和网络摄像头获取图像以及如何将其存储到LightSwitch应用程序的数据库中
根据MSDN的资料进行更改的FilterControl文件,将原来文件中的Existing Report功能摒除掉啦,原来的导出功能存在问题。该版本支持VS2013版本,整个文件是整个扩展的安装文件,个人爱好,需要源码,可以留言。