public static object GetPublicComponent(this ComponentizedObject componentizedObject, Type componentType) { var components = componentizedObject.Components.Where(componentType.IsInstanceOfType).ToArray(); if (components.Length == 0) { throw new InvalidOperationException("A public component of type " + componentType.FullName + " could not be found on this object. Is it private?"); } if (components.Length == 2) { throw new InvalidOperationException("More than one public component of type " + componentType.FullName + " was found on this object."); } return(components[0]); }
public static T GetPublicComponent <T>(this ComponentizedObject componentizedObject) { var components = componentizedObject.Components.OfType <T>().ToArray(); if (components.Length == 0) { throw new InvalidOperationException("A public component of type " + typeof(T).FullName + " could not be found on this object. Is it private?"); } if (components.Length == 2) { throw new InvalidOperationException("More than one public component of type " + typeof(T).FullName + " was found on this object."); } return(components[0]); }
public ImplementedComponentCallable(ComponentizedObject target, Action <T> method) { _target = target; _method = method; }