Tagged pages

Found 10 articles tagged with Extension Method

Simplified FileAttributes usage with extension methods
Useful extension methods for common used file and folder attributes
In case you are working on a small project where you just store some files and access them, you do not really need a database to achieve accessibility and additional info to files or folders. Filesystem itself is providing some stuff which can be useful for this... read more
Easier manipulation with IEnumerable objects
Useful extension methods for working with lists, arrays, dictionaries...
Working with any collection which implements IEnumerable is pretty easy in C#, plus if you are using LINQ you can easily manipulate with collection data. Recently I was doing some filtering with some in-memory collections and I had to check whether one collection contains same elements as some other collection with elements of the same type... read more
Random element of IEnumerable/Array
Random element extension method for IEnumerable/Array
I don't work with random values very often but recently I had to write some small function that returns random value from an array. It sounded like a good idea to write it as an extension method to make it reusable for other projects... read more
Convert string to any type that implements TryParse method
String extension method for converting to other value types
In many cases serialized data is returned in a form of string although the actual type of data is different. The problem begings when you want to use data in it's original type becaus direct cast is not allowed in C# as it is in VB.net. This is why you have to use TryParse and safely parse the value to it's original type... read more
Extension method equivalents in JavaScript
How to write an extension method for a type in JavaScript
For someone who works in C#, extension methods are one really useful feature introduced in .NET framework. I use extension methods a lot because they are so nicely integrated with intellisense and you can access them really easy. ... read more
Fetching image cropper cropped file path
IPublished content extension for getting crop image file easily
ImageCropper datatype was once part of uComponents, but because it is so usefull, it is now included into standard Umbraco instalation. However as much it is useful, I could not find the way to get cropped image file properly with anything that was shipped with Umbraco installation. Therefore I decided to write my own extension and to make life easier while working with ImageCropper in Umbraco. ... read more
Extending WebForms Page class for registering stylesheet include
Extension method which enables registering stylesheet file reference
I recently started working on an Umbraco package for GoogleMap manipulation. Since initial version of package is planned only for Umbraco 6 I decided to use WebuserControl for creating a package custom datatype. It means that for one document type I might have multiple control instances on the page. ... read more
Bitmap manipulation extension methods for C#
Helper methods for bitmap manipulation in .NET
This is a class I used few years back for some image manipulation in C#. Over the years, I was adding more methods and code snippets I needed and some stuff I found on Internet, so it grow to a useful collection of Bitmap manipulation methods... read more
Detect ajax request in C#
Easier way to detect whether request is an ajax request
Sometime you need to determine whether your request is standard GET/POST request or Ajax POST/GET http request. This info is stored in request value isAjax or X-Requested-With. By checking these values of request you can easily determine whether http request is ajax or not. ... read more
Extending Umbraco API with extension methods
Nullreference exception safe property accessing
Often during writing partial view for page you need to read value from property which is content or media picker. In order to get integer value you need to cast value acquired with GetPropertyValue method which is object type... read more