831ec37cda
Printed bill can no longer be changed, any changes voids the bill and prints a new one. Added option to Split Bill. Kot printed with right time. Numerous bug fixes.
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using FluentNHibernate.Conventions;
|
|
using FluentNHibernate.Conventions.Inspections;
|
|
using FluentNHibernate.Conventions.Instances;
|
|
|
|
namespace Tanshu.Accounts.Conventions
|
|
{
|
|
public class PropertyAccessConvention : IPropertyConvention
|
|
{
|
|
public void Apply(IPropertyInstance instance)
|
|
{
|
|
var entityType = instance.EntityType;
|
|
var camelCaseUnderscoreName = ConvertToCamelCaseUnderscore(instance.Name);
|
|
|
|
// Default is to use property setter, so only modify mapping
|
|
// if there is a backing field
|
|
|
|
if (HasField(entityType, camelCaseUnderscoreName))
|
|
instance.Access.CamelCaseField(CamelCasePrefix.Underscore);
|
|
}
|
|
|
|
private static string ConvertToCamelCaseUnderscore(string propertyName)
|
|
{
|
|
return "_" + propertyName[0].ToString().ToLower() + propertyName.Substring(1);
|
|
}
|
|
|
|
private static bool HasField(Type type, string fieldName)
|
|
{
|
|
var backingField = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
|
return backingField != null;
|
|
}
|
|
}
|
|
}
|
|
|
|
|