Function Overloading in JavaScript

Function Overloading is the ability to define two or more functions with the same name that have a different signature, i.e. a number and/or different types of parameters/arguments. For example: function DoSomething(a) function DoSomething(a,b) function DoSomething(a,b,c) In JavaScript, there is no function overloading. There is however behavior regarding sending different parameters, and there is a pattern we can use to handle function overloading. First, consider the case above. If we … Continue reading Function Overloading in JavaScript

WPF – Grid Splitter

Let’s say we have the following WPF form that has 3 rows and 2 columns: If we wanted to give the user the ability to resize the columns, we can use a GridSplitter. Under WPF Controls, you will see GridSplitter: First, we will add an additional colum. This will hold the splitter: Next, we will move our textboxes to the right column, so it frees the middle column for resizing: … Continue reading WPF – Grid Splitter

WPF – Column and Row Definitions

In a WPF grid, we can define columns and rows. To do this, create a new WPF app in Visual Studio: You will see below: Select Layout in Properties. You will see Column Definitions and Row Definitions: Select Column Definitions. Click Add: Here you can add a column definition, which is defining a column, just as you would in a table for example: Add a second column definition: You will … Continue reading WPF – Column and Row Definitions

WPF – Disable Visual Studio UI Debugging

When you create WPF apps in Visual Studio, you will see an extra toolbar on your WPF forms: This is the UI Debugging Tools for XAML in Visual Studio. Options include: Go to Live Visual Tree Enable Selection Display Layout Adorners Track Focused Element To disable this, in Visual Studio select Tools->Options: Debugging->General->Enable UI Debugging Tools for XAML: Rerun and you will now not see the tools:  

WCF Fault Exception

In this example, we will show how to use the FaultException when catching errors in a WCF service. First, create a new WCF service: Our service will be a calculator, that will perform a divide operation. We will rename the files created so we have: Calculator.svc ICalculator.cs In ICalculator, change the code to be below. This is our service contract and operation contract: using System; using System.Collections.Generic; using System.Linq; using … Continue reading WCF Fault Exception

WCF Specify Names of Contracts

Consider a WCF service that returns some text that you entered. The service has a contract called IService1 and an operation called GetData. When we run the service in our test client, we see: The code for this is: using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace Carl.TestWCF { [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); } } Let’s say we … Continue reading WCF Specify Names of Contracts

JavaScript Promises

JavaScript promises are a way in JavaScript to write asynchronous code in a synchronous way. They are asynchronous callbacks, but in terms of error handling are much more readable. Here we will go through an example of how to use promises. We define a promise as below, with 2 parameters, resolve and reject: new Promise((resolve, reject) If the promise is resolved, we can perform an action, and if it is rejected, … Continue reading JavaScript Promises

JavaScript Callback Functions

A callback function in JavaScript is a function passed to another function that is then called after an event has occurred. This is useful when you don’t know how much time the function will take to complete, such as a call to a web API. In the simple example below, we have a function called callback() that writes to the console. We then have a function called testCallback() that calls the … Continue reading JavaScript Callback Functions

JavaScript in the Dynamics CRM Developer Toolkit

The Dynamics CRM developer toolkit allows you to manipulate JScript resources as well as other artifacts. In Dynamics CRM, create a new solution and add a new Web Resource: In Visual Studio, from the Developer Toolkit, create a new project: Now in your project, right click and select Add to packaging project: You can now add code to the file from within Visual Studio: Update and save the .js file: … Continue reading JavaScript in the Dynamics CRM Developer Toolkit

Namespaces in JavaScript

Namespaces are used to help organize code into logical groups. An example of a namespace is MyCo.ERP.Customers, which may contain code regarding ERP Customers. I could also have a namespace called MyCo.CRM.Customers. When writing an app, I can reference each piece of code using their fully qualified name to avoid confusion of what methods I would like to run. In languages like C#, namespaces are easily implemented. In JavaScript, we can … Continue reading Namespaces in JavaScript