//Visitor public void Visitor() { ObjectGuard guard = new ObjectGuard(); AbstractVisitor visitor = new ConcreteVisitor(); guard.Attach(new ConcreteElement1()); guard.Attach(new ConcreteElement2()); guard.Notify(visitor); }
/// <summary> /// Get all public fields from the given object. /// </summary> /// <param name="obj"></param> /// <returns></returns> public static FieldInfo[] GetFields(this object obj) { ObjectGuard.NotNull(obj, nameof(obj)); return(TypeReflections.TypeCacheManager.GetTypeFields(obj.GetType())); }
/// <summary> /// Get all specified fields from the given object, using the specified binding constraints. /// </summary> /// <param name="obj"></param> /// <param name="bindingAttr"></param> /// <returns></returns> public static FieldInfo[] GetFields(this object obj, BindingFlags bindingAttr) { ObjectGuard.NotNull(obj, nameof(obj)); return(obj.GetType().GetFields(bindingAttr)); }
private static Action GuardObjectNullReference(EEntity? @object) => new Action(() => { ObjectGuard.ForNullReference(@object, nameof(@object)); });