Archive for the Category dotnet

 
 

Weekly developer links – 1

  • SymbolSource.org – The goal of this project is to provide a common debugging symbols and sources server for the most popular open source projects in the .NET ecosphere: NHibernate, Castle, Log4Net, C5, NInject and many other.
  • FluentPath – FluentPath implements a modern wrapper around System.IO, using modern patterns such as fluent APIs and Lambdas.By using FluentPath instead of System.IO, you’ll be able to chain calls and act on sets of files as if they were individual files.
  • .NET Screen Scraping in depth – Everything you need to know about screen scraping, from simply pulling down a page to more complex issues like submitting forms and cookies. Here you will learn how to use the WebClient and HttpWebresponse classes and which is better for what task
  • Free Silverlight controls, components & tools – to help making your websites brighter collected by WebResourcesDepot.

Sorting System.Collections.Generic.List<T>

This post shows the sorting technique using anonymous delegate that can be implemented in any custom type generic list based on the selected property.For sorting any custom type the class must implement the System.IComparable interface. Now let me assume you have a Person class and if you want to sort the list of person objects then you must implement System.IComparable interface and write the logic of how our person object is to be sorted in the CompareTo method

using System;

namespace ConsoleApplication1
{
    class Person : IComparable
    {
        public Person(string firstName, int age)
        {
            FirstName = firstName;
            Age = age;
        }

        public string FirstName
        {
            get;
            set;
        }

        public int Age
        {
            get;
            set;
        }

        // sorting in ascending order      

        #region IComparable Members

        public int CompareTo(object obj)
        {
            var person = (Person) obj;
            return FirstName.CompareTo(person);
        }

        #endregion
    }
}

But you can simplify the sorting just by using the anonymous delegate as shown bellow and you don’t need to implement IComparable interface

var persons = new List<Person>
                    {
                        new Person("Tom", 30),
                        new Person("Harry", 55)
                    };
// sort in ascending order
persons.Sort(delegate(Person person0, Person person1)
                    {
                        return person0.FirstName.CompareTo(person1.FirstName);
                    });
// sort in descending order
persons.Sort(delegate(Person person0, Person person1)
                    {
                        return person1.FirstName.CompareTo(person0.FirstName);
                    });

Technorati tags: generic, c#, code

Measure and record C# code metrics.

SourceMonitor measures and records source code metrics. SourceMonitor parses ASCII source code looking for countable metrics items. As these items are identified, their counts are accumulated for each source code file, and within each function or method. These metrics are then accumulated into summary metrics for all files in each checkpoint.If you develop software with Visual Studio, you can add items to your tools menu in Visual Studio that invoke SourceMonitor. You can also operate SourceMonitor from a batch file using commands stored in a text file. SourceMonitor measures metrics for source code written in C++, C, C#, VB.NET, Java, Delphi, Visual Basic (VB6) or HTML.Exports metrics to XML or CSV for further processing with other tools.

C# Metrics

  1. Statements
  2. Percent Comment Lines
  3. Percent Documentation Lines
  4. Classes, Interfaces, Structs
  5. Methods per Class
  6. Statements per Method
  7. Calls per Method
  8. Maximum Method Complexity
  9. Maximum Block Depth
  10. Average Block Depth
  11. Average Complexity

Download SourceMonitor

 

Technorati Tags: ,,

CAKE3 – Free archiving .Net library

Cake3 library supports compressing and extracting filesĀ  to/from different archive formats .The library can be easily integrated to your projects .

Usage of Cake3 library:

Compress

Cakdir3 cdir3 = new Cakdir3(@"c:\temp\arch.lha");
cdir3.AddOptions.addFolder = AddOptions.folderMode.relative;
cdir3.AddOptions.baseFolder = @"c:\temp\";
//Mask not supported in Cake3.
cdir3.AddOptions.addFile = new String[2] {@"c:\temp\arch.zip", @"C:\temp\test\image.bmp"};
cdir3.Add();

Decompress

Cakdir3 cdir = new Cakdir3(@"c:\temp\test.lha");
cdir.ExtractOptions.extractItem = new String[1] {cdir.Archive_Contents[0].fileName};
cdir.ExtractOptions.extractFolder = Utils.GetTempPath() + "qztemp";
cdir.ExtractOptions.allowFolder = true;
cdir.ExtractOptions.allowOverwrite = true;

if (cdir.Extract())
 Console.WriteLine("Success");

Supported Archives(compress)

  • Zip archives (SharpZipLib)
  • 7z archives (7-zip32.dll)
  • lha archivesSupported Archives(extract only)
    • Zip archives (SharpZipLib)
    • 7z archives (7-zip32.dll)
    • Ace archives (acev2.dll)
    • Arj archives (Unarj32j.dll)
    • Lha archives (Unlha32.dll)
    • Sqx archives (Sqx20.dll)
    • Rar archives (unrar.dll)
    • Cab archives (Xacrett.dll)
    • Rar archives (Xacrett.dll)
    • Yz1 archives (Xacrett.dll)
    • Bga archives (Xacrett.dll)
    • Gca archives (Xacrett.dll)
    • Imp archives (Xacrett.dll)
    • Zoo archives (Xacrett.dll)
    • Arc archives (Xacrett.dll)
    • Cpt archives (Xacrett.dll)
    • Pit archives (Xacrett.dll)
    • Arg archives (Xacrett.dll)
    • Asd archives (Xacrett.dll)
    • Zac archives (Xacrett.dll)
    • MacBin archives (Xacrett.dll)
    • Tar, Cpio, Rpm archives (Xacrett.dll)
    • Shar archives (Xacrett.dll)
    • Quake Pak archives (Xacrett.dll)
    • Ar(Deb) archives (Xacrett.dll)
    • Gzip archives (Xacrett.dll)
    • Bzip2 archives (Xacrett.dll)
    • Compress archives (Xacrett.dll)
    • Pack archives (Xacrett.dll)
    • Compact archives (Xacrett.dll)
    • Freeze archives (Xacrett.dll)
    • Belon archives (Xacrett.dll)
    • Splint archives (Xacrett.dll)
    • Jam archives (Xacrett.dll)
    • MS-Compress archives (Xacrett.dll)
    • Base64 archives (Xacrett.dll)
    • UUEncoded files (Xacrett.dll)
    • XXEncoded files (Xacrett.dll)
    • BinHex archives (Xacrett.dll)
    • Ish archives (Xacrett.dll)
    • Boo archives (Xacrett.dll)
    • BtoA archives (Xacrett.dll)
    • Fish archives (Xacrett.dll)
    • Jack archives (Xacrett.dll)
    • Rez archives (Xacrett.dll)
    • Cab(InstallShield) archives (Xacrett.dll)
    • Dzip archives (Xacrett.dll)
    • yEnc archives (Xacrett.dll)
    • Dmg archives (Xacrett.dll)
    • BriefLZ archives (Xacrett.dll)
    • ISO (Xacrett.dll)
    • Alz archives (Xacrett.dll)
    • Lzx archives (Xacrett.dll)
    • Jcalgl archives (Xacrett.dll)
    • apLib archives (Xacrett.dll)
    • Neo_ASK archives (Xacrett.dll)

    Download Cake3

  • CS2-C# Code Search

    CS2 is capable of indexing source code files (at the moment only C# code can be parsed) and searching among them with various parameters, like class, property and method names, as well as full-text queries.

    The main user interface for interacting with the search engine is an ASP.NET website built for version 2.0 of the .NET framework .

    Download CS2 Search Engine

    [Via dotnetkicks.com]


    Page 1 of 1412345...10...Last »