Enum in custom web test validation rule - visual-studio-2010

I'm building a Web Test using Microsoft VS2010.
I used the explanation on MSDN: How to: Create a Custom Validation Rule for a Web Performance Test.
In the example there using string and int as private members with public "get" and "set" those parameters valid for edit in the UI when I add this validation rule to my test.
I want to have an Enum with 3 option that when I add the validation rule to the UI I can choose from.
Is there a way to add an Enum variable which will also be valid in the UI ?
Are there any other types which can be used which will be valid in the UI ?

Unfortunately the UI only shows String and primitive-type properties in user-created rules/plugins. Yet some built-in rules/plugins use enums... how can this be? Thanks to the magic of the disassember and some detective work, we discover that it only accepts enums whose assembly name contains the string "Microsoft.VisualStudio.QualityTools.WebTestFramework".
So if you go to the trouble of compiling your enums (or indeed, your entire project) into an assembly called, for example, "MyEnums.Microsoft.VisualStudio.QualityTools.WebTestFramework", BOOM your enum-typed properties will happily appear in the editor UI.

Related

How to add support for different language in Confirm Prompt (Microsoft Bot Framework)?

I would like to use Confirm Prompt but currently Confirm Prompt supports only few languages such as en-us, fr-fr etc. I would like to use Confirm Prompt for 2 different languages which are not supported by default. I know I can use fields as confirmChoices and choiceOptions to manually specify confirm choices but that would mean that I have to create 1 ConfirmPrompt for every language which is not included in Confirm Prompt by default.
The easiest way to add support for more languages, which are not included by default, would be to add them to defaultChoiceOptions map. But this map is declared as private static, hence it can not be modified.
So I am thinking about extending ConfirmPrompt class and overriding onPrompt and onRecognize method which will be exactly same as in ConfirmPrompt class but it will use myCustomDefaultChoiceOptions which will be non static and public field in my custom class => problem solved.
But this is hackish solution and I can not understand why this map is not public and non static in Bot Framework SDK.
Hence I am asking, is there any other solution (natively supported by framework) which allows me to add support for different languages in ConfirmPrompt?
This was actually a change pushed out a couple of months ago (by me). You'll need to update your packages.
choiceDefaults is private (and non-static, now), however, it can be updated by passing it into the constructor.
The easiest/best way to do this would be to build your PromptCultureModel for each language/locale/culture (so you can also use it easily with ChoicePrompt), then create the object with those PromptCultureModels that matches ChoiceDefaultsConfirmPrompt, and then pass that into the constructor.
You can see how I did this in it's test here.
Note: When you overwrite choiceDefaults, you lose all of the currently-supported languages. You can easily add them to your PromptCultureModel object via PromptCultureModels.getSupportedCultures().
Note: I've got a to-do to add some additional languages, but it's on the backlog since you can now add your own.

How can i set the api version on a generic controller when loading a plugin?

I have some plugin's which are basically input and output type definitions. I have a generic controller which i can add to the mvc pipeline. All works fine.
but I'm having trouble setting the api version on this generic controller. I know you can set this based upon an attribute on top of the controller class. But since you can't have this dynamic (attribute) don't allow it, i have no way to set the version for each instance of the generic controller.
Currently i just compile the controller for each instance on runtime and register i using the roslyn compiler.
is there a way to set the api-version somewhere in the pipeline of registering controllers in the mvc pipeline and endup with different api versions endpoints.
This can be achieved by using the Conventions API. It was designed to support this exact type of scenario:
https://github.com/microsoft/aspnet-api-versioning/wiki/API-Version-Conventions
This will only work on closed-generics, but it shouldn't be too much work to make that happen. Here's a couple of basic examples:
// typed, closed generic
options.Conventions.Controller<GenericController<PlugIn1>>().HasApiVersion(1,0);
// untyped, closed generic
var controllerType = typeof(GenericController<>).MakeGenericType(new []{typeof(PlugIn1)});
options.Conventions.Controller(controllerType).HasApiVersion(1,0);
You can also author your own custom conventions a la IControllerConvention. This approach could be used to version all controllers that inherit from GenericController<>. Then you just need to add it to the conventions like this:
options.Conventions.Add(new PlugInControllerConvention());
Hopefully that's enough to get you started. Feel free to ask more questions.

Click-To-Call feature for Dynamics CRM (like Lync/Skype)

Advance warning: Im an absolute newbie to Dynamics CRM!
Intention
I want to have a feature like Lync/Skype integration but use my own URL. (Click on any telephone number inside CRM and call it).
For eg. assuming I have a web service which can initiate a call per URL: http://telephony.com/call?nr=012345678. Now, whenever a CRM user clicks onto a telephone number field (in forms and views) inside the CRM my web service should be called instead of Skype/Lync.
In fact I'm trying to reproduce sth. like the InGenius Connecter.
Attempts
I already tried to inject a JS web resource to a specific formular (in my case it was the default contact form) and override the Mscrm.ReadFormUtilities.openPhoneClient callback (which seems to handle the Lync/Skype integration).
function load() {
// override integrated CTC (Lync/Skype)
Mscrm.ReadFormUtilities.openPhoneClient = function (telephoneNr) {
// redirect user to my web service
window.location.replace("http://telephony.com/call?nr="+telephoneNr);
return;
}
}
Found this method at: Disable Lync completely
This does work well in forms of Dynamics 2015 (my custom link pops up instead of Skype/Lync). However, this does only work on entity forms since I can't inject web resources into an entity view.
My other ideas how to implement such a feature are:
Inject global JS resource which disables Lync/Skype and encapsulate every telephone number with link to my custom URL.
Extend/Manipulate Lync/Skype integration to use my custom URL instead of Lync/Skype.
Write plugin which encapsulate telephone numbers server side.
Question
Since I have a grasp understanding of Dynamics and no experience in plugin/resource development, I'm left a bit confused with these questions.
Is it possible to achieve any of the three ideas above ?
If not, any idea how InGenius solved this problem ?
Do you have any other idea/resources about this topic ?
Currently I found two options available to achieve a custom CTC feature. (Both has the downside of not being officialy supported by the dynamics crm.)
Global Ribbon
Pretty simple: Add a Click-To-Call button to global ribbon which is only enabled on specific grids when one row is selected.
This button refers to an JS-Action which retrieves the telephone number via ODATA and then launches the dial process.
Global Ribbon CustomRule injection
Add a global button to ribbon which refers to a JS resource per <CustomRule>. The JScript then unbinds all actions from links with .ms-crm-Phone classes and replaces its href-attribute.
This would be useful if one want to override the integrated "Skype / Lync - Click to Dial" feature with his own logic.
I didn't test this method until now, so I can't guarentee it's working !
Note: I will include example scripts as soon I got the time.

Returning child elements in ASP.NET WebAPI OData

I'm using the latest ASP.Net WebAPI Nightly builds (dated 2013-01-16).
I have a simple EF database first model at the moment that has two entities - Patients and Visits. Each patient can have many visits.
I'd like to be able to query for my list of patients and have the visits entities for each patient returned inline. I know that WebAPI's OData implementation doesn't yet support $expand. I'm hoping that just means that optional client-controlled expansion is not supported and that I can force expansion server-side.
At the moment I'm not getting any of the visits inline.
For example, my PatientController's() Get() method looks like
[Queryable(AllowedQueryOptions=AllowedQueryOptions.Supported)]
public override IQueryable<Patient> Get()
{
var query = this.entities.Patients.Include("Visits");
return query;
}
I've verified that the query executing against my database does indeed include the visit information.
To use a publicly available OData service as an example, if you use the service at http://services.odata.org/OData/OData.svc/, you can get a list of Suppliers. This is http://http://services.odata.org/OData/OData.svc/Suppliers.
You can also ask for a list of suppliers that includes the list of products using http://http://services.odata.org/OData/OData.svc/Suppliers?$expand=Products
Stepping through the ASP.NET code (via the symbols server) I've got to the System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer and can see that it's CreatePropertyBag method, which builds up the list of properties to be serialized, just doesn't include the navigation properties, and they don't seem to be enumerated anywhere else apart from being written out as NavigationLinks.
I'm quite new to the ASP.NET world in general and have spent a week or so getting my head around the way things work (particularly with the changes made to OData at the end of 2012 and further changes made so far in 2013).
I suspect that if the ODataEntityTypeSerializer was to be modified (I'm happy to try) to embed this extra information in the appropriate spot (within each navigation link as an nested inline feed as best I can tell) then I'd be set.
Questions:
Have I overlooked something obvious and there's a flag I can set to turn on this behaviour? I can see why, if such a flag exists, it would be off by default (EF lazy loading and this flag wouldn't get on well)
If #1 is no, is there some other ODataEntityTypeSerializer that I could use? If so, how do I switch to it?
If #2 is no, any pointers for where I should start writing my own? Is there a place I can substitute in my own serializer or do I have to maintain my own fork of ASP.NET's Extensions project (as opposed to the Runtime project)
Thanks very much!
$expand is very high on our list of things to support for OData. But as far as I know, we don't have any flag to turn it on server-side. The formatter doesn't currently allow you to substitute your own serializers either. So I'm afraid your only option in the meantime is to create a fork and add support for $expand. If you manage to get it working, please consider sending a pull request our way:
http://aspnetwebstack.codeplex.com/SourceControl/network
You can try it already in webapi nightly builds.
Here is how to install it with nuget:
http://aspnetwebstack.codeplex.com/wikipage?title=Use%20Nightly%20Builds

Validation in ASP.NET MVC using Code Contracts

I want to know the available options for using the "Code Contracts" attributes as the validations rules in ASP.NET MVC 2.
You could do this by customizing the Runtime Checker.
Although it is possible to tweak Code Contracts into being used as a validation framework, I would advise against it. It is one of the more advanced features to tweak the Runtime Checker and more importantly, not what Code Contracts is made for.
Code Contracts is basically a means of integrating Design by Contract in your project. Although one of its purposes is to validate your code against your class design, it is not a validation framework.
In my opinion, you should use it next to another real validation framework.
Before you start using Code Contracts, I suggest you read the user manual here. It has all the information, including how to customize the Runtime Checker.
Yes that is true that the main purpose of "Code Contracts" is to validate my code against my class design but it also describes the valid states of my object.
All I can think of validation scenarios, is of these three types:
Input Validation ( UI Validation )
Domain Validation ( DbC )
Output Validation (Persistence
Validation, Ex: NHibernate
Validator )
I consider validation as a logical question whether the target object is in a valid state or not.
The DbC has three parts,
the validation rules
the static checker
the runtime checker
The first part ( the rules) is common in all three scenarios of validation. When I tag a property with "Not Null" using "Code Contracts" to validate its design, isn't it ugly to have it tagged "Not Empty" using "System.ComponentModel.DataAnnotations" for MVC (UI Validation) ?
In abstract, the definition of valid states is core and the shared part of validation frameworks and "Code Contracts" provides it, with one extra which is the "Static Cheker" for the domain design (not the I/O).

Resources