Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Posts Tagged "C++"

Using T4 Templates to Generate C# Enums from SQL Server Database Tables

Lenni Lobel

When building applications with C# and SQL Server, it is often necessary to define codes in the database that correspond with enums in the application. However, it can be burdensome to maintain the enums manually, as codes are added, modified, and deleted in the database.
In this blog post, I’ll share a T4 template that I wrote which does this automatically. I looked online first, and did find a few different solutions for this, but none that worked for me as-is. So, I built this generic T4 template to do the job, and you can use it too.
Let’s say you’ve got a Color table and ErrorType table in the database, populated as follows:

Now you’d like enums in your C# application that correspond to these rows. The T4 template will generate them as follows:

Before showing the code that generates this, let’s point…

Making the Case for Entity Framework in the Enterprise

Recently, I was met with some friction by the IT department at a client where, they asserted, that a decision had been made years ago to ban Entity Framework. Like many enterprise environments, this client was understandably concerned with the potential pitfalls of embracing Entity Framework. That meant that my job was to convince them otherwise – not to discount their apprehension, but quite the contrary – to demonstrate how EF can be leveraged for its advantages, and avoided for its shortcomings.
Entity Framework (EF) is a broad framework with many optional parts. There are several aspects of EF that provide great benefit, while others are a source of great consternation – particularly from the perspective of the database purist. As the cliché goes, “with great power comes great responsibility,” and so this blog post explores different aspects of EF, and…

Executing a Boomi Process using the AtomSphere RESTish API

Paul Gutierrez

There are a wide range of scheduling options that are made available to a Boomi application once it is deployed. Depending on the inbound connector used in the application, once deployed the process can run on a schedule or it can continuously poll some existing data source. How the process runs is dependent on if the inbound connector being a “Get” operation or a “Listen” operation.
A “Get” operation allows the process to get a set of inbound records from a data source. Upon deployment this process can either be triggered manually or can have a schedule set up so that it runs on set intervals, for example perhaps it is desired that the process runs every Tuesday and Thursday of every week.
A “Listen” operation  allows a data source to be continuously polled and will retrieve data as it comes in. An…

Programmatically Deploying Dell Boomi Processes using the AtomSphere RESTish API and C#

Paul Gutierrez

While the Dell Boomi user interface is highly robust and user friendly there are times when using the user interface can prove to be quite tedious. One example that we have discovered to be an example of this are process deployments. In order to deploy a set of Boomi processes one must search for each individual process and deploy. This may not seem overly tedious if AtomSphere only has a few processes. But in some cases AtomSphere could have numerous applications each consisting of many processes. It is easy to see given the scenario how frequent deployments could prove to be very time consuming.
Luckily, there is an alternative to using the AtomSphere user interface. Dell Boomi offers a set of APIs (both REST and SOAP) that can be used for various sets of tasks and that includes deploying Boomi processes….

Rate Limited Threading in C#

Jeremy Mill

I recently ran into an issue while working on a project dealing with an external, rate limited, REST API. We wanted to perform an action on several thousand local objects which required hitting this external service and getting back a response. Running in an iterative pattern wasn’t an option for us because it would take too long, and guessing the number to try per minute wasn’t an option either because we might incur extra charges from the provider of the external API. The solution was to create a rate limited ThreadPool in our C# application to perform the requests, and a BlockingCollection to store the responses.

Setting Compatibility Mode Of A WPF Web Browser

Jordan Piscitelli

Tutorial for how to set the Compatibility Mode of a WPF Web Browser control to match the default settings of Internet Explorer.

Sending Key Events to a WPF Web Browser (And Injecting Javascript)

Jordan Piscitelli

Recently I had the need to send KeyDown events to the WPF WebBrowser and after many failed attempts I finally figured out a good (or at least a working) solution. It should be noted that this solution does not trigger browser key events but rather triggers javascript key events, such as those bound by addEventListener. The technique utilizes javascript injection, so it could also be used to call any existing javascript method.

Calling an ASP.Net web service using jQuery and JSON.

Karl Schwirz

Let’s say you have a webpage where you need to call a service but cannot perform a post back.  Recently I was on a client engagement where we needed to improve page performance by dynamically loading a navigation tree with a potential for several thousand links.  We implemented a solution that would load each branch as the user clicked on the expanding icon by calling a web service via ajax and passing the required links back to the page and render them client side.  This saved immensely on the load time for the page and improved the user experience
This kind of solution can be applied to several situations such as complex data processing, dynamic loading, or combining them all into a seamless form submission process that would clear the form on post backs.
We can accomplish this process simply by grabbing…

.NET File Compression in Memory

Karl Schwirz

File compression is nothing new to .NET.  However, in many solutions it requires the developer to establish a file folder which they will write the compressed file to and later read from.
This solution cannot work if you want to compress and use the file in memory without writing to disk.  An example of this could be on a server where you don’t particularly want to have random processes writing to and reading files.
Listed below is a solution we came up with for compressing a file in memory. We used an open source library SharpZipLib from sharpDevelop.net.  There are other good options out there that could also be used.  We found that using this library offered the most intuitive solution to creating the archive file.
The result will be a Stream which can be used to send the compressed data to an…

Pass by reference

In C++ and C#, developers have freedom to modify variables by directly having access to memory location.
In C++,
#include <stdio.h>
void swapnum(int &i, int &j) {
int temp = i;
i = j;
j = temp;
int main(void) {
int a = 10;
int b = 20;
swapnum(a, b);
printf(“A is %d and B is %d\n”, a, b);
return 0;
In C#,
int a = 1;
modify(ref a); //now a=2
void modify(ref int a)
a = 2;
In Java, however, there’s no such thing as pass by reference.  Even the so-called pointers (created by ‘new’ operator) are passed by copy of the reference.
Thus, if you do the following,
String a = “a”;
modify(a); //a doesn’t change, since a is being passed as a copy of the pointer a.
void modify(String a)
a = “b” //this a is a different pointer, thus does not affect the real ‘a’ pointer outside of the method.
As you can see, there’s no direct way of modifying…