private void _prefixes_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // get...
            string ns = (string)e.Key;

            // create...
            int index = 1;

            while (true)
            {
                string prefix = this.EncodePrefix(index);
                if (prefix == null)
                {
                    throw new InvalidOperationException("'prefix' is null.");
                }
                if (prefix.Length == 0)
                {
                    throw new InvalidOperationException("'prefix' is zero-length.");
                }

                // check...
                if (!(this.Prefixes.ContainsValue(prefix)))
                {
                    e.NewValue = prefix;
                    return;
                }

                // next...
                index++;
            }
        }
Exemple #2
0
        private static void _eventLogSourceLookup_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            string name = (string)e.Key;

            // try it...
            try
            {
                if (EventLog.SourceExists(name))
                {
                    e.NewValue = true;
                }
                else
                {
                    // create...
                    EventLog.CreateEventSource(name, name);

                    // set...  if we get here we can do it...
                    e.NewValue = true;
                }
            }
            catch (Exception ex)
            {
                // no-op...
                Console.WriteLine(ex);

                // nope...
                e.NewValue = false;
            }
        }
Exemple #3
0
        private static void _extendedTableExists_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            EntityType type = (EntityType)e.Key;

            // get the connection...
            using (IConnection connection = Database.CreateConnection(type.DatabaseName))
                e.NewValue = connection.DoesTableExist(type.NativeNameExtended);
        }
Exemple #4
0
        private void _assemblyLookup_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            ImagesForAssemblyLookup newLookup = new ImagesForAssemblyLookup((Assembly)e.Key);

            newLookup.CreateItemValue += new CreateLookupItemEventHandler(newLookup_CreateItemValue);

            // return...
            e.NewValue = newLookup;
        }
Exemple #5
0
        private static void _assemblyLogs_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // create a new lookup...
            Lookup namesLookup = new Lookup();

            namesLookup.CreateItemValue += new CreateLookupItemEventHandler(namesLookup_CreateItemValue);

            // set...
            e.NewValue = namesLookup;
        }
 private void NamedConnections_CreateItemValue(object sender, CreateLookupItemEventArgs <string, IConnection> e)
 {
     if (e.Key == DefaultKey)
     {
         e.NewValue = Database.CreateConnection();
     }
     else
     {
         e.NewValue = Database.CreateConnection((string)e.Key);
     }
 }
Exemple #7
0
        void ByType_CreateItemValue(object sender, CreateLookupItemEventArgs <EntityType, BfxLookup <long, IDtoCapable> > e)
        {
            var byId = new BfxLookup <long, IDtoCapable>();

            byId.CreateItemValue += (senderById, eById) =>
            {
                eById.NewValue = (IDtoCapable)e.Key.Persistence.GetById(new object[] { eById.Key });
            };

            // return...
            e.NewValue = byId;
        }
Exemple #8
0
        private void _namedConnections_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // create one...
            IConnection connection = Database.CreateConnection((string)e.Key);

            if (connection == null)
            {
                throw new InvalidOperationException("connection is null.");
            }

            // txn...
            connection.BeginTransaction();

            // set...
            e.NewValue = connection;
        }
Exemple #9
0
        private void _byName_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // name...
            string name = (string)e.Key;

            // walk...
            for (int index = 0; index < this.Count; index++)
            {
                if (string.Compare(this[index].Name, name, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
                {
                    e.NewValue = index;
                    return;
                }
            }

            // nope...
            e.NewValue = -1;
        }
Exemple #10
0
        private void newLookup_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // get...
            Assembly asm = ((ImagesForAssemblyLookup)sender).Assembly;

            if (asm == null)
            {
                throw new InvalidOperationException("asm is null.");
            }

            // get...
            Image image = DesktopResourceHelper.GetImage(asm, (string)e.Key);

            if (image == null)
            {
                throw new InvalidOperationException("image is null.");
            }
            e.NewValue = this.InnerImageList.Images.Add(image, this.InnerImageList.TransparentColor);
        }
Exemple #11
0
        static void EnumValuesLookup_CreateItemValue(object sender, CreateLookupItemEventArgs <string, object> e)
        {
            var index    = e.Key.IndexOf('|');
            var typeName = e.Key.Substring(0, index);
            var type     = Type.GetType(typeName);
            var toFind   = ConversionHelper.ToInt64(e.Key.Substring(index + 1));

            // get...
            var masters = Enum.GetValues(type);

            foreach (var master in masters)
            {
                if (ConversionHelper.ToInt64(master) == toFind)
                {
                    e.NewValue = master;
                    return;
                }
            }

            // return...
            e.NewValue = ConversionHelper.ChangeType(toFind, Enum.GetUnderlyingType(type));
        }
Exemple #12
0
        private static void namesLookup_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            // create...
            ILog log = CreateDefaultLog((string)e.Key);

            if (log == null)
            {
                throw new InvalidOperationException("log is null.");
            }

            // raise...
            if (Runtime.IsStarted)
            {
                // mbr - 03-11-2005 - we can do some standard config here...
                ConfigureLogFromInstallationSettings(log);

                // defer...
                Runtime.Current.OnLogCreated(new ILogEventArgs(log));
            }

            // set...
            e.NewValue = log;
        }
Exemple #13
0
 void Items_CreateItemValue(object sender, CreateLookupItemEventArgs <long, T> e)
 {
     e.NewValue = (T)this.EntityType.Persistence.GetById(new object[] { e.Key });
 }
Exemple #14
0
 private static void _cleanupCount_CreateItemValue(object sender, CreateLookupItemEventArgs e)
 {
     e.NewValue = 0;
 }
Exemple #15
0
 private void names_CreateItemValue(object sender, CreateLookupItemEventArgs e)
 {
     e.NewValue = e.Key;
 }