In the course of doing some work for one of our partners – we were asked to take a look at the existing workload for their ECM team. This particular ECM team has done a great job maintaining and integrating ECM components from a variety of vendors. As typical in such an environment – we found that everyone on the team had primary support duties for at least one component, and was involved in customer support issues or updating /enhancing one or more of the company’s ECM products on pretty much a daily basis. Continue reading
What is it?
Here are some benefits:
– Faster load speed
– Small files and cache size
– Less demand on your web server
– Uses less bandwidth especially on mobile devices
How to get image page count in .NET C#
private int GetTotalpages(string filePath)
int pageCount = 0;
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
using (Image temp = Image.FromStream(fs))
pageCount = temp.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
For millennia, mankind has looked to the stars and wondered, “How can I create a generic Dictionary in .NET that allows me use case insensitive strings as keys?” Well today that age old question will be answered with this neat trick.
Simply put, all you need to do is add a StringComparer object when constructing a generic Dictionary that uses a string key, and make sure to use on of the IgnoreCase StringComparers that are offered. Below is some sample code to illustrate just how easy this is.
// Create a generic dictionary with a string comparer that ignores case sensitivity. // // This includes the following: // - CurrentCultureIgnoreCase // - InvariantCultureIgnoreCase // - OrdinalIgnoreCase Dictionary<string, string> stringMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); stringMap.Add("Test Key", "Some value"); // Now try to access or change the corresponding value with the key. // The case of the key string no longer matters. stringMap["test key"] = "This will work"; stringMap["TEST KEY"] = "And also this"; stringMap["tEsT kEy"] = "And this as well"; stringMap["tEST kEY"] = "And finally this"; // This can be done with any dictionary that uses a string as the key Dictionary<string, int> numberMap = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); numberMap.Add("Test Key", 0); // Same deal here, you can use any case to get or set the values in the map numberMap["test key"] = 1; numberMap["TEST KEY"] = 2; numberMap["tEsT kEy"] = 3; numberMap["tEST kEY"] = 4;
And that’s all there is to it. I hope you enjoy and find this useful.