Beispiel #1
0
 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;
 }
Beispiel #2
0
            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);
            }
Beispiel #3
0
 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.");
 }
Beispiel #4
0
 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();
             }
         }
     }
 }
Beispiel #5
0
 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);
     }
 }
Beispiel #6
0
 public static ContentStream PrepareContentStream(ContentDescription contentDescription)
 {
     contentDescription.Stream.Position = contentDescription.Position;
     return(contentDescription.Stream.CreateSubstream(contentDescription.BytesCount));
 }