Class CacheManager
Caching manager, singleton Important: don't cache SharePoint Client objects as these are tied to a specific client context and hence will fail when there's context switching!
Inheritance
Namespace: PnP.Framework.Modernization.Cache
Assembly: PnP.Framework.dll
Syntax
public sealed class CacheManager : object
Properties
Instance
Gets the single cachemanager instance, singleton pattern
Declaration
public static CacheManager Instance { get; }
Property Value
|
CacheManager
|
Store
Declaration
public IDistributedCache Store { get; set; }
Property Value
|
IDistributedCache
|
StoreOptions
Methods
AddAssetTransferredEntity(AssetTransferredEntity)
Declaration
public void AddAssetTransferredEntity(AssetTransferredEntity asset)
Parameters
|
AssetTransferredEntity
asset
|
AddMappedUser(String, String)
Adds a user to the dictionary of mapped users
Declaration
public void AddMappedUser(string principal, string user)
Parameters
|
System.String
principal
Principal to map |
|
System.String
user
mapped user |
ClearAllCaches()
Clear all the caches
Declaration
public void ClearAllCaches()
ClearBaseTemplate()
Clear base template cache
Declaration
public void ClearBaseTemplate()
ClearClientSideComponents()
Clear the clientside component cache
Declaration
public void ClearClientSideComponents()
ClearFieldsToCopy()
Clear the fields to copy cache
Declaration
public void ClearFieldsToCopy()
ClearGeneratedPageLayoutMappings()
Clears the cache of generated page layout mappings
Declaration
public void ClearGeneratedPageLayoutMappings()
ClearSharePointVersions()
GetAADTenantId(Uri)
Returns the used AzureAD tenant id
Declaration
public Guid GetAADTenantId(Uri site)
Parameters
|
Uri
site
Url of the site |
Returns
|
Guid
Azure AD tenant id |
GetAssetsTransferred()
Declaration
public List<AssetTransferredEntity> GetAssetsTransferred()
Returns
|
List<AssetTransferredEntity>
|
GetBaseTemplate(Web)
Gets the base template that will be used to filter out "OOB" fields
Declaration
public ProvisioningTemplate GetBaseTemplate(Web web)
Parameters
|
Web
web
web to operate against |
Returns
|
ProvisioningTemplate
Provisioning template of the base template of STS#0 |
GetBlogListName(ClientContext)
Get translation for the blog list name
Declaration
public string GetBlogListName(ClientContext context)
Parameters
|
ClientContext
context
Context of the site |
Returns
|
System.String
Translated name of the blog list |
GetContentTypeId(List, String)
Gets the ID of a contenttype
Declaration
public string GetContentTypeId(List pagesLibrary, string contentTypeName)
Parameters
|
List
pagesLibrary
Pages library holding the content type |
|
System.String
contentTypeName
Name of the content type |
Returns
|
System.String
ID of the content type |
GetEnsuredUser(ClientContext, String)
Run and cache the output value of EnsureUser for a given user
Declaration
public ResolvedUser GetEnsuredUser(ClientContext context, string userValue)
Parameters
|
ClientContext
context
ClientContext to operate on |
|
System.String
userValue
User name of user to ensure |
Returns
|
ResolvedUser
ResolvedUser instance holding information about the ensured user |
GetExactSharePointVersion(Uri)
GetFieldsToCopy(Web, List, String)
Get the list of fields that need to be copied from cache. If cache is empty the list will be calculated
Declaration
public List<FieldData> GetFieldsToCopy(Web web, List sourceLibrary, string pageType)
Parameters
|
Web
web
Web to operate against |
|
List
sourceLibrary
Pages library instance |
|
System.String
pageType
Type of page |
Returns
|
List<FieldData>
List of fields that need to be copied |
GetLastUsedTransformator()
Gets the last used page transformator instance
Declaration
public BasePageTransformator GetLastUsedTransformator()
Returns
|
BasePageTransformator
|
GetMappedUsers()
Mapped users
Declaration
public Dictionary<string, string> GetMappedUsers()
Returns
|
Dictionary<System.String, System.String>
A dictionary of mapped users |
GetPageLayoutMapping(ListItem)
Generate pagelayout mapping file for given publishing page
Declaration
public PageLayout GetPageLayoutMapping(ListItem page)
Parameters
|
ListItem
page
Publishing page |
Returns
|
PageLayout
Page layout mapping model |
GetPublishingContentTypeField(List, String, String)
Get field information of a content type field
Declaration
public FieldData GetPublishingContentTypeField(List pagesLibrary, string contentTypeId, string fieldName)
Parameters
|
List
pagesLibrary
Pages library list |
|
System.String
contentTypeId
ID of the content type |
|
System.String
fieldName
Name of the field to get information from |
Returns
|
FieldData
FieldData object holding field information |
GetPublishingPagesLibraryName(ClientContext)
Get translation for the publishing pages library
Declaration
public string GetPublishingPagesLibraryName(ClientContext context)
Parameters
|
ClientContext
context
Context of the site |
Returns
|
System.String
Translated name of the pages library |
GetResourceString(ClientContext, String)
Returns the translated value for a resource string
Declaration
public string GetResourceString(ClientContext context, string resource)
Parameters
|
ClientContext
context
Context of the site |
|
System.String
resource
Key of the resource (e.g. $Resources:core,ScriptEditorWebPartDescription;) |
Returns
|
System.String
Translated string |
GetSharePointVersion(Uri)
GetTermFromId(ClientContext, Guid)
Return information for the given term
Declaration
public string GetTermFromId(ClientContext context, Guid termId)
Parameters
|
ClientContext
context
ClientContext object to operate on |
|
Guid
termId
Id of the term to lookup |
Returns
|
System.String
Term label |
GetTermMapping(String, IList<ILogObserver>)
Returns a cached list of mapped items
Declaration
public List<TermMapping> GetTermMapping(string mappingFile, IList<ILogObserver> logObservers = null)
Parameters
|
System.String
mappingFile
|
|
IList<ILogObserver>
logObservers
|
Returns
|
List<TermMapping>
|
GetTransformTermCacheTermById(ClientContext, Guid)
Get Term from Term Cache
Declaration
public TermData GetTransformTermCacheTermById(ClientContext context, Guid termId)
Parameters
|
ClientContext
context
|
|
Guid
termId
|
Returns
|
TermData
|
GetTransformTermCacheTermByName(ClientContext, String, String)
Search Cached term by name
Declaration
public List<TermData> GetTransformTermCacheTermByName(ClientContext context, string termLabel = "", string termPath = "")
Parameters
|
ClientContext
context
|
|
System.String
termLabel
|
|
System.String
termPath
|
Returns
|
List<TermData>
|
GetTransformTermCacheTermsByTermSet(ClientContext, Guid)
Get Term by Term Set Id
Declaration
public Dictionary<Guid, TermData> GetTransformTermCacheTermsByTermSet(ClientContext context, Guid termSetId)
Parameters
|
ClientContext
context
|
|
Guid
termSetId
|
Returns
|
Dictionary<Guid, TermData>
|
GetUrlMapping(String, IList<ILogObserver>)
Returns a list of url mappings
Declaration
public List<UrlMapping> GetUrlMapping(string urlMappingFile, IList<ILogObserver> logObservers = null)
Parameters
|
System.String
urlMappingFile
File with url mappings |
|
IList<ILogObserver>
logObservers
Attached list of log observers |
Returns
|
List<UrlMapping>
List of url mappings |
GetUserFromUserList(ClientContext, Int32)
Lookup a user from the site's user list based upon the user's id
Declaration
public UserEntity GetUserFromUserList(ClientContext context, int userListId)
Parameters
|
ClientContext
context
Context of the web holding the user list |
|
System.Int32
userListId
Id of the user to fetch |
Returns
|
UserEntity
A UserEntity instance holding information about the user |
GetUserFromUserList(ClientContext, String)
Lookup a user from the site's user list based upon the user's upn
Declaration
public UserEntity GetUserFromUserList(ClientContext context, string userUpn)
Parameters
|
ClientContext
context
Context of the web holding the user list |
|
System.String
userUpn
Upn of the user to fetch |
Returns
|
UserEntity
A UserEntity instance holding information about the user |
GetUserMapping(String, IList<ILogObserver>)
Gets the list of user mappings, if first time file will be laoded
Declaration
public List<UserMappingEntity> GetUserMapping(string userMappingFile, IList<ILogObserver> logObservers = null)
Parameters
|
System.String
userMappingFile
File with the user mappings |
|
IList<ILogObserver>
logObservers
Attached list of log observers |
Returns
|
List<UserMappingEntity>
List of user mappings |
IsBlogWeb(String)
Checks if this is blog web
Declaration
public bool IsBlogWeb(string webUrl)
Parameters
|
System.String
webUrl
Web url to check |
Returns
|
System.Boolean
True if blog, false otherwise |
IsPublishingWeb(String)
Checks if this is publishing web
Declaration
public bool IsPublishingWeb(string webUrl)
Parameters
|
System.String
webUrl
Web url to check |
Returns
|
System.Boolean
True if publishing, false otherwise |
SetAADTenantId(Guid, Uri)
Sets the Azure AD tenant Id in cache
Declaration
public void SetAADTenantId(Guid tenantId, Uri site)
Parameters
|
Guid
tenantId
Tenant Id |
|
Uri
site
Site url |
SetBlogWeb(String)
Marks this web as a blog web
Declaration
public void SetBlogWeb(string webUrl)
Parameters
|
System.String
webUrl
Url of the web |
SetExactSharePointVersion(Uri, String)
SetLastUsedTransformator(BasePageTransformator)
Caches the last used page transformator instance, needed to postpone log writing when transforming multiple pages
Declaration
public void SetLastUsedTransformator(BasePageTransformator transformator)
Parameters
|
BasePageTransformator
transformator
|
SetPublishingWeb(String)
Marks this web as a publishing web
Declaration
public void SetPublishingWeb(string webUrl)
Parameters
|
System.String
webUrl
Url of the web |
SetSharePointVersion(Uri, SPVersion)
StoreTermSetTerms(ClientContext, Guid, Guid, Boolean, Boolean)
Get Term Path by ID
Declaration
public void StoreTermSetTerms(ClientContext context, Guid termSetId, Guid sourceSspId, bool isSP2010, bool isSourceTerm)
Parameters
|
ClientContext
context
|
|
Guid
termSetId
|
|
Guid
sourceSspId
|
|
System.Boolean
isSP2010
|
|
System.Boolean
isSourceTerm
|