
Credit to Calvin and Hobbes.
private static bool IsAnonymousType(Type type) {
Debug.Assert(type != null, "Type should not be null");
// HACK: The only way to detect anonymous types right now.return Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false)
&& type.IsGenericType && type.Name.Contains("AnonymousType") && (type.Name.StartsWith("<>", StringComparison.OrdinalIgnoreCase) || type.Name.StartsWith("VB$", StringComparison.OrdinalIgnoreCase))&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic;
}
$('body').jRoll(); $('body').jRoll({ 'url' : 'http://www.google.com' }); $('body').jRoll().click(function() { alert('Never gonna give you up') });// Pass jQuery to a closure that maps to $ so it can't be overwritten
// by another library in the scope of its execution
(function($) {// Add a new function to the jQuery.fn object (your plugin name)
$.fn.jRoll = function(options) { // Default settings
var settings = {'url' : 'http://www.youtube.com/watch?v=4R-7ZO4I1pI'
};
// Merge defaults with options argument
if (options) { $.extend(settings, options);
}
// Modify elements and return them to maintain chainability
// this refers to the jQuery object the plugin was invoked on
return this.each(function () { $(this).find('a[href^="http://"]').attr('href', settings.url);});
}
})(jQuery);