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++; } }
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; } }
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); }
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; }
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); } }
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; }
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; }
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; }
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); }
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)); }
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; }
void Items_CreateItemValue(object sender, CreateLookupItemEventArgs <long, T> e) { e.NewValue = (T)this.EntityType.Persistence.GetById(new object[] { e.Key }); }
private static void _cleanupCount_CreateItemValue(object sender, CreateLookupItemEventArgs e) { e.NewValue = 0; }
private void names_CreateItemValue(object sender, CreateLookupItemEventArgs e) { e.NewValue = e.Key; }