public T GetParentAs <T>() where T : BaseZoneClusterConsumption { var x = ParentBaseZoneClusterConsumption as T; if (x == null) { throw new InvalidOperationException( $"ParentBaseZoneClusterConsumption was not of type: \"{typeof(T)}\", but was: \"{ParentBaseZoneClusterConsumption?.GetType()}\"." ); } return(x); }
public T GetParentAs <T>() where T : BaseZoneClusterConsumption { var x = ParentBaseZoneClusterConsumption as T; if (x == null) { throw new InvalidOperationException(String.Format("ParentBaseZoneClusterConsumption was not of type: \"{0}\", but was: \"{1}\".", typeof(T), ParentBaseZoneClusterConsumption != null ? ParentBaseZoneClusterConsumption.GetType() : null)); } return(x); }