Filter Control for Visual Studio lightswitch Localization

Source: Internet
Author: User

Filter Control for Visual Studio lightswitch is an open-source ls extension for ms. It supports advanced user-defined queries. You can download tranquility extensibility toolkit from here. This tool provides an environment for implementing ls custom extensions.

For more information about how to use filter control, see local filter control. After the downloaded version is installed in Vs, the actual running time is as follows:

 

You can see the description and calltype boxes, which are the attributes of the data entity. For us, we need the displayname defined when designing the entity, I think users should be more accustomed to using Chinese, rather than e-text. Otherwise, I guess the software is hard to sell ., Other localization operations can be directly found in the Code.

I have a little understanding of the VB. NET syntax, but I forgot about it. Below I will make public the code for the first debugging experiment, which is rather bad. (No ls Technical Manual, no knowledge about the object runtime structure)

 

Open the filtercontrol. Client project and find fielddefinition. VB. Here are the modifications we need to make.

Private sub new (byval propdef as ientitypropertydefinition, byval currentdepth as int32, byval maxdepth as int32) is located in the original processing code in this construction, as follows:

'Get displayname
'Replace this with appropriate call in RTM
'Me. displayname = propdef. Name: the place where the query condition display name is processed. comment it out.

The following is the debugging code. I do not know how to write the VB. NET LINQ syntax. Only one loop is allowed.

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

We can determine the idisplaynameattribute by observing the actual running status of the object. With this, it is easy to do. This is our Chinese name. Basically, but through decompiling c: \ Program Files \ Microsoft Visual Studio 10.0 \ common7 \ ide \ lightswitch \ 1.0 \ Client \ Microsoft. lightswitch. DLL to know that there is a better way, a sentence of code can solve this problem, all the code is as follows:

Private sub new (byval propdef as ientitypropertydefinition, byval currentdepth as int32, byval maxdepth as int32) currentdepth + = 1 me. shortname = propdef. name if typeof (propdef. propertytype) is isemantictype then typename = directcast (propdef. propertytype, isemantictype ). underlyingtype. name elseif typeof (propdef. propertytype) is inullabletype andalso typeof (directcast (propdef. propertytype, inullabletype ). underlyingtype) is isemantictype then typename = directcast (propdef. propertytype, inullabletype ). underlyingtype, isemantictype ). underlyingtype. getnullabletype. name elseif typeof (propdef. propertytype) is isimpletype then typename = directcast (propdef. propertytype, isimpletype ). name elseif typeof (propdef. propertytype) is ientitytype then typename = "entity" end if 'dim TP as isimpletype = trycast (propdef. propertytype, isimpletype) 'if TP isnot nothing then' typename = TP. name 'else' typename = "entity" 'end if' MessageBox. show (Microsoft. lightswitch. model. extensions. modelextensions. getdefadisplaydisplayname (propdef) 'Get displayname' replace this with appropriate call in RTM. The following code gets the display name me. displayname = Microsoft. lightswitch. model. extensions. modelextensions. getdefadisplaydisplayname (propdef) If currentdepth <= maxdepth andalso typeof propdef. propertytype is ientitytype then 'navigation property dim navproptype as ientitytype = propdef. propertytype for each P as ientitypropertydefinition in navproptype. properties 'ignore any hidden or computed fields if p. attributes. where (function (a). class. name = "hidden "). firstordefault is nothing andalso p. attributes. where (function (a). class. name = "computed "). firstordefault is nothing then if not typeof p. propertytype is isequencetype then 'ignore collections for now me. addchild (New fielddefinition (p, currentdepth, maxdepth) end if next end if end sub

Other localization work has not been done yet. After all the work is done, please provide the complete Chinese version.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.