Archive for the Category dotnet

 
 

Return the value for the specific attribute using XPathNodeIterator

I will use the following XML document in the example below.

<?xml version="1.0" encoding="utf-8" ?>
<users>
  <user FirstName="Tom" LastName="Adams" Age="23" />
  <user FirstName="Jhon" LastName="Brams" Age="17" />
  <user FirstName="Bill" LastName="Smith" Age="33" />
</users>

The code prints out all the user nodes of the users node that  have an age with a value greater than 17.

// Read the xml from resource file 
string xml = Resources.Users; 
using (StringReader sr = new StringReader(xml)) 
{ 
    XPathDocument document = new XPathDocument(sr); 
    XPathNavigator navigator = document.CreateNavigator(); 
    XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable); 
    //Selects all the user nodes of the users node that 
    // have an age with a value greater than 17  
    XPathNodeIterator it = navigator.Select("/users/user[@Age>17]"); 
    while (it.MoveNext()) 
    { 
        // access the atributes  
        string firstName = it.Current.GetAttribute("FirstName", ns.DefaultNamespace); 
        string lastName = it.Current.GetAttribute("LastName", ns.DefaultNamespace); 
        // Print out  
        Console.WriteLine( "{0} {1}", firstName, lastName ); 
    } 
}

C# String Library by Chad Finsterwald

Inspired by PHP String Functions that are missing in .Net.

Below is a list of the method names and descriptions in the string library.

  • Base64StringEncode: Base64 encodes a string.
  • Base64StringDecode: Decodes a Base64 string.
  • CaseInsenstiveReplace: A case insenstive replace function.
  • ReplaceFirst: Replaces the first occurence of a string with the replacement value. The Replace is case senstive. [The inclusion of this method and ReplaceLast was suggested by a reader's comment.]
  • ReplaceLast: Replaces the last occurence of a string with the replacement value. The replace is case senstive.
  • FilterWords: Removes all the words passed in the filter words parameters. The replace is NOT case sensitive.
  • HasWords: Checks the passed string to see if it contains any of the passed words. Not case-sensitive.
  • HtmlSpecialEntitiesEncode: A wrapper around HttpUtility.HtmlEncode.
  • HtmlSpecialEntitiesDecode: A wrapper around HttpUtility.HtmlDecode.
  • MD5String: MD5 encodes the passed string.
  • MD5VerifyString: Verifies a string against the passed MD5 hash.
  • PadLeftHtmlSpaces: Left pads the passed string using the HTML non-breaking space ( ) for the total number of spaces.
  • CaseInsenstiveReplace: Performs a case insenstive replace.
  • PadLeft: Left pads the passed string using the passed pad string for the total number of spaces. (It will not cut-off the pad even if it causes the string to exceed the total width.)
  • PadRightHtmlSpaces: Right pads the passed string using the HTML non-breaking space ( ) for the total number of spaces.
  • PadRight: Right pads the passed string using the passed pad string for the total number of spaces. (It will not cut-off the pad even if it causes the string to exceed the total width.)
  • RemoveNewLines: Removes the new line (\n) and carriage return (\r) symbols.
  • Reverse: Reverses the passed string.
  • SentenceCase: Converts a string to sentence case.
  • SpaceToNbsp: Converts all spaces to HTML non-breaking spaces.
  • StripTags: Removes all HTML tags from the passed string.
  • TitleCase: Converts a string to title case.
  • TrimIntraWords: Removes multiple spaces between words.
  • NewLineToBreak: Converts each new line (\n) and carriage return (\r) symbols to the HTML
    tag.
  • WordWrap: Wraps the passed string at the passed total number of characters (if cuttOff is true)or at the next whitespace (if cutOff is false). Uses the environment new linesymbol for the break text.

Technorati tags: string, php, dotnet, c#, library

Regular Expression Library by Chad Finsterwald

A utility class containing frequently used Regular Expression Patterns( dates, zip codes, url ,email, credit card )  and two utility methods to see if a passed string conforms to the designated  pattern.

[Via Help.Net]

Krypton Toolkit-Free user interface controls for .NET2

The Krypton Toolkit contains:

KryptonButton

KryptonCheckButton

KryptonSplitContainer

KryptonHeaderGroup

KryptonManager

KryptonPalette

KryptonGroup

KryptonHeader

KryptonPanel

 

 

Download Krypton Toolkit Version 2.2

ZipForge.NET

ZipForge.NET is a .NET framework zip component. With this component you can easily add zip archive functionality to your projects. Free for personal use.ZipForge.NET is 100% managed .NET component written in pure C#.

Features:

  • 100% managed code without unsafe blocks
  • Creates and handles ZIP files
  • Adds, moves, extracts, deletes, updates, tests, refreshes a group of files by a single operation
  • Streaming support
  • Progress indication
  • Encryption\decryption
  • Transactions
  • Zip64 support (allows to create archives over 4Gb)
  • Supports .NET 1.1 and 2.0
  • A lot of demos (C#, VB.NET and Delphi.NET demos are included)
  • Extensive help

ZIP compatibility

  • 100% PKZIP 2.x compatible format
  • Password protection
  • ZIP compatible self extracting archives (SFX)

Download ZipForge.Net


Page 4 of 14« First...23456...10...Last »