mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-12 12:06:58 +00:00
trying to fix JoinMapBaseAdvanced
This commit is contained in:
parent
b32212083d
commit
69f5460442
1 changed files with 22 additions and 13 deletions
|
|
@ -164,7 +164,7 @@ namespace PepperDash.Essentials.Core
|
|||
/// </summary>
|
||||
public abstract class JoinMapBaseAdvanced
|
||||
{
|
||||
protected uint _joinOffset;
|
||||
protected uint JoinOffset;
|
||||
|
||||
/// <summary>
|
||||
/// The collection of joins and associated metadata
|
||||
|
|
@ -175,11 +175,15 @@ namespace PepperDash.Essentials.Core
|
|||
{
|
||||
Joins = new Dictionary<string, JoinDataComplete>();
|
||||
|
||||
_joinOffset = joinStart - 1;
|
||||
|
||||
JoinOffset = joinStart - 1;
|
||||
}
|
||||
|
||||
protected void AddJoins()
|
||||
protected JoinMapBaseAdvanced(uint joinStart, Type type):this(joinStart)
|
||||
{
|
||||
AddJoins(type);
|
||||
}
|
||||
|
||||
protected void AddJoins(Type type)
|
||||
{
|
||||
// Add all the JoinDataComplete properties to the Joins Dictionary and pass in the offset
|
||||
//Joins = this.GetType()
|
||||
|
|
@ -193,22 +197,27 @@ namespace PepperDash.Essentials.Core
|
|||
// return join;
|
||||
// });
|
||||
|
||||
var type = this.GetType();
|
||||
//type = this.GetType(); <- this wasn't working because 'this' was always the base class, never the derived class
|
||||
var cType = type.GetCType();
|
||||
var fields = cType.GetFields(BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (field.IsDefined(typeof(JoinNameAttribute), true))
|
||||
{
|
||||
JoinDataComplete value = field.GetValue(this) as JoinDataComplete;
|
||||
if (!field.IsDefined(typeof (JoinNameAttribute), true)) continue;
|
||||
|
||||
if (value != null)
|
||||
var childClass = Convert.ChangeType(this, type, null);
|
||||
|
||||
var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class...which has no fields.
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
value.SetJoinOffset(_joinOffset);
|
||||
Debug.Console(0, "Unable to caset base class to {0}", type.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
value.SetJoinOffset(JoinOffset);
|
||||
Joins.Add(value.GetNameAttribute(typeof(JoinDataComplete)), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintJoinMapInfo();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue