Пример #1
0
        // --------------------------------------------------

        /// <summary>
        /// Merges this instance with the specified data context.
        /// </summary>
        /// <param name="dataContext">The data context to consider.</param>
        public void Merge(IBdoDataContext dataContext)
        {
            if (dataContext != null)
            {
                foreach (KeyValuePair <string, object> entry in dataContext.SingletonItems)
                {
                    if (!SingletonItems.ContainsKey(entry.Key))
                    {
                        SingletonItems.Add(entry.Key, entry.Value);
                    }
                }

                foreach (KeyValuePair <string, object> entry in dataContext.ScopedItems)
                {
                    if (!ScopedItems.ContainsKey(entry.Key))
                    {
                        ScopedItems.Add(entry.Key, entry.Value);
                    }
                }

                foreach (KeyValuePair <string, object> entry in dataContext.TransientItems)
                {
                    if (!TransientItems.ContainsKey(entry.Key))
                    {
                        TransientItems.Add(entry.Key, entry.Value);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a new scoped item to this instance.
        /// </summary>
        /// <param name="name">Name of the item to add.</param>
        /// <param name="item">The item to consider.</param>
        /// <param name="contextSectionName">Name of the context section to consider.</param>
        public void AddScopedItem(
            string name,
            object item,
            string contextSectionName = null)
        {
            string itemName = BdoDataContext.GetItemUniqueName(name, contextSectionName);

            ScopedItems.Remove(itemName);
            ScopedItems.Add(name, item);
        }