本文整理汇总了C#中Sitecore类的典型用法代码示例。如果您正苦于以下问题:C# Sitecore类的具体用法?C# Sitecore怎么用?C# Sitecore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sitecore类属于命名空间,在下文中一共展示了Sitecore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetItemDefinition
public override ItemDefinition GetItemDefinition(ID itemId, Sitecore.Data.DataProviders.CallContext context)
{
if (_cacheClearer == null)
{
lock (_lockObj)
{
if (_cacheClearer == null)
{
_cacheClearer = new MongoOplogCacheClearer(this.ConnectionString, this.MongoDatabase, this.Collection, this.MappingCollection);
new Thread(_cacheClearer.Start).Start();
}
}
}
if (!_initialized)
{
lock (_lockObj)
{
if (!_initialized)
{
_cacheClearer.AddDatabase(this.Database);
_initialized = true;
}
}
}
return null;
}
开发者ID:techphoria414,项目名称:Sitecore-MongoDataIntegration,代码行数:26,代码来源:MongoDataProvider.cs
示例2: ComputeFieldValue
public object ComputeFieldValue(Sitecore.ContentSearch.IIndexable indexable)
{
var sitecoreIndexable = indexable as SitecoreIndexableItem;
if (sitecoreIndexable == null || !sitecoreIndexable.Item.TemplateName.Equals(TemplateKey,StringComparison.InvariantCultureIgnoreCase)) return null;
return sitecoreIndexable.Item.Axes.SelectSingleItem("./ancestor-or-self::*[@@templatekey='folder']").Name + " content";
}
开发者ID:rauljmz,项目名称:SampleTagSearching,代码行数:7,代码来源:SectionComputedField.cs
示例3: Process
/// <summary>
/// Store source value to use to determine if an item is cloned as value is removed when items are published
/// http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/02/Identify-Cloned-Items-Sitecore-ASPNET-CMS-Publishing-Target-Databases.aspx
/// </summary>
/// <param name="context"></param>
public override void Process(Sitecore.Publishing.Pipelines.PublishItem.PublishItemContext context)
{
base.Process(context);
Item versionToPublish = context.VersionToPublish;
if (!context.Aborted
&& versionToPublish != null
&& versionToPublish.InheritsTemplate(BasePageNEWItem.TemplateId)
&& versionToPublish.Source != null
&& versionToPublish.IsClone)
{
BasePageNEWItem target = context.PublishOptions.TargetDatabase.GetItem(
versionToPublish.ID,
versionToPublish.Language);
if (target.InnerItem != null &&
target.SourceItem.Field.Value !=
versionToPublish.Source.ID.ToString())
{
using (new Sitecore.Data.Items.EditContext(target.InnerItem, updateStatistics: false, silent: true))
{
target.InnerItem[target.SourceItem.Field.InnerField.Name] = versionToPublish.ID.ToString();
}
}
}
}
开发者ID:D0cNet,项目名称:UnderstoodDotOrg.sln,代码行数:31,代码来源:IdentifyClone.cs
示例4: DoProcessRequest
protected override bool DoProcessRequest(HttpContext context, MediaRequest request, Sitecore.Resources.Media.Media media)
{
Assert.ArgumentNotNull(context, "context");
Assert.ArgumentNotNull(request, "request");
Assert.ArgumentNotNull(media, "media");
if (this.Modified(context, media, request.Options) == Sitecore.Tristate.False)
{
Event.RaiseEvent("media:request", new object[] { request });
this.SendMediaHeaders(media, context);
context.Response.StatusCode = 0x130;
return true;
}
// Gets media stream for the requested media item thumbnail
MediaStream stream = ProcessThumbnail(request, media);
if (stream == null)
{
return false;
}
Event.RaiseEvent("media:request", new object[] { request });
this.SendMediaHeaders(media, context);
this.SendStreamHeaders(stream, context);
using (stream)
{
context.Response.AddHeader("Content-Length", stream.Stream.Length.ToString());
WebUtil.TransmitStream(stream.Stream, context.Response, Settings.Media.StreamBufferSize);
}
return true;
}
开发者ID:patelyogesh-in,项目名称:sitecore-pdf-thumbnail-handler,代码行数:30,代码来源:PDFThumbnailRequestHandler.cs
示例5: RenderContent
/// <summary>
/// Renders the content.
/// </summary>
/// <param name="printContext">The print context.</param>
/// <param name="output">The output.</param>
protected override void RenderContent(Sitecore.PrintStudio.PublishingEngine.PrintContext printContext, System.Xml.Linq.XElement output)
{
if (!string.IsNullOrEmpty(this.ChildDataKeyName))
{
printContext.Settings.Parameters[this.ChildDataKeyName] = this.DataSource;
}
if (!string.IsNullOrEmpty(this.DataSources))
{
foreach (var dataSource in this.DataSources.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
{
this.DataSource = dataSource;
if (!string.IsNullOrEmpty(this.ChildDataKeyName))
{
printContext.Settings.Parameters[this.ChildDataKeyName] = dataSource;
}
RenderChildren(printContext, output);
}
return;
}
this.RenderChildren(printContext, output);
}
开发者ID:ravikumhar,项目名称:Sitecore.PxM.Toolbox,代码行数:30,代码来源:LookupRepeat.cs
示例6: GetMediaUrl
/// <summary>
/// If CDN is enabled for this request, replace the outgoing media url with the cdn version
/// </summary>
/// <param name="item"></param>
/// <param name="options"></param>
/// <returns></returns>
public override string GetMediaUrl(Sitecore.Data.Items.MediaItem item, MediaUrlOptions options)
{
string hostname = CDNManager.GetCDNHostName();
string url = base.GetMediaUrl(item, options);
bool shouldReplace = !string.IsNullOrEmpty(hostname) && // cdnHostname exists for site
Sitecore.Context.PageMode.IsNormal; // PageMode is normal
bool dontReplace = !CDNManager.IsMediaPubliclyAccessible(item) || // media is publicly accessible
CDNManager.IsMediaAnalyticsTracked(item); // media is analytics tracked
CDNUrlState contextState = CDNUrlSwitcher.CurrentValue;
if (contextState == CDNUrlState.Enabled)
{
shouldReplace = true;
}
else if (contextState == CDNUrlState.Disabled)
{
UrlString url2 = new UrlString(url);
url2[CDNManager.StopToken] = "1";
url = url2.ToString();
shouldReplace = false;
}
if (shouldReplace && !dontReplace) // media not DMS tracked
{
return CDNManager.ReplaceMediaUrl(url, hostname);
}
else
{
return url;
}
}
开发者ID:carriercomm,项目名称:SitecoreCDN,代码行数:41,代码来源:CDNMediaProvider.cs
示例7: GetItemAccess
protected override AccessResult GetItemAccess(Sitecore.Data.Items.Item item, Account account, AccessRight accessRight, PropagationType propagationType)
{
//
//This method applies the specified AccessRight. Since the custom AccessRight
//has been extended to support additional properties (max comments and
//time range), these properties must be considered.
var result = base.GetItemAccess(item, account, accessRight, propagationType);
//
//
if (result == null || result.Permission != AccessPermission.Allow)
{
return result;
}
//
//
if (accessRight.Name != BucketRights.AddComments)
{
return result;
}
//
//
var right = accessRight as BucketAccessRight;
if (right != null)
{
result = GetItemAccess(item, account, right);
}
return result;
}
开发者ID:golden86,项目名称:ItemBuckets,代码行数:28,代码来源:AuthHelper.cs
示例8: UpdateField
public void UpdateField(Sitecore.Data.Fields.Field field, string importValue, IImportOptions importOptions)
{
var selectionSource = field.Item.Database.SelectSingleItem(field.Source);
if (selectionSource != null)
{
var query = ID.IsID(importValue)
? ".//*[@@id='" + ID.Parse(importValue) + "']"
: "." +
Sitecore.StringUtil.EnsurePrefix('/',
importValue.Replace(importOptions.TreePathValuesImportSeparator, "/"));
var selectedItem = selectionSource.Axes.SelectSingleItem(query);
if (selectedItem != null)
{
field.Value = selectedItem.ID.ToString();
return;
}
}
if (importOptions.InvalidLinkHandling == InvalidLinkHandling.SetBroken)
{
field.Value = importValue;
}
else if (importOptions.InvalidLinkHandling == InvalidLinkHandling.SetEmpty)
{
field.Value = string.Empty;
}
}
开发者ID:dresser,项目名称:SitecoreEzImporter,代码行数:26,代码来源:DropTreeFieldUpdater.cs
示例9: Evaluate
protected override void Evaluate(Sitecore.Pipelines.InsertRenderings.InsertRenderingsArgs args, Sitecore.Data.Items.Item item)
{
RuleList<ConditionalRenderingsRuleContext> globalRules = this.GetGlobalRules(item);
foreach (RenderingReference reference in new List<RenderingReference>((IEnumerable<RenderingReference>)args.Renderings))
{
string conditions = reference.Settings.Conditions;
if (!string.IsNullOrEmpty(conditions))
{
List<Item> conditionItems = this.GetConditionItems(item.Database, conditions);
if (conditionItems.Count > 0)
{
RuleList<ConditionalRenderingsRuleContext> rules = RuleFactory.GetRules<ConditionalRenderingsRuleContext>((IEnumerable<Item>)conditionItems, "Rule");
ConditionalRenderingsRuleContext renderingsRuleContext = new ConditionalRenderingsRuleContext(args.Renderings, reference);
renderingsRuleContext.Item = item;
ConditionalRenderingsRuleContext ruleContext = renderingsRuleContext;
rules.Run(ruleContext);
}
}
if (globalRules != null)
{
ConditionalRenderingsRuleContext renderingsRuleContext = new ConditionalRenderingsRuleContext(args.Renderings, reference);
renderingsRuleContext.Item = item;
ConditionalRenderingsRuleContext ruleContext = renderingsRuleContext;
globalRules.Run(ruleContext);
}
GetCustomRules(args, item, reference);
}
}
开发者ID:jgeorgiades,项目名称:CustomGlobalCondRendRules,代码行数:29,代码来源:CustomEvaluateCondition.cs
示例10: AddTableCell
/// <summary>
/// This function will be used to add
/// table cell
/// </summary>
/// <param name="tableRow">Table Row</param>
/// <param name="aField">Field</param>
/// <param name="fieldType">Type of field</param>
/// <returns></returns>
private static TableCell AddTableCell(TableRow tableRow, Sitecore.Data.Fields.Field aField, FieldTypes fieldType)
{
TableCell tableCell1 = new TableCell();
string valueToPrint = "NA";
switch (fieldType)
{
case FieldTypes.DateTime:
if ((aField != null) && !string.IsNullOrEmpty(aField.Value))
{
string dateFormat = "r";
DateTime createdDate = DateTime.Now;
createdDate = Sitecore.DateUtil.IsoDateToDateTime(aField.Value);
valueToPrint = createdDate.ToString(dateFormat);
}
else
{
valueToPrint = "NA";
}
break;
case FieldTypes.Text:
valueToPrint = ((aField != null) && !string.IsNullOrEmpty(aField.Value)) ? aField.Value : "NA";
break;
default:
valueToPrint = ((aField != null) && !string.IsNullOrEmpty(aField.Value)) ? aField.Value : "NA";
break;
}
tableCell1.Text = valueToPrint;
tableRow.Cells.Add(tableCell1);
return tableCell1;
}
开发者ID:klpatil,项目名称:PackageHistory,代码行数:41,代码来源:PackageHistory.aspx.cs
示例11: BeginRender
/// <summary>
/// Preliminary render action invoked before RenderContent <see cref="RenderContent"/>.
/// </summary>
/// <param name="printContext">The print context.</param>
protected override void BeginRender(Sitecore.PrintStudio.PublishingEngine.PrintContext printContext)
{
if (!string.IsNullOrEmpty(this.RenderingItem["Item Field"]))
{
var dataItem = this.GetDataItem(printContext);
var data = dataItem[this.RenderingItem["Item Field"]];
if (!string.IsNullOrEmpty(this.RenderingItem["Item Selector"]))
{
var xpath = this.RenderingItem["Item Selector"];
if (!string.IsNullOrEmpty(xpath))
{
var items = dataItem.Axes.SelectItems(xpath);
if (items != null)
{
//this.DataSources = string.Join("|", items.Select(t => t.ID.ToString()).ToArray());
foreach (Item lookup in items)
{
this.DataSources = lookup[this.RenderingItem["Item Field"]];
}
}
}
}
Logger.Info("found DataSources: " + this.DataSources);
Logger.Info("found DataSource: " + this.DataSource);
}
}
开发者ID:ravikumhar,项目名称:Sitecore.PxM.Toolbox,代码行数:34,代码来源:LookupRepeat.cs
示例12: Process
/// <summary>
/// Processes the specified arguments.
/// </summary>
/// <param name="args">The arguments.</param>
public override void Process(Sitecore.Commerce.Pipelines.ServicePipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
Assert.ArgumentNotNull(args.Request, "args.request");
Assert.ArgumentNotNull(args.Result, "args.result");
RefSFArguments.TranslateEntityToOrderAddressRequest request = (RefSFArguments.TranslateEntityToOrderAddressRequest)args.Request;
Assert.ArgumentNotNull(request.SourceParty, "request.SourceParty");
Assert.ArgumentNotNull(request.DestinationAddress, "request.DestinationAddress");
if (request.SourceParty is ConnectOrderModels.CommerceParty)
{
this.TranslateCommerceParty(request.SourceParty as ConnectOrderModels.CommerceParty, request.DestinationAddress);
}
else if (request.SourceParty is EmailParty)
{
this.TranslateEmailParty(request.SourceParty as EmailParty, request.DestinationAddress);
}
else
{
this.TranslateCustomParty(request.SourceParty, request.DestinationAddress);
}
TranslateEntityToOrderAddressResult result = (TranslateEntityToOrderAddressResult)args.Result;
result.Address = request.DestinationAddress;
}
开发者ID:Brad-Christie,项目名称:sccs-demo,代码行数:31,代码来源:TranslateEntityToOrderAddress.cs
示例13: RunQuery
public override List<SkinnyItem> RunQuery(Sitecore.Search.QueryBase query, bool showAllVersions)
{
using (var scope = QueryTraceHelper.GetQueryTraceScope(query))
{
return base.RunQuery(query, showAllVersions);
}
}
开发者ID:NetworkTen,项目名称:SitecoreSearchContrib,代码行数:7,代码来源:QueryRunnerTrace.cs
示例14: GetField
/// <summary>
/// Gets the field.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="config">The config.</param>
/// <param name="context">The context.</param>
/// <returns>System.Object.</returns>
public override object GetField(Sitecore.Data.Fields.Field field, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
{
if (field == null)
return string.Empty;
if (config.Setting == SitecoreFieldSettings.RichTextRaw)
{
return field.Value;
}
Guid fieldGuid = field.ID.Guid;
// shortest route - we know whether or not its rich text
if (isRichTextDictionary.ContainsKey(fieldGuid))
{
return GetResult(field, isRichTextDictionary[fieldGuid]);
}
// we don't know - it might still be rich text
bool isRichText = field.TypeKey == _richTextKey;
isRichTextDictionary.TryAdd(fieldGuid, isRichText);
// now we know it isn't rich text - return the raw result.
return GetResult(field, isRichText);
}
开发者ID:rootix,项目名称:Glass.Mapper,代码行数:32,代码来源:SitecoreFieldStringMapper.cs
示例15: InheritsFromTemplate
private bool InheritsFromTemplate(TemplateItem templateItem, Sitecore.Data.ID templateId)
{
return templateItem.ID == templateId
|| (templateItem.BaseTemplates != null
&& templateItem.BaseTemplates
.Where(baseTempl => InheritsFromTemplate(baseTempl, templateId)).Count() > 0);
}
开发者ID:johnpen,项目名称:SharedSource.Projects,代码行数:7,代码来源:CheckProjectItems.cs
示例16: GetItemUrl
public override string GetItemUrl(Sitecore.Data.Items.Item item, Sitecore.Links.UrlOptions options)
{
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNull(options, "options");
// Store real item for later use
Item realItem = item;
// Check if item is an wildcard item
bool isWildcardItem = item.IsDatasourceItemForWildcard();
if (isWildcardItem)
{
item = Context.Database.GetItem(WildcardProvider.GetSetting(item.TemplateID).ItemID);
}
if (item == null)
{
item = realItem;
}
string text = base.GetItemUrl(item, options);
if (isWildcardItem)
{
text = WildcardProvider.GetWildcardItemUrl(item, realItem, UseDisplayName);
}
return text.ToLower();
}
开发者ID:cvandeluitgaarden,项目名称:Sitecore.SharedSource.Wildcard,代码行数:28,代码来源:LinkProvider.cs
示例17: GetOptions
/// <summary>
/// Retrieve field editor options controlling the field editor,
/// including the fields displayed.
/// </summary>
/// <param name="args">Pipeline arguments.</param>
/// <param name="form">Form parameters.</param>
/// <returns>Field editor options.</returns>
protected override Sitecore.Shell.Applications.WebEdit.PageEditFieldEditorOptions GetOptions(Sitecore.Web.UI.Sheer.ClientPipelineArgs args,NameValueCollection form)
{
Sitecore.Diagnostics.Assert.IsNotNull(args, "args");
Sitecore.Diagnostics.Assert.IsNotNull(form, "form");
Sitecore.Diagnostics.Assert.IsNotNullOrEmpty(args.Parameters[URI], URI);
Sitecore.Data.ItemUri uri = Sitecore.Data.ItemUri.Parse(args.Parameters[URI]);
Sitecore.Diagnostics.Assert.IsNotNull(uri, URI);
Sitecore.Diagnostics.Assert.IsNotNullOrEmpty(args.Parameters["flds"], "flds");
string flds = args.Parameters["flds"];
Sitecore.Data.Items.Item item = Sitecore.Data.Database.GetItem(uri);
Sitecore.Diagnostics.Assert.IsNotNull(item, "item");
List<Sitecore.Data.FieldDescriptor> fields = new List<Sitecore.Data.FieldDescriptor>();
foreach (string fieldName in flds.Split('|'))
{
if (item.Fields[fieldName] != null)
{
fields.Add(new Sitecore.Data.FieldDescriptor(item, item.Fields[fieldName].Name));
}
}
// Field editor options.
Sitecore.Shell.Applications.WebEdit.PageEditFieldEditorOptions options = new Sitecore.Shell.Applications.WebEdit.PageEditFieldEditorOptions(form, fields);
options.PreserveSections = false;
options.DialogTitle = "Update Item";
options.Icon = item.Appearance.Icon;
return options;
}
开发者ID:nemetosKot,项目名称:LaunchSitecoreTDS,代码行数:38,代码来源:FieldEditorButton.cs
示例18: GetCustomRules
private static void GetCustomRules(Sitecore.Pipelines.InsertRenderings.InsertRenderingsArgs args, Sitecore.Data.Items.Item item, RenderingReference reference)
{
string configId = Sitecore.Configuration.Settings.GetSetting("customRulesConfigFolder");
if (string.IsNullOrEmpty(configId))
{
Error("Sitecore setting 'customRulesConfigFolder' not found", args.ContextItem);
return;
}
Database db = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
Item configFolder = db.GetItem(configId);
if (configFolder == null)
{
Error(string.Format("Config folder {0} not found", configId), args.ContextItem);
return;
}
if (configFolder.HasChildren && configFolder.Children.Any(r => !string.IsNullOrEmpty(r["rendering"]) && new ID(r["rendering"]) == reference.RenderingID))
{
Item configItem = configFolder.Children.First(r => new ID(r["rendering"]) == reference.RenderingID);
Item datasourceItem = db.GetItem(configItem["item"]);
if (datasourceItem == null)
{
Error(string.Format("No Item containing rules set on config item at {0}", configItem.Paths.FullPath), args.ContextItem);
return;
}
string fieldName = configItem["rule field"];
RunPromoRule(args, item, reference, datasourceItem, fieldName);
}
}
开发者ID:jgeorgiades,项目名称:CustomGlobalCondRendRules,代码行数:29,代码来源:CustomEvaluateCondition.cs
示例19: HandleDaysToAllowComments
protected virtual AccessResult HandleDaysToAllowComments(Sitecore.Data.Items.Item item, Account account, BucketAccessRight right)
{
//
//Allow commenting if the value is -1 since that value means comments
//may be added indefinitely.
//if (right.DaysToAllowComments == -1)
//{
// var ex = new AccessExplanation("Comments can be added indefinitely.");
// return new AccessResult(AccessPermission.Allow, ex);
//}
//
//Deny commenting if the item has not been updated within the allowed
//time range.
var d1 = item.Statistics.Updated;
var d2 = d1.AddDays(1.0);
if (DateTime.Compare(d1, d2) != -1)
{
var ex = new AccessExplanation("Comments cannot be added after {0} {1}.", d2.ToLongDateString(), d2.ToLongTimeString());
return new AccessResult(AccessPermission.Deny, ex);
}
//
//No other rules need to be implemented, so allow comments.
var ex1 = new AccessExplanation("Comments can be added until {0} {1}.", d2.ToLongDateString(), d2.ToLongTimeString());
return new AccessResult(AccessPermission.Allow, ex1);
}
开发者ID:golden86,项目名称:ItemBuckets,代码行数:25,代码来源:AuthHelper.cs
示例20: GetField
/// <summary>
/// Gets the field.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="config">The config.</param>
/// <param name="context">The context.</param>
/// <returns>System.Object.</returns>
public override object GetField(Sitecore.Data.Fields.Field field, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
{
var data = field.GetBlobStream();
MemoryStream stream = null;
if (data.CanRead)
{
stream = new MemoryStream();
byte[] buffer = new byte[2048];
int bytesRead;
while ((bytesRead = data.Read(buffer, 0, buffer.Length)) > 0)
{
stream.Write(buffer, 0, bytesRead);
}
data.Close();
stream.Seek(0, SeekOrigin.Begin);
}
return stream;
}
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:32,代码来源:SitecoreFieldStreamMapper.cs
注:本文中的Sitecore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论