本文整理汇总了C#中Umbraco.Web.UmbracoContext类的典型用法代码示例。如果您正苦于以下问题:C# UmbracoContext类的具体用法?C# UmbracoContext怎么用?C# UmbracoContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UmbracoContext类属于Umbraco.Web命名空间,在下文中一共展示了UmbracoContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlRssHandler
public XmlRssHandler()
{
umbContext = UmbracoContext.Current;
appContext = ApplicationContext.Current;
services = appContext.Services;
helper = new UmbracoHelper( umbContext );
}
示例2: ProductVariantApiController
/// <summary>
/// This is a helper contructor for unit testing
/// </summary>
internal ProductVariantApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
: base(merchelloContext, umbracoContext)
{
_productService = MerchelloContext.Services.ProductService;
_productVariantService = MerchelloContext.Services.ProductVariantService;
_warehouseService = MerchelloContext.Services.WarehouseService;
}
示例3: SetUp
public void SetUp()
{
TestHelper.SetupLog4NetForTests();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
_httpContextFactory = new FakeHttpContextFactory("~/Home");
//ensure the StateHelper is using our custom context
StateHelper.HttpContext = _httpContextFactory.HttpContext;
_umbracoContext = new UmbracoContext(_httpContextFactory.HttpContext,
new ApplicationContext(),
new DefaultRoutesCache(false));
_umbracoContext.GetXmlDelegate = () =>
{
var xDoc = new XmlDocument();
//create a custom xml structure to return
xDoc.LoadXml(GetXml());
//return the custom x doc
return xDoc;
};
_publishedContentStore = new DefaultPublishedContentStore();
}
示例4: BeginRequest
/// <summary>
/// Begins to process a request.
/// </summary>
/// <param name="httpContext"></param>
void BeginRequest(HttpContextBase httpContext)
{
// do not process if client-side request
if (IsClientSideRequest(httpContext.Request.Url))
return;
// ok, process
// create the LegacyRequestInitializer
// and initialize legacy stuff
var legacyRequestInitializer = new LegacyRequestInitializer(httpContext.Request.Url, httpContext);
legacyRequestInitializer.InitializeRequest();
// create the UmbracoContext singleton, one per request, and assign
var umbracoContext = new UmbracoContext(
httpContext,
ApplicationContext.Current,
RoutesCacheResolver.Current.RoutesCache);
UmbracoContext.Current = umbracoContext;
// create the nice urls provider
var niceUrls = new NiceUrlProvider(PublishedContentStoreResolver.Current.PublishedContentStore, umbracoContext);
// create the RoutingContext, and assign
var routingContext = new RoutingContext(
umbracoContext,
DocumentLookupsResolver.Current.DocumentLookups,
LastChanceLookupResolver.Current.LastChanceLookup,
PublishedContentStoreResolver.Current.PublishedContentStore,
niceUrls);
umbracoContext.RoutingContext = routingContext;
}
示例5: FindContent
protected override sealed IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
{
var byId = umbracoContext.ContentCache.GetById(_realNodeId);
if (byId == null) return null;
return FindContent(requestContext, umbracoContext, byId);
}
示例6: OrderApiController
/// <summary>
/// Initializes a new instance of the <see cref="OrderApiController"/> class.
/// </summary>
/// <param name="merchelloContext">
/// The merchello context.
/// </param>
/// <param name="umbracoContext">
/// The umbraco context.
/// </param>
internal OrderApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
: base(merchelloContext, umbracoContext)
{
_orderService = merchelloContext.Services.OrderService;
_invoiceService = merchelloContext.Services.InvoiceService;
_merchello = new MerchelloHelper(merchelloContext.Services);
}
示例7: CatalogShippingApiController
/// <summary>
/// This is a helper contructor for unit testing
/// </summary>
internal CatalogShippingApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
: base(merchelloContext, umbracoContext)
{
_gatewayProviderService = MerchelloContext.Services.GatewayProviderService;
_storeSettingService = MerchelloContext.Services.StoreSettingService;
_shipCountryService = ((ServiceContext)MerchelloContext.Services).ShipCountryService;
}
示例8: UmbracoUserControl
/// <summary>
/// Default constructor
/// </summary>
/// <param name="umbracoContext"></param>
protected UmbracoUserControl(UmbracoContext umbracoContext)
{
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
UmbracoContext = umbracoContext;
InstanceId = Guid.NewGuid();
Umbraco = new UmbracoHelper(umbracoContext);
}
示例9: FormsController
/// <summary>
/// Primary constructor.
/// </summary>
/// <param name="context">Umbraco context.</param>
public FormsController(UmbracoContext context)
: base(context)
{
Persistence = FormPersistence.Current.Manager;
Entities = EntityPersistence.Current.Manager;
Validations = ValidationPersistence.Current.Manager;
}
示例10: Crawl
/// <summary>
/// The crawl.
/// </summary>
/// <param name="site">
/// The site.
/// </param>
/// <param name="doc">
/// The doc.
/// </param>
public void Crawl(UmbracoContext site, XmlDocument doc)
{
/*
* We're going to crawl the site layer-by-layer which will put the upper levels
* of the site nearer the top of the sitemap.xml document as opposed to crawling
* the tree by parent/child relationships, which will go deep on each branch before
* crawling the entire site.
*/
var helper = new UmbracoHelper(UmbracoContext.Current);
var siteRoot = helper.TypedContentAtRoot().First();
var node = SitemapGenerator.CreateNode(siteRoot, site);
if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
{
SitemapGenerator.AppendUrlElement(doc, node);
}
var items = siteRoot.Descendants();
if (items != null)
{
foreach (var item in items)
{
node = SitemapGenerator.CreateNode(item, site);
if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
{
SitemapGenerator.AppendUrlElement(doc, node);
}
}
}
}
示例11: FindContent
protected override sealed IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
{
//determine if it's for a particular domain
int realNodeId;
if (_hostsAndIds.Count == 1)
{
realNodeId = _hostsAndIds[0].Item2;
}
else
{
if (requestContext.HttpContext.Request.Url == null)
{
if (_hostsAndIds.Count > 0)
{
//cannot be determined
realNodeId = _hostsAndIds[0].Item2;
}
else
{
LogHelper.Warn<ArticulateVirtualNodeByIdRouteHandler>("No entries found to map hosts and IDs");
return null;
}
}
else if (requestContext.HttpContext.Request.Url.Host.InvariantEquals("localhost")
&& !UmbracoConfig.For.UmbracoSettings().RequestHandler.UseDomainPrefixes)
{
//TODO: Why is this checking for UseDomainPrefixes + localhost? I can't figure that part out (even though i wrote that)
var found = _hostsAndIds.FirstOrDefault(x => x.Item1 == string.Empty);
if (found != null)
{
realNodeId = found.Item2;
}
else
{
LogHelper.Warn<ArticulateVirtualNodeByIdRouteHandler>("No entries found in hosts/IDs map with an empty Host value. Values: " + DebugHostIdsCollection());
return null;
}
}
else
{
var found = _hostsAndIds.FirstOrDefault(x => x.Item1.InvariantEquals(requestContext.HttpContext.Request.Url.Host));
if (found != null)
{
realNodeId = found.Item2;
}
else
{
LogHelper.Warn<ArticulateVirtualNodeByIdRouteHandler>("No entries found in hosts/IDs map with a Host value of " + requestContext.HttpContext.Request.Url.Host + ". Values: " + DebugHostIdsCollection());
return null;
}
}
}
var byId = umbracoContext.ContentCache.GetById(realNodeId);
if (byId == null) return null;
return FindContent(requestContext, umbracoContext, byId);
}
示例12: MarketingApiController
/// <summary>
/// Initializes a new instance of the <see cref="MarketingApiController"/> class.
/// </summary>
/// <param name="merchelloContext">
/// The merchello context.
/// </param>
/// <param name="umbracoContext">
/// The umbraco context.
/// </param>
internal MarketingApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
: base(merchelloContext, umbracoContext)
{
_offerSettingsService = merchelloContext.Services.OfferSettingsService;
// TODO - this need to be fixed to make testable
this._providerResolver = OfferProviderResolver.Current;
}
示例13: ShipmentApiController
/// <summary>
/// This is a helper contructor for unit testing
/// </summary>
internal ShipmentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
: base((MerchelloContext) merchelloContext, umbracoContext)
{
_shipmentService = merchelloContext.Services.ShipmentService;
_invoiceService = merchelloContext.Services.InvoiceService;
_orderService = merchelloContext.Services.OrderService;
_shipMethodService = ((ServiceContext)merchelloContext.Services).ShipMethodService;
}
示例14: MerchelloApiController
protected MerchelloApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
: base(umbracoContext)
{
Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
MerchelloContext = merchelloContext;
InstanceId = Guid.NewGuid();
}
示例15: GetNode
/// <summary>
/// Shared with PublishMediaStoreTests
/// </summary>
/// <param name="id"></param>
/// <param name="umbracoContext"></param>
/// <returns></returns>
internal static IPublishedContent GetNode(int id, UmbracoContext umbracoContext)
{
var ctx = umbracoContext;
var mediaStore = new DefaultPublishedMediaStore();
var doc = mediaStore.GetDocumentById(ctx, id);
Assert.IsNotNull(doc);
return doc;
}