Moving ImportContentSession to a separate file.

--HG--
branch : dev
This commit is contained in:
Suha Can
2011-03-15 16:55:50 -07:00
parent 4426d99f0c
commit 3c2cfa471b
3 changed files with 37 additions and 33 deletions

View File

@@ -466,39 +466,6 @@ namespace Orchard.ContentManagement {
}
}
public class ImportContentSession {
private readonly IContentManager _contentManager;
// order of x500 elements.
private readonly Dictionary<string, ContentItem> _dictionary;
public ImportContentSession(IContentManager contentManager) {
_contentManager = contentManager;
_dictionary = new Dictionary<string, ContentItem>();
}
// gets a content item for an identity string.
public ContentItem Get(string id) {
if (_dictionary.ContainsKey(id))
return _dictionary[id];
foreach (var item in _contentManager.Query(VersionOptions.Published).List()) {
var identity = _contentManager.GetItemMetadata(item).Identity.ToString();
if (identity == id) {
_dictionary.Add(identity, item);
return item;
}
}
return null;
}
public void Store(string id, ContentItem item) {
_dictionary.Add(id, item);
}
}
class CallSiteCollection : ConcurrentDictionary<string, CallSite<Func<CallSite, object, object>>> {
readonly Func<string, CallSite<Func<CallSite, object, object>>> _valueFactory;

View File

@@ -0,0 +1,36 @@
using System.Collections.Generic;
namespace Orchard.ContentManagement {
public class ImportContentSession {
private readonly IContentManager _contentManager;
// order of x500 elements.
private readonly Dictionary<string, ContentItem> _dictionary;
public ImportContentSession(IContentManager contentManager) {
_contentManager = contentManager;
_dictionary = new Dictionary<string, ContentItem>();
}
// gets a content item for an identity string.
public ContentItem Get(string id) {
if (_dictionary.ContainsKey(id))
return _dictionary[id];
foreach (var item in _contentManager.Query(VersionOptions.Published).List()) {
var identity = _contentManager.GetItemMetadata(item).Identity.ToString();
if (identity == id) {
_dictionary.Add(identity, item);
return item;
}
}
return null;
}
public void Store(string id, ContentItem item) {
_dictionary.Add(id, item);
}
}
}

View File

@@ -160,6 +160,7 @@
<Compile Include="ContentManagement\Handlers\ExportContentContext.cs" />
<Compile Include="ContentManagement\Handlers\ImportContentContext.cs" />
<Compile Include="ContentManagement\IContentBehavior.cs" />
<Compile Include="ContentManagement\ImportContentSession.cs" />
<Compile Include="ContentManagement\Utilities\ComputedField.cs" />
<Compile Include="DisplayManagement\Descriptors\PlacementInfo.cs" />
<Compile Include="DisplayManagement\Descriptors\ResourceBindingStrategy\StylesheetBindingStrategy.cs" />