TECH NOTES

September 16, 2008

CodeProject Pick: “SQLite Membership, Role, and Profile Providers”

Filed under: IT CodeProject Picks, IT Tools & Code — Black Falcon @ 11:31 pm
Tags:


Go here for article source…

SQLite Membership, Role, and Profile Providers

By Roger Martin

Introduction

This is an implementation of the Membership, Role, and Profile providers for ASP.NET 2.0. It is fully functional, except there is no support for saving or reading binary objects to/from the profile provider.

This is the same code that is included with the shipping release of Gallery Server Pro, so you can be assured it is production ready. However, if you do find any issues, please contact me and I will correct them.

It is intended that this code can be used as a drop-in replacement for the SQL Server providers by Microsoft. You can even use the backup/restore functionality in Gallery Server Pro to migrate your SQL Server membership, role, and profile data to SQLite, or the other way around. (You don’t have to use the rest of the Gallery Server Pro functionality if all you need is help migrating your users.)

(more…)

August 20, 2008

CodeProject Pick: “Active Directory Roles Provider”

Filed under: IT CodeProject Picks, IT Tools & Code — Black Falcon @ 11:22 pm
Tags: ,



Active Directory Roles Provider

By Daniel_PS

Go here for article source…

Contents

Introduction

So, you’ve made a website using ActiveDirectoryMembershipProvider. You decide to use forms-based authentication. You knew to use an SSL-secured log-in page so that domain accounts and passwords aren’t floating around the internet in plain text. You want to now set up your roles in Active Directory using group membership, so you come across WindowsTokenRoleProvider. It’s a role provider that operates off Windows groups, so it should do the trick, right?

Of course, it doesn’t, since you are using forms-based authentication, and not integrated authentication. The best solution you are left with is setting up AzMan, but there’s a significant learning curve and a lot of conflicting information out there regarding it.

That’s where ADRoleProvider comes in to play. Simply stated, ADRoleProvider is a RoleProvider class that translates your Active Directory groups into Roles, and uses group membership as role membership. Since it inherits from RoleProvider, it should function seamlessly in your site and work with all the standard .NET controls (LoginView, etc) and Web.config authorization settings.

As long as you are aware of its limitations (see technical and security concerns below), it may foot the bill. Please make certain that you read through this documentation and understand the security and performance concerns mentioned. Also, look through the code to gain an understanding of what exactly it does. I’ve tried to make the code as solid as possible, but it is still a work in progress.

If you spot a bug, memory leak, or security risk that I haven’t accounted for, please notify me ASAP.

(more…)

August 12, 2008

CodeProject Pick: Write a Compiler With Herre Kuijpers’ “TinyPG”

Filed under: IT CodeProject Picks — Black Falcon @ 11:20 pm
Tags: ,



Go here for article source…

A Tiny Parser Generator

By Herre Kuijpers

TinyPG is a utility that makes it easier to write and try out your own parser/compiler

Introduction

TinyGP stands for “Tiny Parser Generator”. This particular generator is an LL(1) recursive descent parser generator. This means that instead of generating a state machine out of a grammar like most compiler compilers, instead it will generate source code directly; basically generating a method for each non-terminal in the grammar. Terminals are expressed using .Net’s powerful regular expressions. To help the programmer create .Net regular expressions a Regex tool is embedded in TinyPG. Grammars can be written using the extended BNF notation. TinyGP will generate a scanner, parser and parsetree file in c# code from this which can be compiled directly into your own projects.

In this article I will not go into depth about compiler theory. Basic understanding of compilers and grammars is required. For your reference I have included a list of terms used in this article explained on Wikipedia: grammar, BNF, terminal, non-terminal, LL(1), lookahead, recursive decent, concrete syntax tree (CST) , parse tree,

Nowadays, with the availability of numerous compiler compilers, it becomes hard to think of a new name for a compiler compiler. ‘Yet Another Compiler Compiler’ was taken so I decided to name this tiny tool after its many strengths:

  • a powerful tiny utility (<100KB) in which to define the grammar for the new compiler, allowing
  • syntax and semantics checking of the grammar
  • generating a tiny set of sources for the parser/scanner/parsetree (just 3 .cs files without any external dependencies)
  • while each generated file remains clearly human readably and debuggable with visual studio(!)
  • including an expression evaluation tool which
  • generates a traversable parse tree
  • option to include c# codeblocks inside the grammar, adding immediate functionality with just a few lines of code.
  • including a tiny regular expression tool
  • while trying to keep things as simple and tiny as possible.

Background

Since there are already a number of compiler compilers out there, you might wonder why write another one? The reasons for writing this utility are:

  • the fun factor, seriously, who doesn’t want to write his/her own compiler compiler!? 8-)
  • the compiler compiler should be able to generate c# code
  • the utility should be free, allowing developers to use the generated code for whatever purpose (no restrictive licenses).
  • the generated code should be readable and relatively easy to debug if needed.
  • the generated code should be completely independent and not require any external libraries to run (e.g. libraries from the compiler compiler itself !)
  • source code available to allow developers to modify this utility as they like
  • the tool should be free
  • it should be possible to separate the semantics from the syntax (use subclassing), or combine them (inline codeblocks)

(more…)

July 3, 2008

CodeProject Pick: Duplex Web Services

Filed under: IT CodeProject Picks — Black Falcon @ 1:43 am
Tags:

Duplex Web Services

By Boaz Davidoff

Using multi-threading techniques to create a duplex (two-way) web service that can push events/messages to the client.

Go here for article source…

Introduction

While doing a code review for a friend of mine, I came across an interesting technique for getting a web service to “push” an event or message back to the client when something occurs. We all know that the HTTP is a request/response protocol. The client makes a request, a socket is opened, the server allocates a thread for the request, the request is processed, the results are returned, and the socket is closed. In the code that I saw, and reworked/improved for this example, web services are used to communicate events or messages between the request and the response.

Think of a chat room application entirely handled by web services. The various “events” or messages that would have to be passed between users include “user has logged in”, “user has logged out”, and the actual text messages sent.


(more…)

CodeProject Pick: SQL Server to SQL Server Compact Edition Database Copy Utility

Filed under: IT CodeProject Picks — Black Falcon @ 1:26 am
Tags: , , ,

CodeProject Pick: ASP.NET File Manager

Filed under: IT CodeProject Picks — Black Falcon @ 1:10 am
Tags: ,

CodeProject Pick: A lightweight AJAX.NET-enabled grid control

Filed under: IT CodeProject Picks, Uncategorized — Black Falcon @ 12:58 am
Tags: , ,

A lightweight AJAX.NET-enabled grid control

By Simon Gulliver

A lighweight approach to creating AJAX.NET-enabled grids, with advanced functionality built in.

Go here for article source…

Introduction

Managing lists of items from databases is the bread and butter of most web applications, but creating an user-friendly grid can be problematic. The obvious solution of creating Microsoft grid controls in an Ajax.Net Update panel can create very large HTML pages with long response times when a substantial amount of data is being worked with. Also, every grid has to be created individually on each page, and that makes it hard to create and maintain a common “look and feel”.

This lightweight grid outputs very compact HTML and uses javascript to dynamically generate input or select boxes when updating. It includes built-in Ajaxed sorting and filtering which is very user-friendly, and throws in csv export for free. It has a fixed table header and scrolling contents, to facilitate use with large amounts of data.

Many different grids can be very quickly generated in a standard way using an XML control file and a single common style sheet. Multiple AjaxGrids can be defined and used, even on the same page.

You can customise grid column data to include links, images, etc and to support your own custom validations.


(more…)

June 3, 2008

CodeProject Pick: “NArrange” – VS.NET Code Beautifier

Filed under: IT CodeProject Picks — Black Falcon @ 1:48 am

Go here for article source and downloads…

NArrange – .NET Code Organizer

By James Nies

Using NArrange to Organize C# Source Code

Introduction

NArrange is a stand-alone, configurable .NET code beautification tool that automatically organizes code members and elements within .NET classes. It allows developers to easily sort class contents according to their style and layout conventions. NArrange works by parsing source code files into a document object model, arranging the elements then rewriting the arranged source code.

NArrange helps reduce the amount of time developers spend arranging members within source code files and when used a part of check-in procedures can also help reduce source code repository conflicts. With NArrange, developers don’t need to worry about where they place a new member definition in a class, they can just type away and run NArrange prior to compilation. After formatting, the new member will be automatically moved to the appropriate location in the source file. NArrange is not only a great time saver, but it also helps enforce coding style standards across a team when a common configuration file is used.

Obtaining NArrange

NArrange is an open source tool and can be downloaded from SourceForge at http://sourceforge.net/project/showfiles.php?group_id=213288.

Using NArrange

To demonstrate the common usage scenarios of NArrange we’ll start by creating a new project in our C# editor, in this case Visual Studio®, and add a stub class with a constructor. Note that since NArrange is a stand-alone tool without any IDE dependencies, it can be used along with any code editor or within automated build processes.


Figure: New Project with a Class Stub

(more…)

CodeProject Pick: LINQ to SQL… All in one base class

Filed under: IT CodeProject Picks — Black Falcon @ 1:38 am


Go here for article source and downloads…

LINQ to SQL: All common operations (Insert, Update, Delete, Get) in one base class

By Yazeed Hamdan

A base class to perform all common LINQ to SQL operations.

Introduction

I have been playing with LINQ to SQL for a bit. It is great and easy to use along with the designer that ships with VS.NET 2008. I wanted to create a Facade layer that integrates with LINQ to SQL classes. The old school way is to create a public class (Manager) and this class calls your database mappers to get/set the required info. Now, LINQ to SQL replaces those mapper classes, and the way to do your operations is to open the DataContext and start defining queries to perform such operations.

So, I grouped those queries and operations into another separate layer called Processes/Operations layer in which the facade will end up calling. By doing that, the Facade remains as is and the Processes/Operations layer replaces the mappers layer while it encapsulates the whole logic and complexity for the DB operations.

Having said that, I created a base class which encapsulates the most common logic for database operations in the Processes/Operations layer instead of repeating the same code over and over for each class.

Note: This article is intended for people familiar with LINQ and LINQ to SQL.

Using the code

Class definition

Shown below is the definition of the class:

internal class DataBaseProcessBase<T, DC> where T :

class, new() where DC : DataContext, new()

As you can notice, this is a generic class taking two types: the first one is your entity type, while the second is your DataContext. Moving forward, here are the operations listed in that class:

  1. Add
  2. Get
  3. Update
  4. Delete

You just create a class that inherits from this one, as follows:

internal class MyProcess : DataBaseProcessBase<MyEntity,MyDataContext>

(more…)

October 4, 2007

Code Project Pick: “HTTP File Downloader Class for .NET”

Filed under: IT CodeProject Picks, IT Tools & Code — Black Falcon @ 2:25 am


HTTP File Downloader Class for .NET
Click title for source at CodeProject.com…

By Alex_1


(more…)

Next Page »

Blog at WordPress.com.