Example #1
0
 private void OnCreateItemValue(CreateLookupItemEventArgs <TKey1, TKey2, TValue> e)
 {
     if (this.CreateItemValue != null)
     {
         this.CreateItemValue(this, e);
     }
 }
Example #2
0
 /// <summary>
 /// Raised the <see cref="CreateItemValue"/> event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnCreateItemValue(CreateLookupItemEventArgs e)
 {
     if (this.CreateItemValue != null)
     {
         this.CreateItemValue(this, e);
     }
 }
Example #3
0
//		private string SharedSettingsCacheFilePath
//		{
//			get
//			{
//				// get...
//				return Path.Combine(Runtime.Current.AllUsersApplicationDataFolderPath, SharedSettingsCacheFileName);
//			}
        //		}

        private void _caches_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // create a new lookup...
            Lookup items = new Lookup();

            items.CreateItemValue += new CreateLookupItemEventHandler(PerDatabaseCreateItemValue);

            // set...
            e.NewValue = items;
        }
Example #4
0
        void InnerLookup_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            var newE = new CreateLookupItemEventArgs <TKey, TValue>((TKey)e.Key);

            if (this.CreateItemValue != null)
            {
                this.CreateItemValue(this, newE);
            }

            e.NewValue = newE.NewValue;
        }
Example #5
0
        private void InnerLookup_CreateItemValue(object sender, CreateLookupItemEventArgs <TKey1, BfxLookup <TKey2, TValue> > e)
        {
            e.NewValue = new BfxLookup <TKey2, TValue>();
            e.NewValue.CreateItemValue += (theSender, theE) =>
            {
                var newE = new CreateLookupItemEventArgs <TKey1, TKey2, TValue>(e.Key, theE.Key);
                this.OnCreateItemValue(newE);

                // pass...
                theE.NewValue = newE.NewValue;
            };
        }
Example #6
0
        private void PerDatabaseCreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            string name = (string)e.Key;

            // do we have it?
            if (!(_ensureCalled))
            {
                try
                {
                    ConfigItem.EnsureConfigTableExists();
                }
                finally
                {
                    _ensureCalled = true;
                }
            }

            // mbr - 10-03-2006 - check...
            if (CompanyName == null)
            {
                throw new InvalidOperationException("'CompanyName' is null.");
            }
            if (CompanyName.Length == 0)
            {
                throw new InvalidOperationException("'CompanyName' is zero-length.");
            }
            if (ProductName == null)
            {
                throw new InvalidOperationException("'ProductName' is null.");
            }
            if (ProductName.Length == 0)
            {
                throw new InvalidOperationException("'ProductName' is zero-length.");
            }

            // get...
            ConfigItem item = ConfigItem.GetByCompanyProductAndName(this.CompanyName, this.ProductName, name);

            // mbr - 02-04-2006 - don't create the item - just won't work if we do.
//			if(item == null)
//			{
//				item = new ConfigItem();
//				item.CompanyName = this.CompanyName;
//				item.ProductName = this.ProductName;
//				item.Name = name;
//				item.Version = 0;
//			}

            // return...
            e.NewValue = item;
        }
Example #7
0
        /// <summary>
        /// Demand loads the item.
        /// </summary>
        /// <param name="key"></param>
        // mbr - 2010-01-20 - broken into separate method...
        private void LoadItem(object key, bool forceReload)
        {
            Lock.UpgradeToWriterLock(-1);

            // try again...
            if (forceReload || !(InnerValues.Contains(key)))
            {
                // create it...
                CreateLookupItemEventArgs e = new CreateLookupItemEventArgs(key);
                this.OnCreateItemValue(e);

                // add...
                // mbr - 2010-01-20 - added wrap...
                //InnerValues[key] = e.NewValue;
                InnerValues[key] = Wrap(e.NewValue);
            }
        }