Skip to content

Commit

Permalink
Ported library from VB.NET to C#. Closes #61.
Browse files Browse the repository at this point in the history
All source code has been migrated to C# from VB.NET to allow for better
cross platform usability. Functionality remains identical. Note: there
may be some minor changes due to the way VB.NET handles strings.
  • Loading branch information
hisystems committed Jul 23, 2012
1 parent 3618d56 commit af1a55f
Show file tree
Hide file tree
Showing 286 changed files with 18,094 additions and 19,352 deletions.
96 changes: 96 additions & 0 deletions Attributes/DistinctFieldAttribute.cs
@@ -0,0 +1,96 @@
// ___________________________________________________
//
// © Hi-Integrity Systems 2010. All rights reserved.
// www.hisystems.com.au - Toby Wicks
// ___________________________________________________
//

using System.Collections;
using System;
using System.Data;

/// --------------------------------------------------------------------------------
/// <summary>
/// Specifies the field name that uniquely identifies each object
/// within the collection. Typically, this is the field name of an identity or auto
/// increment field. If the SubSetAttribute has been specified
/// then the strDistinctFieldName need only be unique within the subset not the
/// entire table. The strDistinctFieldName and can be identical to the field name
/// specified with a KeyField attribute.
/// This attribute must be specified on a DatabaseObjects*UsingAttributes class.
/// This attribute is used to implement the IDatabaseObjects.DistinctFieldName
/// and IDatabaseObjects.DistinctFieldAutoIncrements functions.
/// </summary>
/// <example>
/// <code>
/// &lt;DistinctField("CustomerID", bAutoIncrements:=True)&gt;
/// Public Class Customers
/// ...
/// </code>
/// </example>
/// --------------------------------------------------------------------------------
namespace DatabaseObjects
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class DistinctFieldAttribute : Attribute
{
private string pstrDistinctFieldName;
private SQL.FieldValueAutoAssignmentType peFieldValueAutomaticAssignment = SQL.FieldValueAutoAssignmentType.None;

/// <summary>
/// Specifies the field name that uniquely identifies each object
/// within the collection.
/// </summary>
public DistinctFieldAttribute(string strDistinctFieldName)
: this(strDistinctFieldName, bAutoIncrements: false)
{
}

/// <summary>
/// Specifies the field name that uniquely identifies each object
/// within the collection. Typically, this is the field name of an identity or auto
/// increment field in which case the bAutoIncrements value should be set to true.
/// </summary>
public DistinctFieldAttribute(string strDistinctFieldName, bool bAutoIncrements)
{
if (String.IsNullOrEmpty(strDistinctFieldName))
throw new ArgumentNullException();

pstrDistinctFieldName = strDistinctFieldName;

if (bAutoIncrements)
peFieldValueAutomaticAssignment = SQL.FieldValueAutoAssignmentType.AutoIncrement;
}

/// <summary>
/// Specifies the field name that uniquely identifies each object
/// within the collection. Typically, this is the field name of an identity or auto
/// increment field in which case the bAutoIncrements value should be set to true.
/// </summary>
public DistinctFieldAttribute(string strDistinctFieldName, SQL.FieldValueAutoAssignmentType eAutomaticAssignment)
{
if (String.IsNullOrEmpty(strDistinctFieldName))
throw new ArgumentNullException();

pstrDistinctFieldName = strDistinctFieldName;
peFieldValueAutomaticAssignment = eAutomaticAssignment;
}

public string Name
{
get
{
return pstrDistinctFieldName;
}
}

public SQL.FieldValueAutoAssignmentType AutomaticAssignment
{
get
{
return peFieldValueAutomaticAssignment;
}
}
}

}
99 changes: 0 additions & 99 deletions Attributes/DistinctFieldAttribute.vb

This file was deleted.

65 changes: 65 additions & 0 deletions Attributes/FieldMappingAttribute.cs
@@ -0,0 +1,65 @@
// ___________________________________________________
//
// © Hi-Integrity Systems 2010. All rights reserved.
// www.hisystems.com.au - Toby Wicks
// ___________________________________________________
//

using System.Collections;
using System;
using System.Data;

/// --------------------------------------------------------------------------------
/// <summary>
/// The FieldMappingAttribute class is used to define a mapping between a database
/// field and a class property. This attribute is used with the
/// DatabaseObjectUsingAttributes class.
/// This field can also be used for loading fields that are of type
/// DatabaseObjects.ObjectReference or DatabaseObjects.Generic.ObjectReference.
/// </summary>
/// --------------------------------------------------------------------------------
namespace DatabaseObjects
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class FieldMappingAttribute : Attribute
{
private string pstrFieldName;

/// --------------------------------------------------------------------------------
/// <param name="strFieldName">
/// The name of the database field associated with this property or field.
/// </param>
/// <example>
/// Loads a field:
/// <code>
///
/// &lt;DatabaseObjects.FieldMapping("Name")&gt; _
/// Private pstrName As String
///
/// </code>
/// Loads an object:
/// <code>
///
/// &lt;DatabaseObjects.FieldMapping("ProductGroupID")&gt; _
/// Private pobjGroup As New Generic.ObjectReference(Of ProductGroup, Integer)(Database.ProductGroups)
///
/// </code>
/// </example>
/// --------------------------------------------------------------------------------
public FieldMappingAttribute(string strFieldName)
{
if (String.IsNullOrEmpty(strFieldName))
throw new ArgumentNullException();

pstrFieldName = strFieldName;
}

public string FieldName
{
get
{
return pstrFieldName;
}
}
}
}
63 changes: 0 additions & 63 deletions Attributes/FieldMappingAttribute.vb

This file was deleted.

32 changes: 32 additions & 0 deletions Attributes/FieldMappingObjectHookAttribute.cs
@@ -0,0 +1,32 @@
// ___________________________________________________
//
// © Hi-Integrity Systems 2010. All rights reserved.
// www.hisystems.com.au - Toby Wicks
// ___________________________________________________
//

using System.Collections;
using System;
using System.Data;

/// --------------------------------------------------------------------------------
/// <summary>
/// Used to mark a property or field that reference an object for which database
/// fields need to be loaded. The referenced object then contain fields or properties
/// marked with FieldMappingAttribute.
/// The field must be marked on a reference type field not a value based field.
/// This attribute is useful in situations where another class (usually an inner class)
/// holds a reference to an object that contains additional properties that are stored
/// in the same record as the main container class.
/// </summary>
/// --------------------------------------------------------------------------------
namespace DatabaseObjects
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class FieldMappingObjectHookAttribute : Attribute
{
public FieldMappingObjectHookAttribute()
{
}
}
}
28 changes: 0 additions & 28 deletions Attributes/FieldMappingObjectHookAttribute.vb

This file was deleted.

0 comments on commit af1a55f

Please sign in to comment.