init
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
//***************************************************************************//
|
||||
// Pool támogató szekciót generál egy osztályhoz //
|
||||
//***************************************************************************//
|
||||
template GeneratePoolableSection(classname, ismasterentity, customname)
|
||||
#region Pool-lal kapcsolatos műveletek
|
||||
|
||||
private static readonly PoolableFactory m_Factory = new [classname]Factory();
|
||||
private static readonly ObjectPool m_Pool = new ObjectPool(m_Factory);
|
||||
protected override PoolableFactory GetFactory() { return m_Factory; }
|
||||
protected override ObjectPool GetPool() { return m_Pool; }
|
||||
|
||||
private sealed class [classname]Factory : PoolableFactory
|
||||
{
|
||||
public Poolable CreateObject() { return new [customname](); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visszaad egy alapállapotú [classname] entitáspéldányt, lehetőleg pool-ból.
|
||||
/// </summary>
|
||||
/// <returns>Egy alapállapotú [classname] példány.</returns>
|
||||
[if ([ismasterentity] == "true")]
|
||||
public static [classname] GiveAnInstance()
|
||||
[else]
|
||||
public static new [classname] GiveAnInstance()
|
||||
[end if]
|
||||
{
|
||||
[classname] result = ([classname])m_Factory.CreateObject();
|
||||
result.Reset();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
end template
|
||||
|
||||
|
||||
//***************************************************************************//
|
||||
// Legenerálja egy entitás Reset() metódusát //
|
||||
//***************************************************************************//
|
||||
template GenerateEntityReset(MClass)
|
||||
#region Alaphelyzetbe állítás
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
// alaphelyzetbe állítjuk az egyszerű mezőket
|
||||
[loop (MClass -> MAttribute where [MAttribute.name] != [MClass.name])]
|
||||
this.m_[MAttribute.name] = [GetCSharpDefaultValueOfAttribute([MAttribute])];
|
||||
[end loop]
|
||||
|
||||
// alaphelyzetbe állítjuk az asszociációkból származó mezőket
|
||||
[loop (MClass -> MAssociation as CurrentAssoc-> MAssociationEnd as StartRole -> MClass as StartClass where (GetStereoType([StartClass])=="Entity") )]
|
||||
[loop (CurrentAssoc -> MAssociationEnd as EndRole -> MClass as EndClass where([StartRole.id]<[EndRole.id] and GetStereoType([EndClass]) == "Entity" ))]
|
||||
this.m_[ConvertRoleToName([StartRole])] = [GetCSharpDefaultValueOfType("ID")]; // ID
|
||||
this.m_[ConvertRoleToName([EndRole])] = [GetCSharpDefaultValueOfType("ID")]; // ID
|
||||
[end loop]
|
||||
[end loop]
|
||||
[loop (MClass -> Role as StartRole -> MAssociation as CurrentAssoc -> MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id] != [EndRole.id]) and GetStereoType([PartnerClass]) == "Entity"))]
|
||||
[if (([PartnerClass.name] != [MClass.name]) or ([PartnerClass.name] == [MClass.name] and [MClass.name] != DefineRoleName([EndRole])))]
|
||||
[if (HasAssociationClass([CurrentAssoc]) == "")]
|
||||
[//if (([EndRole.multiplicity] == "1") or (([EndRole.multiplicity] == "0..1") and (([StartRole.multiplicity] == "1..*") or ([StartRole.multiplicity] == "*") or ([StartRole.multiplicity] == "0..*"))))]
|
||||
[if (([EndRole.multiplicity] == "1") or ([EndRole.multiplicity] == "0..1"))]
|
||||
this.m_[ConvertRoleToName([EndRole])] = [GetCSharpDefaultValueOfType("ID")];
|
||||
this.m_[DefineRoleName([EndRole])] = null; // Entity
|
||||
[end if]
|
||||
[if ([EndRole.multiplicity] == "*" or [EndRole.multiplicity] == "1..*" or [EndRole.multiplicity] == "0..*")]
|
||||
this.m_[DefineRoleName([EndRole])] = null; // EntityCollection
|
||||
[end if]
|
||||
[else]
|
||||
[if ([EndRole.multiplicity] == "1" or [EndRole.multiplicity] == "0..1")]
|
||||
[end if]
|
||||
[if ([EndRole.multiplicity] == "*" or [EndRole.multiplicity] == "1..*" or [EndRole.multiplicity] == "0..*")]
|
||||
[end if]
|
||||
[end if]
|
||||
[end if]
|
||||
[end loop]
|
||||
}
|
||||
|
||||
#endregion
|
||||
end template
|
||||
|
||||
Reference in New Issue
Block a user