Browse by Tags
All Tags »
C# (
RSS)
I really like jQuery’s pattern of attribute getters and setters. They are fluent and work really well with HTML and XML DOMs. If you specify a value in addition to the name, it’s setting, otherwise it’s getting. In C#, we have an OK API for XML, XElement, but it’s not as easy to use as jQuery’s attr methods. It is also missing the flexibility of Javascript with regards to parameter types. To recreate the simplicity of attr in C#, I built a set of extension methods for the most common simple types: var el = new XElement("node"); el.Attr("foo", "bar") .Attr("baz", 42) .Attr("really", true); var answer = el.Attr("baz"); The element built by this code looks like this: <node foo="bar"...
‘Paste JSON As Classes’ is a cool feature in ASP.NET and Web Tools 2012.2 RC. This feature will help you generate strongly typed classes in C# or VB.NET from valid JSON text. With ASP.NET and Web Tools 2012.2 RC installed, you will see new menu option like below for C# and VB.NET Website and Web Application projects only. This new menu option will be enabled for .cs and .vb file extensions inside these projects: JSON to C#/VB.NET class conversion To use this feature, just copy sample JSON text and “Paste JSON As Classes” inside .vb or .cs file. This feature uses Newtonsoft JSON parser to parse JSON text from clipboard. Once Newtonsoft JSON parser validates the clipboard data as valid JSON, then it will be converted into...
To those of us who have been around for a while, namespaces have been part of the landscape. One could even say that they have been defining the large-scale features of the landscape in question. However, something happened fairly recently that I think makes this venerable structure obsolete. Before I explain this development and why it’s a superior concept to namespaces, let me recapitulate what namespaces are and why they’ve been so good to us over the years… Namespaces are used for a few different things: Scope : a namespace delimits the portion of code where a name (for a class, sub-namespace, etc.) has the specified meaning. Namespaces are usually the highest-level scoping structures in a software package. Collision prevention : name collisions...
It should be quite obvious: drawing requires constant visual feedback. Why is it then that we still draw with code in so many situations? Of course it’s because the low-level APIs always come first, and design tools are built after and on top of those. Existing design tools also don’t typically include complex UI elements such as buttons. When we launched our Touch Display module for Netduino Go! , we naturally built APIs that made it easy to draw on the screen from code, but very soon, we felt the limitations and tedium of drawing in code. In particular, any modification requires a modification of the code, followed by compilation and deployment. When trying to set-up buttons at pixel precision, the process is not optimal. On the other hand...
Netduino Go is designed for much more than toy projects, but one has to recognize that toy projects are fun and also great learning experiences. Today, I want to take you through the process of reproducing the behavior of a famous toy that you will surely recognize. That toy, that has helped many of us realize what poor motor skills we possess, has two knobs that control the horizontal and vertical coordinates of a pen that draws into the dust on the back of a simple screen. It’s a great mechanical device that is part of western culture. Our version will use two potentiometers , a 320x240 LCD display , a button to erase the screen, and of course a Netduino Go . The hardware setup looks like the following: We connected the button to port 2 (but...
Wouldn’t it be great if you could build your own stuff? Microcontrollers let you do that, but they usually require dealing with a lot of complexity and unknowns. If you’re a software developer, chances are you don’t really know how to use a capacitor, or how a transistor works, even though it is at the heart of all computers. Well there is a way now to develop awesome hardware projects without knowledge of electronics, just by connecting modules together. Netduino Go is a platform that allows for that without constraining the types of projects you can build. Today the number of available modules is still limited (the platform was released only last Wednesday), but it is expected to grow fast. In this post, I’ll introduce you to the platform...
If you're a regular reader of this blog, you may have noticed the electronics posts lately. With my friend Fabien , we've been building a little handheld console from readily available parts. It's also programmable in C#, using a library that we built . It's great fun really. Our plan is to build a kit and a book out of it, to help people learn the basics of digital electronics and C# programming. We've built a site for the project over a few nights last week, using Orchard and hosting on Azure . I thought I'd throw in a little return on experience and talk about the modules we used. The site can be found here: http://www.pix6t4.com The first thing I did to build the site was to build the theme. I started from the built...
There is a (not so) particular kind of shape in Orchard: zones. Functionally, zones are places where other shapes can render. There are top-level zones, the ones defined on Layout, where widgets typically go, and there are local zones that can be defined anywhere. These local zones are what you target in placement.info . Creating a zone is easy because it really is just an empty shape. Most themes include a helper for it: Func<dynamic, dynamic> Zone = x => Display(x); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd...
Most Orchard shapes get created from part drivers, but they are a lot more versatile than that. They can actually be created from pretty much anywhere, including from templates. One example can be found in the Layout.cshtml file of the ThemeMachine theme: WorkContext.Layout.Footer .Add(New.BadgeOfHonor(), "5" ); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background...
A year ago, I wrote a scary post about RSS in Orchard . RSS was one of the first features we implemented in our CMS , and it has stood the test of time rather well, but the post was explaining things at a level that was probably too abstract whereas my readers were expecting something a little more practical. Well, this post is going to correct this by showing how I built a module that adds RSS feeds for each tag on the site. Hopefully it will show that it's not very complicated in practice, and also that the infrastructure is pretty well thought out. In order to provide RSS, we need to do two things: generate the XML for the feed, and inject the address of that feed into the existing tag listing page, in order to make the feed discoverable...
More Posts
Next page »