Tip : How to know how your product name sounds in another language.

SONY DSC

Finding a name that suits your product/business/application/[anything] is hard.
It’s even harder when you want your product to be available worldwide.

You have to keep in mind that the name you found can be perfect in you language but can have an dumb (or offensive) meaning in another one.

You will also wonder how the name you came with will sound in other languages.

To help you with these questions, here is a quick tip: use google translate https://translate.google.com

First, it will help you to know the different meaning your name can have

Translate

Second, you can listen how it sounds in different languages

2016-01-29 10_10_57-Google Translatefrench

2016-01-29 10_10_24-Google Translateenglish

It will not really help you to find a name, but it’s a cheap and easy way to test if what you came with doesn’t sound really weird in some languages.

How to instantiate PrivateType of nested class

The PrivateType class is very handy when it comes to run unit tests on methods that are either private, either in an internal class.

The constructor signature is:


public PrivateType(
	string assemblyName,
	string typeName
)

You use it this way:


PrivateType t = new PrivateType("Myassembly", "Myassembly.MyNamespaces.MyInternalClass");

MyType result = t.InvokeStatic("MyMethod") as MyType ; // MyType  can be any object type

But when you are in the specific case of testing a method from an nested class of an internal class, there is a little trick

The TypeName argument of the PrivateType’s constructor is not (as we could imagine) “Myassembly.MyNamespaces.MyInternalClass.MyInnerClass” but “Myassembly.MyNamespaces.MyInternalClass+MyInnerClass” (notice the “+”)

So :


PrivateType t = new PrivateType("Myassembly", "Myassembly.MyNamespaces.MyInternalClass+MyInnerClass");

MyType result = t.InvokeStatic("MyMethod") as MyType ; // MyType  can be any object type

Help found thanks to :https://stackoverflow.com/questions/3200875/how-to-instantiate-privatetype-of-inner-private-class/22700890#22700890

Incoming search terms:

  • Nested Leave a Reply comment -captcha
  • privatetype private class
  • unity instantiate nested class

Print a Kendo UI grid with pagination

So I wanted to print a page that has a Kendo ui grid with pagination activated, but I didn’t want to remove the pagination on the page.

I found those two posts that helped me

http://www.telerik.com/forums/print-all-pages-in-a-grid

http://stackoverflow.com/questions/18325025/how-to-detect-window-print-finish

And I ended with this


(function () {

var pageSize = 0;
 var beforePrint = function () {

 // remove paging on grid
 if ($(".k-grid").length > 0) {
 var dataSource = $(".k-grid").data("kendoGrid").dataSource;
 pageSize = dataSource.options.pageSize; // save the current page size
if(pageSize !== undefined){
 dataSource.pageSize(dataSource.total()); // set the size to the number of items
}
 }

};

var afterPrint = function () {

// set paging back
 if ($(".k-grid").length > 0 && pageSize > 0) {
 var dataSource = $(".k-grid").data("kendoGrid").dataSource;
 dataSource.pageSize(pageSize);
 }
 };

// chrome
 if (window.matchMedia) {
 var mediaQueryList = window.matchMedia('print');
 mediaQueryList.addListener(function (mql) {
 if (mql.matches) {
 beforePrint();
 } else {
 afterPrint();
 }
 });
 }

// FF & IE
 //https://developer.mozilla.org/en-US/docs/Web/API/window.onbeforeprint
 window.onbeforeprint = beforePrint;
 window.onafterprint = afterPrint;

}());

Hope it helps someone

Incoming search terms:

  • kendo ui pagination
  • kendo ui print
  • kendo ui chart print
  • print kendo grid
  • kendogrid number page total
  • print_pagination
  • live disable pagination kendo grid
  • kendo ui page size 0
  • Kendo Grid Pagination
  • remove kendo grid

Know your .NET Framework Episode 2 : getting a range of integers

If you need a list of integers filled with all numbers in a specific range, you will often do this :

List<int> range = new List<int>();
for (int i = rangeStart; i < RangeEnd; i++)
{
   range.Add(i);
}

or you will write a method

public IEnumerable<int> GetRange(int start, int end)
{
  for (int i = start; i < end; i++)
  {
    yield return i;
  }
}

and call it:

List<int> range = GetRange(0, 10).ToList();

Good news : this method already exists in the framework !

You can find it in the System.Linq namespace : it’s the Enumerable.Range static method, and it’s available since framework 3.5.

This method returns an IEnumerable<int>, you can use it like this, or convert it to an array or a list.
to use it :
List<int> range = new List<int>(Enumerable.Range(0, 10));
or
List<int> range = Enumerable.Range(0, 10)).ToList();

Remark

Note that the first parameter is the start, but the second is not the end ! it’s a count !, so if you want to use it by specifying a start and an end you will have to do this :

int start = 5;
int end = 50;
List<int> range = Enumerable.Range(start, (end-start)+1)).ToList();

It’s handy to reduce the code size when you want to fill a dropdown or other things that requires a range of integers.