Tagged articles
Image from Pexels

Tagged articles - Extension Method

Found 12 articles tagged with Extension Method

Using strongly typed objects with IDistributedCache instead of byte arrays
An easy way to cache any object to distributed cache store using .NET Core
0
Saving an object to distributed cache store in .NET Core requires your object to be serialized to byte array in order for SetAsync method on Microsoft.Extensions.Caching.Distributed.IDistributedCache interface implemented instance to save your object to the injected cache store instance. This means that what ever instance you have, you need to serialize it first to byte array. Similar, just reversed process applies for the process of reading an object from the distributed cache store. ...read more
Get number of messages in MSMQ with C#
MSMQ message count in .NET
0
MSMQ (Microsoft Message Queuing) is a built in Windows component. It is not so popular now days as there are more efficient and robust solutions available. However, it still has it's place in application architecture as a simple queueing system, plus as I mentioned, it comes out of the box with Windows operating system as a Windows component.This means it is still widely used Windows based applications mostly for internal notifications and services between components of the solution...read more
Simplified FileAttributes usage with extension methods
Useful extension methods for common used file and folder attributes
0
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. File-system 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...
 
0
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
 
0
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
0
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
0
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
0
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
0
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
 
0
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
0
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
 
0
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

.NET

read more

JavaScript

read more

SQL/T-SQL

read more

Umbraco CMS

read more