public static void SetContentDescription(string name, ContentDescription contentDescription) { if (m_contentInfosByFolderName.Count > 0 && (!m_contentDescriptionsByName.TryGetValue(name, out ContentDescription value) || value.TypeName != contentDescription.TypeName)) { m_contentInfosByFolderName.Clear(); } m_contentDescriptionsByName[name] = contentDescription; }
public CachedItemWrapper(string name) { m_name = name; ContentDescription contentDescription = GetContentDescription(name, throwIfNotFound: true); if (contentDescription.CachedItemWrappers == null) { contentDescription.CachedItemWrappers = new List <CachedItemWrapperBase>(); } contentDescription.CachedItemWrappers.Add(this); }
public static void LoadContent(ContentDescription contentDescription) { if (contentDescription.Stream != null) { IContentReader contentReader = GetContentReader(contentDescription.TypeName); ContentStream stream = PrepareContentStream(contentDescription); contentDescription.Content = contentReader.Read(stream, contentDescription.Content); return; } throw new InvalidOperationException("Cannot load manually added content item. Item must have been disposed and accessed again."); }
public static void Dispose(string name) { lock (m_lock) { ContentDescription contentDescription = GetContentDescription(name, throwIfNotFound: true); (contentDescription.Content as IDisposable)?.Dispose(); contentDescription.Content = null; if (contentDescription.CachedItemWrappers != null) { foreach (CachedItemWrapperBase cachedItemWrapper in contentDescription.CachedItemWrappers) { cachedItemWrapper.Clear(); } } } }
public static object Get(string name, bool throwIfNotFound = true) { lock (m_lock) { ContentDescription contentDescription = GetContentDescription(name, throwIfNotFound); if (contentDescription != null) { if (contentDescription.Content == null) { LoadContent(contentDescription); } return(contentDescription.Content); } return(null); } }
public static ContentStream PrepareContentStream(ContentDescription contentDescription) { contentDescription.Stream.Position = contentDescription.Position; return(contentDescription.Stream.CreateSubstream(contentDescription.BytesCount)); }