|
//================================================================================
//
// Copyright (c) objectnation GmbH, 2002
//
//================================================================================
//
// Author simon.wilson
// Creation Date 12.09.2002
// Creation Time 12:49:09
// IDE Version Microsoft Development Environment Enterprise Edition 7.00
// OS Version Microsoft Windows NT 5.1.2600.0
//
//================================================================================
#region Copyright � objectnation GmbH, 2002
// This software is provided 'as-is'. While the greatest care has been taken to
// ensure that the software functions correctly, no guarantee can be made to this effect.
//
// objectnation grants permission to anyone to use this software for any purpose as long as
// it is in compliance with the following restrictions:
//
// 1. This software is the intellectual property and copyright of objectnation GmbH.
// Under no circumstances may the origin of the software be misrepresented.
//
// 2. Should this software be used in the development of a commercial product,
// then an acknowledgement in that product's documentation is a requirement.
// The following text should be used:
//
// This product contains code generated by objectnation SP/Invoke,
// copyright � objectnation GmbH 2002 (http://www.objectnation.com).
//
// 3. The software may not be redistributed without the express written permission of
// the copyright holder, namely objectnation GmbH, Switzerland.
#endregion
using System;
using System.Collections;
using System.Collections.Specialized;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
namespace objectnation.SPInvoke
{
public abstract class TypeGenerator : Generator
{
string _typeName;
StoredProcedure _storedProc;
TypeAttributes _visibility = TypeAttributes.NotPublic;
//============================================================================
public TypeGenerator()
{
_typeName = string.Empty;
}
//============================================================================
public TypeGenerator(
StoredProcedure storedProc,
CodeDomProvider provider,
string typeName,
TypeAttributes visibility) : base(provider)
{
_storedProc = storedProc;
_typeName = typeName;
_visibility = visibility;
}
//============================================================================
public StoredProcedure Source
{
get { return _storedProc; }
set { _storedProc = value; }
}
//============================================================================
public string TypeName
{
get
{
if(_typeName == null || _typeName.Length == 0)
return CreateCodeCompatibleName(Source.Name);
return _typeName;
}
set { _typeName = value; }
}
//============================================================================
public TypeAttributes Visibility
{
get { return _visibility; }
set { _visibility = value; }
}
//============================================================================
public abstract CodeTypeDeclarationCollection Generate();
//============================================================================
protected string CreateCodeCompatibleName(string name)
{
string identifier = string.Empty;
foreach(char c in name)
{
if(!char.IsLetterOrDigit(c))
identifier += '_';
else
identifier += c;
}
ICodeGenerator generator = Provider.CreateGenerator();
while(!generator.IsValidIdentifier(identifier))
identifier = '_' + identifier;
return identifier;
}
}
//==============================================================================
public class TypeGenerators : CollectionBase
{
public TypeGenerators() : base()
{
}
public void Add(TypeGenerator generator)
{
List.Add(generator);
}
public TypeGenerator this [int index]
{
get { return (TypeGenerator) List[index]; }
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.