Abstract Nonsense in Software Development

Published on 16 January 2019 10:00 AM
This post thumbnail

Database Domain

Introduction

This article contains further development of my articles devoted to common problems and real-time. This article depends on previous ones.

My samples are accomplished with "serialized" samples where data sets are serialized. Usage of these samples does not require SQL server databases.

IMPORTANT: The demo solution contains the OracleTableProvider project. This project is intended for support of the Oracle client. If the Oracle client is not installed, then the OracleTableProvider project should be excluded from the solution.

Background

The Database domain contains the following base types.

  • IDataSetProvider: This interface is implemented by any object that supplies a DataSet.
  • IDataSetConsumer: This interface is implemented by any object that uses a DataSet.
  • DataSetArrow: Source (resp. target) of this arrow should implement IDataSetConsumer (resp. IDataSetProvider interface).
/// Provider of data set
public interface IDataSetProvider
{
    /// Provided data set
    DataSet DataSet { get; }

    /// Factory. This object can be null. It is not null for databases (SQL Server, Oracle, ...)
    IDataSetFactory Factory { get; set; }

    /// Change event
    event Action<DataSet> Change;
}

/// Data set consumer
public interface IDataSetConsumer
{
    /// Adds data set
    void Add(DataSet dataSet);

    /// Removes data set
    void Remove(DataSet dataSet);

    IDataSetFactory Factory { get; set; }

    event Action<DataSet> OnAdd;

    event Action<DataSet> OnRemove;
}

/// Arrow between data set provider and data set consumer
[Serializable()]
public class DataSetArrow : CategoryArrow, ISerializable, IRemovableObject
{
    protected IDataSetConsumer source;
    protected IDataSetProvider target;

    // Constructors

    public DataSetArrow()
    {
    }

    public DataSetArrow(SerializationInfo info, StreamingContext context)
    {
    }

    // ISerializable Members

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
    }

    // ICategoryArrow Members

    public override ICategoryObject Source
    {
        get
        {
            return source as ICategoryObject;
        }
        set
        {
            source = value.GetSource<IDataSetConsumer>();
        }
    }

    public override ICategoryObject Target
    {
        get
        {
            return target as ICategoryObject;
        }
        set
        {
            target = value.GetSource<IDataSetProvider>();
        }
    }
}

Cat and apple Markdown doesn’t natively support image captions, but there are two possible workarounds.