public static void SetParentId <T>(this T @this, Guid?parentId = null) where T : IParentId { if (@this.ParentId != null && parentId == null) { // do nothing ... don't set to null } else { @this.ParentId = parentId; } foreach (PropertyInfo propertyInfo in @this.GetType().GetProperties()) { if (propertyInfo.PropertyType.GetInterfaces().Contains(typeof(IParentId))) { IParentId property = propertyInfo.GetValue(@this) as IParentId; if (property != null) { property.SetParentId(@this.Id); } } if (propertyInfo.PropertyType.GetInterfaces().Contains(typeof(IEnumerable))) { foreach (var item in propertyInfo.GetValue(@this) as IEnumerable) { IParentId child = item as IParentId; if (child != null) { child.SetParentId(@this.Id); } } } } }
public void Setup() { _el = _Fac.CreateDummyCompoundElementBase(Guid.NewGuid()); _asISetPortMgrs = _el as ISetPortMgrs; _asIParentId = _el as IParentId; _asIIdGetter = _el; }
public void Setup() { TestSupport.Core.Factory fac = new TestSupport.Core.Factory(); _el = fac.CreateDummyCommentBase(Guid.NewGuid()); _asIParentId = _el as IParentId; _asISetId = _el; _asIIdGetter = _el; _asISetParentId = _el as ISetParentId; }
public void Setup() { _store = new NetworkBackingStore(); _asSetParentId = _store as ISetParentId; _asIParentId = _store as IParentId; }