About the author

Miron Abramson
Me
Software Engineer,
CTO at PixeliT
and .NET addicted for long time.
Open source projects:
MbCompression - Compression library

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014

Creative Commons License

Blog Flux Directory
Technology Blogs - Blog Top Sites

Update to my compression module to compress third party scripts

My last version of the compression module was working great and able to compress and cache pages, WebResources, CSS and JavaScripts files. It have one problem (that similiar to most of the compression modules you can find). To compress the javascripts files, you have to modify the way you register them and change their links to something like that: 

<script type="text/javascript" src="/Scripts/utils.js">

needs to became 

<script type="text/javascript" src="Scripts/jslib.axd?d=~/Scripts/utils.js">

It is not so hard work to do, but it became useless when you use third party controls as 'Telerik' (RadControls)  and force it to doesn't use it's scripts as WebResources. In such case, the controls 'Injects' their scripts links into the HTML code and you can't modify them as needed to let the compression handler to compress it.  In the new version of my compression component, I added a ResponseFilter that parse the Scripts links in the HTML and convert them into 'compressable' links. By default, this option is disabled in the compression module. To enable it (if you use such third party controls), just add the attribute compressThirdParityScripts="true" to the compression configuration.

Full implementation instructions can be found here: Compression module implementation 

Latest code can be downloaded from: http://www.codeplex.com/MbCompression

Currently rated 4.8 by 5 people

  • Currently 4.8/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Miron on Friday, February 22, 2008 4:15 AM
Permalink | Comments (7) | Post RSSRSS comment feed

Simple Generic Business Entities

"Business Entites" are widly commonly use everywhere. Sometimes the entities are very big and contains a lot of methods and properties, but most of the time, they are basicly objects that holds data in easier and cleaner way than DataTables/DataSets. Sometimes you have entity for specific type such "Customer", "Laboratory", "Shop" or whatever, but lots of time you just need to load and hold data that is not from spesific type. Good way to hold such "un typed data" is using Generic. A "Generic Entity" that can hold any kind of data you need in the moment. For example, I create Generic entity called "Quadruple" that have 4 properties that will be from type you choose. If you create an instance of this entity like this:

Quadruplet<int,string,int,string> q1 = new Quadruplet<int,string,int,string>();

Quadruplet<bool,bool,Array,string> q2 = new Quadruplet<bool,bool,Array,string>();

q1 will be entity that can hold int, string, int & string and q2 will be entity that hold bool, bool, Array, string. No casting is needed.

List<Quadruplet<int, string, int, string>> quadrupletList = new List<Quadruplet<int, string, int, string>>();

quadrupletList  will be List of object from type Quadruplet<int,string,int,string>.  This kind of entitis can be very usuful in any kind of application, and it very reusable from application to another. 

In the file below, there are 4 entites: Duplet - hold 2 objects from any kind, Triplet 3 object (I know there is such class in 'System.Web.UI' but it holds 3 objects from the type 'Object' and casting will be needed),  Quadruplet for 4 objects and Quintet for 5. All those entities contains basic needed methods as Equals(object), operator ==, operator != and GetHashCode().

Those entities are NOT comming to replace the  "Customer", "Laboratory", "Shop" or any other specific needed entity. They are to help working with "un type" of data. Where the data is not from specific type or you don't want to make specific entitiy for that data.

SimpleGenericBusinessEntities.zip (4.26 kb)

Currently rated 4.4 by 7 people

  • Currently 4.428571/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Miron on Saturday, February 16, 2008 6:57 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Collect all controls from specific type

I got a simple "mission" to make a method that collect all the TextBox controls from any given control on the page (or from the Page itself).  As I like to do things in the most 'Generic' way, I finished with a simple method that collect all contols from any type you want.

This is the method that run recursive and collect all the controls from type T: 

        /// <summary>
        /// Loot recursive and collect the controls
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contol"></param>
        /// <param name="list"></param>
        private static void LoopControls<T>(Control parentContol, List<T> list) where T : Control
        {
            foreach (Control ctrl in parentContol.Controls)
            {
                if (ctrl is T)
                {
                    list.Add(ctrl as T);
                }
                else
                {
                    if (ctrl.Controls.Count > 0)
                    {
                        LoopControls(ctrl, list);
                    }
                }
            }
        }

To start the 'collecting' process:

        /// <summary>
        /// Collect all the controls from type 'T'
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contol"></param>
        /// <returns></returns>
        public static List<T> CollectControls<T>(Control parent) where T : Control
        {
            List<T> list = new List<T>();
            LoopControls(parent, list);
            return list;
        }

Drop this method in your 'Utilities' class, and its ready to go.  Now, To collect  all the TextBox in the page, just us it like this:

System.Collections.Generic.List<TextBox> l = Utils.CollectControls<TextBox>(Page);

and to collect all the Labels, just change the  '<TextBox>' to '<Label>'.

Using 'Generic' is very goot thing, and a lot of times, if you thing on the feutre and not focus only on the current mission when you write any method, you will end up using the Generic namespace.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: ASP.NET | C# | Server side
Posted by Miron on Wednesday, February 06, 2008 8:50 PM
Permalink | Comments (3) | Post RSSRSS comment feed

Back from holidays

I just come back from almost a month of vacation.  My sister and my father came to visit me in Argentina, (I moved to Argentina a year ago) and cause I didn't see them for almost a year, I was very excited for their visit. We spent a week in Bariloche - that is in the south of Argentina. I must tell you, it's the most beautiful place I ever seen. The chocolates from there are the best.



Afer they gone, I spent a week with my beautiful wife and her parents in a small place called Villa General de Belgrano - near to Cordoba (in Argentina too). It is a very nice place, but after you visit in Bariloche - nothing can impress you.



Something I must say: The meat in Argentina is the best in the world, and the meat in  Buenos Aires is best in Argentina !!!
So that's it. No more vacation. Now, back to the real life. Back to work Cool

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Personal life
Posted by Miron on Tuesday, February 05, 2008 8:05 AM
Permalink | Comments (6) | Post RSSRSS comment feed