/// <summary> /// Queries a resource. /// </summary> /// <exception cref="InvalidOperationException">Is thrown when there was no matching resource found.</exception> public static T QueryResource <T>(object tag = null) where T : IResource { try { if (tag == null) { return(Resources.OfType <T>().First()); } else { return(Resources.OfType <T>().First(resource => tag.Equals(resource.Tag))); } } catch (InvalidOperationException) { PostGlobalLogMessage(string.Format("Error querying resource of type {0}{1}: no matches found.", typeof(T).FullName, tag != null ? string.Format(" with tag '{0}'", tag) : string.Empty), LogMessageKind.Error, LogMessagePriority.Engine); throw; } }
/// <summary> /// Enumerates all buffers of a specific type. /// </summary> public IEnumerable <T> EnumerateBuffers <T>() where T : IBufferedState <T> { return(Updateables.OfType <UpdateContainer <T> >().Select(updateable => updateable.GetBuffer(CurrentBufferIndex))); }