/// <summary> /// Copy constructor /// </summary> /// <param name="parent">Parent debuggable</param> /// <param name="stats">The stats to copy</param> public Stats(Debuggable parent, Stats stats) : base(parent) { Hp.Value = stats.Hp; Mp.Value = stats.Mp; Attack.Value = stats.Attack; Defense.Value = stats.Defense; MagicAttack.Value = stats.MagicAttack; MagicDefense.Value = stats.MagicDefense; Speed.Value = stats.Speed; }
/// <summary> /// Default constructor /// </summary> /// <param name="parent">Parent debuggable</param> public Stats(Debuggable parent) : base(parent) { }
/// <summary> /// Creatse a new stat operations under the parent debuggable /// </summary> /// <param name="parent">Parent debuggable</param> public StatOperations(Debuggable parent) : base(parent) { }
/// <summary> /// Initializes a debuggable object /// </summary> /// <param name="parent">The parent object</param> /// <param name="name">The name of the object</param> public Debuggable(Debuggable parent, string name) { InitializeDebuggable(parent, name); }
/// <summary> /// Initializes a debuggable object /// </summary> /// <param name="parent">The parent object</param> public Debuggable(Debuggable parent) { InitializeDebuggable(parent, GetType().Name); }
/// <summary> /// Disposes the debuggable object and all its debug fields /// </summary> protected override void DisposeInternal() { _debug.Dispose(); if (null != _parent) { _parent._properties.Remove(this); _parent = null; } _properties.Dispose(); }
/// <summary> /// Initializes a debuggable object /// </summary> /// <param name="parent">Parent object</param> /// <param name="name">The name of the object</param> public void InitializeDebuggable(Debuggable parent, string name) { var type = GetType(); _parent = parent; _name = name; _debug = (Debug)Activator.CreateInstance(typeof(Debug<>).MakeGenericType(type), null == _parent ? null : _parent._debug, _name); if (null != Parent) { _parent._properties.Add(this); } foreach (var property in type.GetProperties(All).Where(IsDebugProperty).Select(property => property.DeclaringType == property.ReflectedType ? property : property.DeclaringType.GetProperty(property.Name, All))) { var prop = Activator.CreateInstance(typeof(Debug<>).MakeGenericType(property.PropertyType.GetGenericArguments()[0]), _debug, property.Name); _properties.Add((IDisposable)prop); property.SetValue(this, prop); } foreach (var field in type.GetFields(All).Where(IsDebugField)) { var prop = Activator.CreateInstance(typeof(Debug<>).MakeGenericType(field.FieldType.GetGenericArguments()[0]), _debug, field.Name); _properties.Add((IDisposable)prop); field.SetValue(this, prop); } }