/// <summary> /// Gets the context items. /// </summary> /// <returns>The collection of the context items.</returns> public override ContextItemCollection Select() { var result = new ContextItemCollection(); foreach (ShopContext shopContext in this.ShopContextFactory.GetWebShops()) { result.Add( new ContextItem { Name = shopContext.InnerSite.Name, Title = shopContext.InnerSite.BrowserTitle, Tooltip = shopContext.InnerSite.BrowserTitle }); } return result; }
/// <summary> /// Gets the context items. /// </summary> /// <returns>The collection of the context items.</returns> public override ContextItemCollection Select() { var result = new ContextItemCollection(); foreach (ShopContext shopContext in this.ShopContextFactory.GetWebShops()) { result.Add( new ContextItem { Name = shopContext.InnerSite.Name, Title = shopContext.InnerSite.BrowserTitle, Tooltip = shopContext.InnerSite.BrowserTitle }); } return(result); }
/// <summary> /// Attach a new context item collection to the current context. /// </summary> /// <param name="context">The <see cref="T:Smartac.SR.Core.ApplicationContexts.ContextItemCollection" /> to attach.</param> /// <param name="behavior">The <see cref="T:Smartac.SR.Core.ApplicationContexts.ContextAttachBehavior" />.</param> public void AttachContext(ContextItemCollection context, ContextAttachBehavior behavior) { if (behavior == ContextAttachBehavior.Clear) { this.Clear(); } foreach (ContextItem current in context) { if (this.GetContextItem(current.Key) == null) { this.SetContextItem(current); } else if (behavior == ContextAttachBehavior.Override) { this.SetContextItem(current); } } }
/// <summary> /// Gets the web shops. /// </summary> /// <returns> /// The web shops. /// </returns> public override ContextItemCollection Select() { var result = new ContextItemCollection(); if (string.IsNullOrEmpty(this.Source)) { return result; } var itemUri = ItemUri.Parse(this.Source); var rootItem = Database.GetItem(itemUri); var webShops = this.ShopContextFactory.GetWebShops().Select(ws => ws.InnerSite.Name); foreach (Item item in rootItem.Children.Where(c => webShops.Any(ws => string.Compare(ws, c["Name"], StringComparison.OrdinalIgnoreCase) == 0))) { result.Add(new ContextItem { Name = item["Name"], Title = item["Title"], Tooltip = item["Tooltip"], Icon = item["Icon"] }); } return result; }
/// <summary> /// Clone the specified ApplicationContext and create a new DependentApplicationContext />. /// </summary> /// <param name="context">The DependentApplicationContext to be cloned.</param> /// <returns>The DependentApplicationContext</returns> /// . public static DependentApplicationContext DepedentClone(this ApplicationContext context) { Guard.ArgumentNotNull(context, "context"); var currentContext = context.ContextLocator.GetCurrentContext(); var contextItemCollection = new ContextItemCollection(); foreach (var current in currentContext) { var obj = current.Value; var cloneable = obj as ICloneable; if (cloneable != null) { obj = cloneable.Clone(); } var contextItem = new ContextItem(current.Key, obj, current.IsLocal); if (current.ReadOnly) { contextItem.ReadOnly = true; } contextItemCollection.Add(contextItem); } return new DependentApplicationContext(contextItemCollection); }
/// <summary> /// Gets the web shops. /// </summary> /// <returns> /// The web shops. /// </returns> public override ContextItemCollection Select() { var result = new ContextItemCollection(); if (string.IsNullOrEmpty(this.Source)) { return(result); } var itemUri = ItemUri.Parse(this.Source); var rootItem = Database.GetItem(itemUri); var webShops = this.ShopContextFactory.GetWebShops().Select(ws => ws.InnerSite.Name); foreach (Item item in rootItem.Children.Where(c => webShops.Any(ws => string.Compare(ws, c["Name"], StringComparison.OrdinalIgnoreCase) == 0))) { result.Add(new ContextItem { Name = item["Name"], Title = item["Title"], Tooltip = item["Tooltip"], Icon = item["Icon"] }); } return(result); }
/// <summary> /// Get all current context item collection. /// </summary> /// <returns> /// A <see cref="T:Smartac.SR.Core.ApplicationContexts.ContextItemCollection" /> containg all of the current context items. /// </returns> public override ContextItemCollection GetCurrentContext() { ContextItemCollection contextItemCollection = new ContextItemCollection(); foreach (string current in CallContextLocator.Keys) { ContextItem contextItem = this.GetContextItem(current); if (contextItem != null) { contextItemCollection.Add(contextItem); } } return contextItemCollection; }
/// <summary> /// Get all current context item collection. /// </summary> /// <returns> /// A <see cref="T:Cedar.Core.ApplicationContexts.ContextItemCollection" /> containg all of the current context items. /// </returns> public override ContextItemCollection GetCurrentContext() { if (SessionStateAvailabe) { var contextItemCollection = new ContextItemCollection(); foreach (var current in ContextItemKeys) { contextItemCollection.Add(GetContextItem(current)); } return contextItemCollection; } return CallContextLocator.GetCurrentContext(); }
/// <summary> /// Disposes this editing context. /// </summary> /// <param name="disposing">True if this object is being disposed, or false if it is finalizing.</param> protected virtual void Dispose(bool disposing) { if (disposing) { // Let any interested parties know the context is being disposed if (Disposing != null) { Disposing(this, EventArgs.Empty); } if (_contextItems != null) { foreach (var contextItem in _contextItems) { var d = contextItem as IDisposable; if (d != null) { d.Dispose(); } } } _efArtifactService = null; _contextItems = null; } }
/// <summary> /// Initializes a new instance of the DependentApplicationContext class. /// </summary> /// <param name="items">The collection of context items.</param> public DependentApplicationContext(ContextItemCollection items) { Guard.ArgumentNotNull(items, "items"); this.Items = items; this.MasterThread = Thread.CurrentThread; }
/// <summary> /// Get all current context item collection. /// </summary> /// <returns> /// A <see cref="T:Smartac.SR.Core.ApplicationContexts.ContextItemCollection" /> containg all of the current context items. /// </returns> public override ContextItemCollection GetCurrentContext() { if (this.SessionStateAvailabe) { ContextItemCollection contextItemCollection = new ContextItemCollection(); foreach (string current in this.ContextItemKeys) { contextItemCollection.Add(this.GetContextItem(current)); } return contextItemCollection; } return this.CallContextLocator.GetCurrentContext(); }
/// <summary> /// Get all current context item collection. /// </summary> /// <returns> /// A <see cref="T:Cedar.Core.ApplicationContexts.ContextItemCollection" /> containg all of the current context items. /// </returns> public override ContextItemCollection GetCurrentContext() { var contextItemCollection = new ContextItemCollection(); foreach (var current in Keys) { var contextItem = GetContextItem(current); if (contextItem != null) { contextItemCollection.Add(contextItem); } } return contextItemCollection; }