當前位置: 首頁>>代碼示例>>C#>>正文


C# Web.UmbracoContext類代碼示例

本文整理匯總了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 );
 }
開發者ID:rasmuseeg,項目名稱:UmbracoFeed,代碼行數:7,代碼來源:XmlRssHandler.cs

示例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;
 }
開發者ID:BatJan,項目名稱:Merchello,代碼行數:10,代碼來源:ProductVariantApiController.cs

示例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();			
		}
開發者ID:elrute,項目名稱:Triphulcas,代碼行數:25,代碼來源:PublishContentStoreTests.cs

示例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;
		}
開發者ID:elrute,項目名稱:Triphulcas,代碼行數:36,代碼來源:UmbracoModule.cs

示例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);
        }
開發者ID:BenFidge,項目名稱:Articulate,代碼行數:7,代碼來源:UmbracoVirtualNodeByIdRouteHandler.cs

示例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);
 }
開發者ID:ProNotion,項目名稱:Merchello,代碼行數:16,代碼來源:OrderApiController.cs

示例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;
 }
開發者ID:naepalm,項目名稱:Merchello,代碼行數:10,代碼來源:CatalogShippingApiController.cs

示例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);
		}
開發者ID:Jeavon,項目名稱:Umbraco-CMS,代碼行數:11,代碼來源:UmbracoUserControl.cs

示例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;
 }
開發者ID:Vrijdagonline,項目名稱:formulate,代碼行數:11,代碼來源:FormsController.cs

示例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);
                    }
                }
            }
        }
開發者ID:MattSchroer,項目名稱:constellation.umbraco.seo,代碼行數:40,代碼來源:DefaultCrawler.cs

示例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);
        }
開發者ID:simonech,項目名稱:Articulate,代碼行數:59,代碼來源:ArticulateVirtualNodeByIdRouteHandler.cs

示例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;
        }
開發者ID:drpeck,項目名稱:Merchello,代碼行數:17,代碼來源:MarketingApiController.cs

示例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;
 }
開發者ID:kedde,項目名稱:Merchello,代碼行數:11,代碼來源:ShipmentApiController.cs

示例14: MerchelloApiController

        protected MerchelloApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(umbracoContext)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");

            MerchelloContext = merchelloContext;
            InstanceId = Guid.NewGuid();
        }
開發者ID:naepalm,項目名稱:Merchello,代碼行數:8,代碼來源:MerchelloApiController.cs

示例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;
		}
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:14,代碼來源:PublishedMediaTests.cs


注:本文中的Umbraco.Web.UmbracoContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。