博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

CodeBuilder之Source接口

Posted on 2010-01-11 00:05  faib  阅读(452)  评论(0编辑  收藏  举报

ISource接口

代码
using System;
using System.Collections.Generic;

namespace FaibClass.SourcePackage
{
    
/// <summary>
    
/// 提供数据源接口。
    
/// </summary>
    public interface ISource : BasePackage.IPackage, IDisposable
    {
        
/// <summary>
        
/// 打开获取数据源的对话框。
        
/// </summary>
        
/// <param name="option"></param>
        
/// <returns>如果打开失败返回false。</returns>
        bool Open(SourceOptions option);
        
/// <summary>
        
/// 打开数据源地址。
        
/// </summary>
        
/// <param name="option"></param>
        
/// <param name="url"></param>
        void Open(SourceOptions option, string url);
        
/// <summary>
        
/// 获取历史列表。
        
/// </summary>
        
/// <returns></returns>
        Dictionary<stringobject> GetRecentHistory();
        
/// <summary>
        
/// 表集合。
        
/// </summary>
        Collection<ITable> Tables { get; }
        
string Schema { get; }
        
/// <summary>
        
/// 获取当前数据源中的所有表集合。
        
/// </summary>
        void GetTables();
        
/// <summary>
        
/// 获取表的个数。
        
/// </summary>
        
/// <returns></returns>
        int GetTableCount();
        
/// <summary>
        
/// 获取数据类型。
        
/// </summary>
        string DbType { get; }
        
/// <summary>
        
/// 用到的枚举集合。
        
/// </summary>
        Collection<DbEnum> Enums { get; }
        
/// <summary>
        
/// 获取到表时触发事件。
        
/// </summary>
        event GetTableEventHandler GetTable;
        
string OutputFolder { getset; }
        ITable CreateTable(
string name);
    }
    
public delegate bool GetTableEventHandler(ITable table);
}

 

 

ITable接口

代码
using System.ComponentModel;
using System.Drawing.Design;

namespace FaibClass.SourcePackage
{
    
/// <summary>
    
/// 提供与数据表对应的接口。
    
/// </summary>
    public interface ITable
    {
        
/// <summary>
        
/// 获取该表的所有字段。
        
/// </summary>
        
/// <returns></returns>
        Collection<IColumn> Columns { get; }
        
/// <summary>
        
/// 表的名称。
        
/// </summary>
        string Name { getset; }
        
/// <summary>
        
/// 对应类的名称。
        
/// </summary>
        string ClassName { getset; }
        
/// <summary>
        
/// 表的说明。
        
/// </summary>
        string Description { getset; }
        
/// <summary>
        
/// 与之关联的外键。
        
/// </summary>
        Collection<IForeignKey> SubKeys { get; }
        
/// <summary>
        
/// 主键。
        
/// </summary>
        Collection<IPrimaryKey> PrimaryKeys { get; }
        
/// <summary>
        
/// 外键。
        
/// </summary>
        Collection<IForeignKey> ForeignKeys { get; }
        
/// <summary>
        
/// 数据源对象。
        
/// </summary>
        ISource Owner { get; }
        
/// <summary>
        
/// 是否选中。
        
/// </summary>
        bool Checked { getset; }
        
/// <summary>
        
/// 依存关系。
        
/// </summary>
        ReferenceGroup Reference { get; }
        
/// <summary>
        
/// 继承的表。
        
/// </summary>
        ITable Parent { getset; }
        IColumn CreateColumn(
string name);
    }
}

 

IColumn接口

代码
using System.ComponentModel;

namespace FaibClass.SourcePackage
{
    
/// <summary>
    
/// 提供与字段对应的接口。
    
/// </summary>
    public interface IColumn
    {
        
/// <summary>
        
/// 该字段的名称。
        
/// </summary>
        string Name { getset; }
        
/// <summary>
        
/// 对应属性的名称。
        
/// </summary>
        string PropertyName { getset; }
        
/// <summary>
        
/// 该字段的说明。
        
/// </summary>
        string Description { getset; }
        
/// <summary>
        
/// 该字段的数据类型。
        
/// </summary>
        string DataType { getset; }
        
/// <summary>
        
/// 该字段的属性数据类型。
        
/// </summary>
        string PropertyType { getset; }
        
/// <summary>
        
/// 该字段的长度。
        
/// </summary>
        long ? Length { getset; }
        
/// <summary>
        
/// 该字段的默认值。
        
/// </summary>
        string DefaultValue { getset; }
        
/// <summary>
        
/// 该字段的小数位数。
        
/// </summary>
        int ? Scale { getset; }
        
/// <summary>
        
/// 该字段的精度。
        
/// </summary>
        int ? Precision { getset; }
        
/// <summary>
        
/// 该字段是否可为空。
        
/// </summary>
        bool IsNullable { getset; }
        
/// <summary>
        
/// 该字段是否自动生成。
        
/// </summary>
        bool AutoGenerate { getset; }
        
/// <summary>
        
/// 该字段对应的主键。
        
/// </summary>
        IPrimaryKey PrimaryKey { getset; }
        
/// <summary>
        
/// 该字段对应的外键。
        
/// </summary>
        IForeignKey ForeignKey { getset; }
        
/// <summary>
        
/// 对应的枚举。
        
/// </summary>
        DbEnum Enum { getset; }
        
/// <summary>
        
/// 用当前字段创建主键。
        
/// </summary>
        
/// <returns></returns>
        IPrimaryKey CreatePrimaryKey();
        
/// <summary>
        
/// 表对象。
        
/// </summary>
        ITable Owner { get; }
        
/// <summary>
        
/// 绑定外键。
        
/// </summary>
        
/// <param name="table">主表。</param>
        
/// <param name="column">主键。</param>
        
/// <returns></returns>
        IForeignKey BindForeignKey(ITable table, IColumn column);
        
/// <summary>
        
/// 是否选中。
        
/// </summary>
        bool Checked { getset; }
    }
}

 

IPrimaryKey接口

代码
using System.Drawing.Design;
using System.ComponentModel;

namespace FaibClass.SourcePackage
{
    
/// <summary>
    
/// 提供与主键对接的接口。
    
/// </summary>
    public interface IPrimaryKey
    {
        
/// <summary>
        
/// 主键的对应的列。
        
/// </summary>
        IColumn Column { get; }
    }
}

 

IForeignKey接口

代码
using System.Drawing.Design;
using System.ComponentModel;

namespace FaibClass.SourcePackage
{
    
/// <summary>
    
/// 提供与外键对接的接口。
    
/// </summary>
    public interface IForeignKey
    {
        
/// <summary>
        
/// 外表的名称。
        
/// </summary>
        ITable FK_Table { get; }
        
/// <summary>
        
/// 外表字段的名称。
        
/// </summary>
        IColumn FK_Column { get; }
        
/// <summary>
        
/// 主表的名称。
        
/// </summary>
        ITable PK_Table { get; }
        
/// <summary>
        
/// 主表字段的名称。
        
/// </summary>
        IColumn PK_Column { get; }
        
/// <summary>
        
/// 级联更新。
        
/// </summary>
        bool CascadeUpdate { getset; }
        
/// <summary>
        
/// 级联删除。
        
/// </summary>
        bool CascadeDelete { getset; }
    }
}

 

IDataExtendObject接口

代码
using System;
using System.Reflection;
using System.Collections;
using System.ComponentModel;
using FaibClass.BasePackage;

namespace FaibClass.SourcePackage
{
    
public interface IDataExtendObject : IPackage
    {
        IDataExtendProvider Owner { 
setget; }
        ExtendFor For { 
get; }
    }

    
public interface IDataExtendProvider
    {
        IDataExtendObject ExtendObject { 
getset; }
        Hashtable TemporaryVariable { 
get; }
    }
}