Archive for October 16th, 2009

maxImage: jQuery Image Scaling

jQuery maxImage Plugin enables you to resize and scale targeted images to their maximum width according to the image ratio, the browser size and some simple options. Every time a user resizes the browser, the images will resize accordingly. Images can resize based on the width only, the height only, or both.

jQuery maxImage Plugin provides you the option to make your image a background image. The plugin find the width of your browser and the ratio of your image and then resizes it accordingly. Another useful option allows you to add slideshow functionality. Each image loads separately so that the slideshow can begin as soon as the first image is loaded.

Developed by Aaron Vanderzwan; jQuery maxImage Plugin is available for download under GNU General Public License.  You can find further information, demo & download on jQuery maxImage Plugin Website.

Similar Posts:



Thanks ElegantCode for welcoming me! (Jason Jarrett, @staxmanade)

Test 1…2…3… is this blogging software configured correctly???

Wonderful!

 

I’d like to thank David Starr and all the other members of the group for the opportunity to blog here at ElegantCode.

A little about me.

Prior to joining ElegantCode, I blogged over at staxmanade.blogspot.com. I will probably dual post. (until I decide and give further notice)

I’m a Senior Software Engineer and team member on a consulting firm in the Northwestern Nevada area. I’m primarily a Microsoft .net platform developer with a couple years experience with Linux/C++.

I develop a small tool on the side to allow for ease of TDD/BDD/<YourDD HERE> development in Silverlight – you can find it at http://www.statlight.net
image

 

A few minor OSS contributions

  • Submitted initial port of Castle.DynamicProxy2 to Silverlight – After the ^DP2^ was ported to Silverlight
  • Submitted initial port of Moq to Silverlight
  • Contributor to the i4o library

Lastly, I’ll highlight some of the more popular blog posts of my original blog…

There are many more posts there, most I think still relevant, but I hope some can provide value to the community.

I look forward to participating and growing with the community.


Mapping From IDataReader/IDataRecord with AutoMapper

A while ago, I submitted a patch to AutoMapper that added basic support for mapping data from an IDataReader/IDataRecord to an object. For those of us who don’t have the luxury to use NHibernate in their projects, this feature can save you from writing lots of repetitive and tedious code.

Its usage is pretty much the same as with regular object-to-object mapping using AutoMapper. Lets show a very simple example.

Suppose we have a view object like the one shown below:

public class SomeView
{
    public Int32 SomeNumber { get; private set; }
    public Guid AnId { get; private set; }
    public Double OrNothing { get; private set; }
}

Now when we can execute a query like this,

SELECT ColumnA AS SomeNumber,
       ColumnB AS AnId,
       ColumnC AS OrNothing
FROM SomeTable
WHERE ...

and read the results using a data reader. Now we can use AutoMapper to map the results to instances of our view class:

var dataReader = ... // Execute a data reader
var views = Mapper.Map<IDataReader, IEnumerable<SomeView>>(_dataReader);

This results in a collection of one of or more view objects. When our query is guaranteed to always return one record, we can use the following syntax:

var dataRecord = ... // Execute data reader and read first record
var = Mapper.Map<IDataRecord, SomeView>(_dataRecord);

This approach expects that a convention is followed whereby the name of a field returned by the query matches the name of a property on the target class. Its also possible to use projection as already provided for regular object-to-object mapping.

Suppose we add a new property to our view,

public class SomeView
{
    ...
    public DateTime SomeDate { get; private set; }
}

and we modify the query so that we retrieve the corresponding date value from the database:

SELECT ...
       ColumnD AS BirthDay
FROM SomeTable

Notice that we’ve broken the convention here and we need to use projection to ensure that the retrieved date value is mapped to the correct property.

Mapper.CreateMap<IDataRecord, SomeView>()
    .ForMember(dest => dest.SomeDateAndTime,
               options => options.MapFrom(
               src => src.GetDateTime(src.GetOrdinal("BirthDay"))));

var dataRecord = ...    // Execute data reader and read first record
var = Mapper.Map<IDataRecord, SomeView>(_dataRecord);

Using projection we’re able to manually map from a data reader or data record. In some sense,  we’re back to square one if we have to do this for all fields. Trying to follow the convention is of course the most useful. 

I know its not much, but I think it can be helpful for those cases where you actually need to map from a data reader or a data record to an object.


More Upcoming RIA Events

RIA Unleashed - Boston is a 1 day 3 track event covering Flex, AIR, ColdFusion and related technologies and disciplines. Our three tracks are designed to allow you to focus on the technologies you are interested in. You'll be able...

  • Sponsored Links

  •  

  • .

    Copyright © 1996-2010 Answer My Query. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress