internal string GetSortExpression(ColumnProvider sortColumn, string format) { if ((this.Direction == AssociationDirection.OneToMany) || (this.Direction == AssociationDirection.ManyToMany)) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, DynamicDataResources.AssociationProvider_DirectionDoesNotSupportSorting, new object[] { this.Direction })); } if (sortColumn == null) { throw new ArgumentNullException("sortColumn"); } if (!this.ToTable.Columns.Contains(sortColumn)) { throw new ArgumentException(DynamicDataResources.AssociationProvider_SortColumnDoesNotBelongToEndTable, "sortColumn"); } if (sortColumn.IsSortable) { return(string.Format(CultureInfo.InvariantCulture, format, new object[] { this.FromColumn.Name, sortColumn.Name })); } return(null); }
/// <summary> /// Removes all resources such as menus, handles and forms from KeePass. /// </summary> public override void Terminate() { // Destroy Help Form. if (_helpForm.Visible) { _helpForm.Close(); } else { _helpForm.Dispose(); } // Unregister internal events. PluginHost.MainWindow.Shown -= MainWindow_Shown; PluginHost.MainWindow.UIStateUpdated -= MainWindow_UIStateUpdated; // Dispose menu items if (_menuItemProvider != null) { _menuItemProvider.Dispose(); } // Unregister auto-type function. if (SprEngine.FilterPlaceholderHints.Contains(Settings.AutoTypeFieldName.ExtWithBrackets())) { SprEngine.FilterCompile -= SprEngine_FilterCompile; SprEngine.FilterPlaceholderHints.Remove(Settings.AutoTypeFieldName.ExtWithBrackets()); } // Remove Column provider. PluginHost.ColumnProviderPool.Remove(columnProvider); columnProvider = null; // Remove Timer. _liRefreshTimer.Tick -= OnTimerTick; _liRefreshTimer.Dispose(); }
internal void Initialize() { // If we don't have a PropertyInfo, we're likely dealing with an association column // we created in TryCreateAssociationColumn, and we should skip it here if (EntityTypeProperty == null) { return; } // Check if there is an Entity that has the same type as this column. If so, we treat this column as an entity ref TableProvider parentTable = Table.DataModel.Tables.SingleOrDefault(t => t.EntityType == ColumnType); if (parentTable == null) { return; } DataServiceColumnProvider toColumn = null; ColumnProvider parentPK = null; // Look for the matching Entity Set column in the parent table foreach (DataServiceColumnProvider parentColumn in parentTable.Columns) { // Pick up the parent table's PK column on the way if (parentColumn.IsPrimaryKey) { parentPK = parentColumn; } // The Entity Set column is expected to be of a type like IList<AcmeProduct> if (!parentColumn.ColumnType.IsGenericType) { continue; } Type childrenType = parentColumn.ColumnType.GetGenericArguments()[0]; if (childrenType == Table.EntityType) { toColumn = parentColumn; break; } } var foreignKeyNames = new List <string>(); foreignKeyNames.Add(Name + "." + parentPK.Name); if (toColumn == null) { Association = new DataServiceAssociationProvider(AssociationDirection.ManyToOne, this, parentTable, foreignKeyNames); } else { Association = new DataServiceAssociationProvider(AssociationDirection.ManyToOne, this, toColumn, foreignKeyNames); // Create the reverse association var reverseAssociation = new DataServiceAssociationProvider(AssociationDirection.OneToMany, toColumn, this, foreignKeyNames); toColumn.Association = reverseAssociation; } }
public MetaColumn(MetaTable table, ColumnProvider columnProvider) { Table = table; Provider = columnProvider; }
public CustomMetaChildrenColumn(MetaTable table, ColumnProvider columnProvider) : base(table, columnProvider) { }
public MetaColumn(MetaTable table, ColumnProvider columnProvider);
internal void AddColumn(ColumnProvider cp) { _columns.Add(cp); }
public MetaChildrenColumn(MetaTable table, ColumnProvider entityMember) : base(table, entityMember) { }
public DynamicDataAssociationProvider(AssociationDirection direction, ColumnProvider owner, ColumnProvider to) { this.Direction = direction; this.IsPrimaryKeyInThisTable = owner.IsPrimaryKey; this.FromColumn = owner; this.ToTable = to.Table; }
public void ResolveAssociations() { if (associationResolved) { return; } associationResolved = true; string associated = column.AssociatedTo; if (String.IsNullOrEmpty(associated)) { return; } string[] names = associated.Split(new char[] { '.' }); if (names.Length != 2) { throw new ApplicationException("Only associations of type Table.Column are supported"); } string tableName = names[0]; string columnName = names[1]; TableProvider tableProvider = null; try { tableProvider = Table.DataModel.Tables.First <TableProvider> ((TableProvider tp) => { if (tp.Name == tableName) { return(true); } return(false); }); } catch { return; } if (tableProvider == null) { return; } ColumnProvider toColumn = null; try { toColumn = tableProvider.Columns.First <ColumnProvider> ((ColumnProvider cp) => { if (cp.Name == columnName) { return(true); } return(false); }); } catch { return; } if (toColumn == null) { return; } IsForeignKeyComponent = true; Association = new DynamicDataAssociationProvider(column.AssociationDirection, this, toColumn); }
protected virtual MetaColumn CreateColumn(ColumnProvider columnProvider) { return(new MetaColumn(this, columnProvider)); }
protected virtual MetaForeignKeyColumn CreateForeignKeyColumn(ColumnProvider columnProvider) { return(new MetaForeignKeyColumn(this, columnProvider)); }
internal MetaForeignKeyColumn(MetaTable table, ColumnProvider provider) : base(table, provider) { }
public MetaForeignKeyColumn(MetaTable table, ColumnProvider entityMember) : base(table, entityMember) { }
protected override MetaChildrenColumn CreateChildrenColumn(ColumnProvider columnProvider) { return(new CustomMetaChildrenColumn(this, columnProvider)); }
public override string GetSortExpression(ColumnProvider sortColumn) { return(this.GetSortExpression(sortColumn, "{0}.{1}")); }
protected override MetaForeignKeyColumn CreateForeignKeyColumn(ColumnProvider columnProvider) { return(new CustomMetaForeignKeyColumn(this, columnProvider)); }
public CustomMetaForeignKeyColumn(MetaTable table, ColumnProvider columnProvider) : base(table, columnProvider) { }