/// <summary> /// Register a data control to give it Dynamic Data behavior /// </summary> /// <param name="setSelectionFromUrl">When true, if a primary key is found in the route values /// (typically on the query string), it will get be set as the selected item. This only applies /// to list controls.</param> public void RegisterControl(Control control, bool setSelectionFromUrl) { // if (DesignMode) { return; } IDataBoundControlInterface dataBoundControl = DataControlHelper.GetDataBoundControl(control, true /*failIfNotFound*/); // If we can't get an associated IDynamicDataSource, don't do anything IDynamicDataSource dataSource = dataBoundControl.DataSourceObject as IDynamicDataSource; if (dataSource == null) { return; } // If we can't get a MetaTable from the data source, don't do anything MetaTable table = MetaTableHelper.GetTableWithFullFallback(dataSource, Context.ToWrapper()); // Save the datasource so we can process its parameters in OnLoad. The value we set is irrelevant _dataSources[dataSource] = null; ((INamingContainer)control).SetMetaTable(table); BaseDataBoundControl baseDataBoundControl = control as BaseDataBoundControl; if (baseDataBoundControl != null) { EnablePersistedSelection(baseDataBoundControl, table); } RegisterControlInternal(dataBoundControl, dataSource, table, setSelectionFromUrl, Page.IsPostBack); }
public static MetaTable FindMetaTable(this Control current) { // .NET doesn't perform the check, we will if (current == null) { throw new NullReferenceException(); } while (current != null) { DataBoundControl dbc = current as DataBoundControl; if (dbc != null) { IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource; if (dds != null) { return(dds.GetTable()); } } current = current.NamingContainer; } return(null); }
/// Gets a table from an IDynamicDataSource's ContextType and EntitySetName. /// Does not throw, returns null on failure. internal static MetaTable GetTableFromDynamicDataSource(IDynamicDataSource dynamicDataSource) { string tableName = dynamicDataSource.EntitySetName; Type contextType = dynamicDataSource.ContextType; if (contextType == null || String.IsNullOrEmpty(tableName)) { return(null); } MetaModel model; if (MetaModel.MetaModelManager.TryGetModel(contextType, out model)) { Debug.Assert(model != null); MetaTable table; if (model.TryGetTable(tableName, out table)) { return(table); } } return(null); }
internal static MetaTable GetTableWithFullFallback(IDataSource dataSource, HttpContextBase context) { MetaTable table = GetTableFromMapping(context, dataSource); if (table != null) { return(table); } IDynamicDataSource dynamicDataSource = dataSource as IDynamicDataSource; if (dynamicDataSource != null) { table = GetTableFromDynamicDataSource(dynamicDataSource); if (table != null) { return(table); } } table = DynamicDataRouteHandler.GetRequestMetaTable(context); if (table != null) { return(table); } Control c = dataSource as Control; string id = (c != null ? c.ID : String.Empty); throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.MetaTableHelper_CantFindTable, id)); }
public static MetaTable GetTable(this IDynamicDataSource dataSource) { if (dataSource == null) { return(null); } string entitySetName = dataSource.EntitySetName; if (String.IsNullOrEmpty(entitySetName)) { // LAMESPEC: MSDN says we should throw in this case, but .NET calls // DynamicDataRouteHandler.GetRequestMetaTable(HttpContext // httpContext) instead (eventually) MetaTable ret = DynamicDataRouteHandler.GetRequestMetaTable(HttpContext.Current); if (ret == null) { throw new InvalidOperationException("The control '" + GetDataSourceId(dataSource) + "' does not have a TableName property and a table name cannot be inferred from the URL."); } } Type contextType = dataSource.ContextType; if (contextType == null) { throw new InvalidOperationException("The ContextType property of control '" + GetDataSourceId(dataSource) + "' must specify a data context"); } return(MetaModel.GetModel(contextType).GetTable(entitySetName)); }
/// <summary> /// Expand Dynamic where parameter (e.g. DynamicControlParameter, DynamicQueryStringParameter) into /// 'regular' parameters that the datasource can understand /// </summary> /// <param name="dataSource">The datasource which Where parameters need to be expanded</param> public static void ExpandDynamicWhereParameters(this IDynamicDataSource dataSource) { ParameterCollection whereParameters = dataSource.WhereParameters; // First, check if any parameters need to be expanded bool needProcessing = false; foreach (Parameter parameter in whereParameters) { if (parameter is IWhereParametersProvider) { needProcessing = true; break; } } // If not, don't do anything if (!needProcessing) { return; } // Make a copy of the parameters, and clear the collection var whereParametersCopy = new Parameter[whereParameters.Count]; whereParameters.CopyTo(whereParametersCopy, 0); whereParameters.Clear(); // Go through all the parameters and expand them foreach (Parameter parameter in whereParametersCopy) { ExpandWhereParameter(dataSource, parameter); } }
public static void RegisterInsertDefaults(IDynamicDataSource dataSource, DetailsView detailsView, bool hideDefaults) { RequestContext requestContext = DynamicDataRouteHandler.GetRequestContext(HttpContext.Current); MetaTable table = dataSource.GetTable(); if (hideDefaults) { var fieldGenerator = detailsView.RowsGenerator as AdvancedFieldGenerator; if (fieldGenerator != null) { fieldGenerator.SkipList.AddRange(BuildSkipList(table, requestContext.RouteData.Values)); } else { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "Expected a field generator of type {0}", typeof(AdvancedFieldGenerator).FullName)); } detailsView.ItemInserting += delegate(object sender, DetailsViewInsertEventArgs e) { SetDefaultInsertValues(table, requestContext.RouteData.Values, e.Values); }; } else { detailsView.DataBound += delegate(object sender, EventArgs e) { //In the seperate page version we pull the values from the querystring via routing SetDefaultInsertControlValues(table, detailsView, requestContext.RouteData.Values); }; } }
/// <summary> /// See IWhereParametersProvider /// </summary> public virtual IEnumerable <Parameter> GetWhereParameters(IDynamicDataSource dataSource) { // Add all the specific filters as where parameters return(GetFilterControls().Select(filter => (Parameter) new DynamicControlParameter(filter.UniqueID) { Name = filter.DataField, })); }
private static Type GetType(IQueryableDataSource dataSource) { IDynamicDataSource dynamicDataSource = dataSource as IDynamicDataSource; if (dynamicDataSource != null) { return(dynamicDataSource.ContextType); } return(null); }
/// <summary> /// See IWhereParametersProvider.GetWhereParameters /// </summary> public virtual IEnumerable<Parameter> GetWhereParameters(IDynamicDataSource dataSource) { var table = MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper()); // check makes no sense as the above call will throw //if (table == null) { // return new Parameter[0]; //} return RouteParametersHelper.GetColumnParameters(table, Name); }
static string GetDataSourceId(IDynamicDataSource dataSource) { Control c = dataSource as Control; if (c == null) { return(String.Empty); } return(c.ID); }
/// <summary> /// See IWhereParametersProvider.GetWhereParameters /// </summary> public virtual IEnumerable <Parameter> GetWhereParameters(IDynamicDataSource dataSource) { var table = MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper()); // check makes no sense as the above call will throw //if (table == null) { // return new Parameter[0]; //} return(RouteParametersHelper.GetColumnParameters(table, Name)); }
protected override void OnInit(EventArgs e) { IDynamicDataSource dds = DynamicDataSource; if (dds != null) { dds.Exception += HandleException; } base.OnInit(e); }
public void SetSource(object source) { data = source; bindingProperty = data as IBindingProperty; bindingHandler = bindingProperty?.Subscribe(OnValueChange); array = data as Array; dynamicData = data as IDynamicDataSource; list = data as IList; dictionary = data as IDictionary; }
/// <summary> /// See IWhereParametersProvider.GetWhereParameters /// </summary> public virtual IEnumerable<Parameter> GetWhereParameters(IDynamicDataSource dataSource) { Debug.Assert(dataSource != null); // Find the control that the ControlParameter uses Control control = Misc.FindControl((Control)dataSource, ControlId); if (control == null) { throw new InvalidOperationException(String.Format( CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlNotFound, ControlId)); } // If the control is itself a parameter provider, delegate to it var whereParametersProvider = control as IWhereParametersProvider; if (whereParametersProvider != null) { return whereParametersProvider.GetWhereParameters(dataSource); } IControlParameterTarget paramTarget = DynamicDataManager.GetControlParameterTarget(control); if (paramTarget == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlCannotBeUsedAsParent, ControlId)); } string columnName = Name; MetaColumn column = null; MetaTable table = MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper()); if (!String.IsNullOrEmpty(columnName)) { column = table.GetColumn(columnName); } else { // There was no Name attribute telling us what field to filter, but maybe // the control given us data has that info column = paramTarget.FilteredColumn; } if (column == null) { // If there is no specific column, we're setting the primary key if (paramTarget.Table != table) { throw new Exception(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_InvalidPK, ControlId, paramTarget.Table, table.Name)); } return GetPrimaryKeyControlWhereParameters(control, paramTarget); } else if (column is MetaForeignKeyColumn) { return GetForeignKeyControlWhereParameters(control, paramTarget, (MetaForeignKeyColumn)column); } return GetPropertyControlWhereParameters(control, paramTarget, column); }
void RegisterDataSource(IDynamicDataSource dds) { if (knownDataSources == null) { knownDataSources = new Dictionary <IDynamicDataSource, bool> (); knownDataSources.Add(dds, true); return; } if (knownDataSources.ContainsKey(dds)) { return; } knownDataSources.Add(dds, true); }
protected override void OnInit(EventArgs e) { base.OnInit(e); // Don't do anything in Design mode if (DesignMode) { return; } IDynamicDataSource dataSource = DynamicDataSource; if (dataSource != null) { // Register for datasource exception so that we're called if an error occurs // during an update/insert/delete dataSource.Exception += new EventHandler <DynamicValidatorEventArgs>(OnException); } }
private static void ExpandWhereParameter(IDynamicDataSource dataSource, Parameter parameter) { var provider = parameter as IWhereParametersProvider; if (provider == null) { // If it's a standard parameter, just add it dataSource.WhereParameters.Add(parameter); } else { // Get the list of sub-parameters and expand them recursively IEnumerable <Parameter> newParameters = provider.GetWhereParameters(dataSource); foreach (Parameter newParameter in newParameters) { ExpandWhereParameter(dataSource, newParameter); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // http://forums.asp.net/p/1257004/2339034.aspx // http://forums.asp.net/t/1297860.aspx // http://forums.asp.net/p/1396453/3005197.aspx#3005197 if (knownDataSources != null) { foreach (var de in knownDataSources) { IDynamicDataSource dds = de.Key; if (dds == null) { continue; } dds.ExpandDynamicWhereParameters(); } } }
internal MethodInfo ResolveMethod() { if (String.IsNullOrEmpty(MethodName)) { throw new InvalidOperationException(AtlasWeb.MethodExpression_MethodNameMustBeSpecified); } MethodInfo methodInfo = null; // We allow the format string {0} in the method name IDynamicDataSource dataSource = DataSource as IDynamicDataSource; if (dataSource != null) { MethodName = String.Format(CultureInfo.CurrentCulture, MethodName, dataSource.EntitySetName); } else if (MethodName.Contains("{0}")) { // If method has a format string but no IDynamicDataSource then throw an exception throw new InvalidOperationException(AtlasWeb.MethodExpression_DataSourceMustBeIDynamicDataSource); } foreach (Func <Type> typeGetter in typeGetters) { Type type = typeGetter(); // If the type is null continue to next fall back function if (type == null) { continue; } methodInfo = type.GetMethod(MethodName, MethodFlags); if (methodInfo != null) { break; } } return(methodInfo); }
public void RegisterControl(Control control, bool setSelectionFromUrl) { // .NET doesn't check for null here, but since I don't like such code, we // will do the check and throw the same exception as .NET if (control == null) { throw new NullReferenceException(); } if (!ControlIsValid(control)) { throw new Exception("Controls of type " + control.GetType() + " are not supported."); } DataBoundControl dbc = control as DataBoundControl; if (dbc != null) { IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource; if (dds == null) { return; } MetaTable table = dds.GetTable(); if (table == null) { return; } GridView gv = control as GridView; if (gv != null) { gv.ColumnsGenerator = new AutoFieldGenerator(table); return; } } }
void RegisterDataSource (IDynamicDataSource dds) { if (knownDataSources == null) { knownDataSources = new Dictionary <IDynamicDataSource, bool> (); knownDataSources.Add (dds, true); return; } if (knownDataSources.ContainsKey (dds)) return; knownDataSources.Add (dds, true); }
void PostUpdateCleanup() { if( archiveStorage_!=null ) { archiveStorage_.Dispose(); archiveStorage_=null; } updateDataSource_=null; updates_ = null; updateIndex_ = null; }
internal void RegisterControlInternal(IDataBoundControlInterface dataBoundControl, IDynamicDataSource dataSource, IMetaTable table, bool setSelectionFromUrl, bool isPostBack) { // Set the auto field generator (for controls that support it - GridView and DetailsView) IFieldControl fieldControl = dataBoundControl as IFieldControl; if (fieldControl != null) { fieldControl.FieldsGenerator = new DefaultAutoFieldGenerator(table); } var linqDataSource = dataSource as LinqDataSource; var entityDataSource = dataSource as EntityDataSource; // If the context type is not set, we need to set it if (dataSource.ContextType == null) { dataSource.ContextType = table.DataContextType; // If it's a LinqDataSurce, register for ContextCreating so the context gets created using the correct ctor // Ideally, this would work with other datasource, but we just don't have the right abstraction if (linqDataSource != null) { linqDataSource.ContextCreating += delegate(object sender, LinqDataSourceContextEventArgs e) { e.ObjectInstance = table.CreateContext(); }; } if (entityDataSource != null) { entityDataSource.ContextCreating += delegate(object sender, EntityDataSourceContextCreatingEventArgs e) { e.Context = (ObjectContext)table.CreateContext(); }; } } // If the datasource doesn't have an EntitySetName (aka TableName), set it from the meta table if (String.IsNullOrEmpty(dataSource.EntitySetName)) { dataSource.EntitySetName = table.DataContextPropertyName; } // If there is no Where clause, turn on auto generate if (String.IsNullOrEmpty(dataSource.Where)) { dataSource.AutoGenerateWhereClause = true; } // If it's a LinqDataSource and the flag is set, pre load the foreign keys if (AutoLoadForeignKeys && linqDataSource != null) { linqDataSource.LoadWithForeignKeys(table.EntityType); } if (!isPostBack) { if (table.HasPrimaryKey) { dataBoundControl.DataKeyNames = table.PrimaryKeyNames; // Set the virtual selection from the URL if needed var dataKeySelector = dataBoundControl as IPersistedSelector; if (dataKeySelector != null && setSelectionFromUrl) { DataKey dataKey = table.GetDataKeyFromRoute(); if (dataKey != null) { dataKeySelector.DataKey = dataKey; } } } } }
static string GetDataSourceId (IDynamicDataSource dataSource) { Control c = dataSource as Control; if (c == null) return String.Empty; return c.ID; }
public virtual IEnumerable <Parameter> GetWhereParameters(IDynamicDataSource dataSource) { throw new NotImplementedException(); }
// TBD: Direct form of updating // // public void Update(IEntryMatcher deleteMatcher) // { // } // // public void Update(IScanner addScanner) // { // } #endregion #region Deferred Updating /// <summary> /// Begin updating this <see cref="ZipFile"/> archive. /// </summary> /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param> /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param> public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) { if ( IsEmbeddedArchive ) { throw new ZipException ("Cannot update embedded/SFX archives"); } if ( archiveStorage == null ) { throw new ArgumentNullException("archiveStorage"); } if ( dataSource == null ) { throw new ArgumentNullException("dataSource"); } archiveStorage_ = archiveStorage; updateDataSource_ = dataSource; // NOTE: the baseStream_ may not currently support writing or seeking. if ( entries_ != null ) { updates_ = new ArrayList(entries_.Length); foreach(ZipEntry entry in entries_) { updates_.Add(new ZipUpdate(entry)); } } else { updates_ = new ArrayList(); } contentsEdited_ = false; commentEdited_ = false; newComment_ = null; }
/// <summary> /// See IWhereParametersProvider.GetWhereParameters /// </summary> public virtual IEnumerable <Parameter> GetWhereParameters(IDynamicDataSource dataSource) { Debug.Assert(dataSource != null); // Find the control that the ControlParameter uses Control control = Misc.FindControl((Control)dataSource, ControlId); if (control == null) { throw new InvalidOperationException(String.Format( CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlNotFound, ControlId)); } // If the control is itself a parameter provider, delegate to it var whereParametersProvider = control as IWhereParametersProvider; if (whereParametersProvider != null) { return(whereParametersProvider.GetWhereParameters(dataSource)); } IControlParameterTarget paramTarget = DynamicDataManager.GetControlParameterTarget(control); if (paramTarget == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlCannotBeUsedAsParent, ControlId)); } string columnName = Name; MetaColumn column = null; MetaTable table = MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper()); if (!String.IsNullOrEmpty(columnName)) { column = table.GetColumn(columnName); } else { // There was no Name attribute telling us what field to filter, but maybe // the control given us data has that info column = paramTarget.FilteredColumn; } if (column == null) { // If there is no specific column, we're setting the primary key if (paramTarget.Table != table) { throw new Exception(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_InvalidPK, ControlId, paramTarget.Table, table.Name)); } return(GetPrimaryKeyControlWhereParameters(control, paramTarget)); } else if (column is MetaForeignKeyColumn) { return(GetForeignKeyControlWhereParameters(control, paramTarget, (MetaForeignKeyColumn)column)); } return(GetPropertyControlWhereParameters(control, paramTarget, column)); }
/// <summary> /// See IWhereParametersProvider /// </summary> public virtual IEnumerable<Parameter> GetWhereParameters(IDynamicDataSource dataSource) { // Add all the specific filters as where parameters return GetFilterControls().Select(filter => (Parameter)new DynamicControlParameter(filter.UniqueID) { Name = filter.DataField, }); }
public void DynamicDataExtensions_GetTable_Test() { IDynamicDataSource dds = null; dds.GetTable(); }
// TBD: Direct form of updating // // public void Update(IEntryMatcher deleteMatcher) // { // } // // public void Update(IScanner addScanner) // { // } #endregion #region Deferred Updating /// <summary> /// Begin updating this <see cref="ZipFile"/> archive. /// </summary> /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param> /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param> /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception> /// <exception cref="ArgumentNullException">One of the arguments provided is null</exception> /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception> public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) { if ( archiveStorage == null ) { throw new ArgumentNullException("archiveStorage"); } if ( dataSource == null ) { throw new ArgumentNullException("dataSource"); } if ( _isDisposed ) { throw new ObjectDisposedException("ZipFile"); } if ( IsEmbeddedArchive ) { throw new ZipException ("Cannot update embedded/SFX archives"); } _archiveStorage = archiveStorage; _updateDataSource = dataSource; // NOTE: the baseStream_ may not currently support writing or seeking. _updateIndex = new Hashtable(); _updates = new ArrayList(_entries.Length); foreach(ZipEntry entry in _entries) { int index = _updates.Add(new ZipUpdate(entry)); _updateIndex.Add(entry.Name, index); } _updateCount = _updates.Count; _contentsEdited = false; _commentEdited = false; _newComment = null; }
public void RegisterControl(Control control, bool setSelectionFromUrl) { // .NET doesn't check for null here, but since I don't like such code, we // will do the check and throw the same exception as .NET if (control == null) { throw new NullReferenceException(); } if (!ControlIsValid(control)) { throw new Exception("Controls of type " + control.GetType() + " are not supported."); } // http://forums.asp.net/p/1257004/2339034.aspx // http://forums.asp.net/p/1383908/2936065.aspx DataBoundControl dbc = control as DataBoundControl; if (dbc != null) { IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource; if (dds == null) { return; } RegisterDataSource(dds); MetaTable table = dds.GetTable(); if (table == null) { return; } if (String.IsNullOrEmpty(dds.Where)) { dds.AutoGenerateWhereClause = true; } else { dds.AutoGenerateWhereClause = false; } Type contextType = dds.ContextType; if (contextType == null) { dds.ContextType = table.DataContextType; } string entityName = dds.EntitySetName; if (String.IsNullOrEmpty(entityName)) { dds.EntitySetName = table.DataContextPropertyName; } if (AutoLoadForeignKeys) { var ldds = dds as LinqDataSource; if (ldds != null) { ldds.LoadWithForeignKeys(table.EntityType); } } var gv = control as GridView; if (gv != null) { gv.ColumnsGenerator = new AutoFieldGenerator(table); return; } var dv = control as DetailsView; if (dv != null) { dv.RowsGenerator = new AutoFieldGenerator(table); return; } } }
/// Gets a table from an IDynamicDataSource's ContextType and EntitySetName. /// Does not throw, returns null on failure. internal static MetaTable GetTableFromDynamicDataSource(IDynamicDataSource dynamicDataSource) { string tableName = dynamicDataSource.EntitySetName; Type contextType = dynamicDataSource.ContextType; if (contextType == null || String.IsNullOrEmpty(tableName)) { return null; } MetaModel model; if (MetaModel.MetaModelManager.TryGetModel(contextType, out model)) { Debug.Assert(model != null); MetaTable table; if (model.TryGetTable(tableName, out table)) { return table; } } return null; }
public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) { if (archiveStorage == null) { throw new ArgumentNullException(nameof(archiveStorage)); } if (dataSource == null) { throw new ArgumentNullException(nameof(dataSource)); } if (_isDisposed) { throw new ObjectDisposedException("ZipFile"); } if (IsEmbeddedArchive) { throw new ZipException("Cannot update embedded/SFX archives"); } _archiveStorage = archiveStorage; _updateDataSource = dataSource; _updateIndex = new Hashtable(); _updates = new ArrayList(_entries.Length); foreach (var entry in _entries) { var num = _updates.Add(new ZipUpdate(entry)); _updateIndex.Add(entry.Name, num); } _updates.Sort(new UpdateComparer()); var num2 = 0; foreach (ZipUpdate update in _updates) { if (num2 == (_updates.Count - 1)) { break; } update.OffsetBasedSize = ((ZipUpdate)_updates[num2 + 1]).Entry.Offset - update.Entry.Offset; num2++; } _updateCount = _updates.Count; _contentsEdited = false; _commentEdited = false; _newComment = null; }
public static void ExpandDynamicWhereParameters(this IDynamicDataSource dataSource) { throw new NotImplementedException(); }
public static MetaTable GetTable(this IDynamicDataSource dataSource) { return(MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper())); }
// TBD: Direct form of updating // // public void Update(IEntryMatcher deleteMatcher) // { // } // // public void Update(IScanner addScanner) // { // } #endregion #region Deferred Updating /// <summary> /// Begin updating this <see cref="ZipFile"/> archive. /// </summary> /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param> /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param> /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception> /// <exception cref="ArgumentNullException">One of the arguments provided is null</exception> /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception> public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) { if ( archiveStorage == null ) { throw new ArgumentNullException("archiveStorage"); } if ( dataSource == null ) { throw new ArgumentNullException("dataSource"); } if ( isDisposed_ ) { throw new ObjectDisposedException("ZipFile"); } if ( IsEmbeddedArchive ) { throw new ZipException ("Cannot update embedded/SFX archives"); } archiveStorage_ = archiveStorage; updateDataSource_ = dataSource; // NOTE: the baseStream_ may not currently support writing or seeking. updateIndex_ = new Hashtable(); updates_ = new ArrayList(entries_.Length); foreach(ZipEntry entry in entries_) { int index = updates_.Add(new ZipUpdate(entry)); updateIndex_.Add(entry.Name, index); } // We must sort by offset before using offset's calculated sizes updates_.Sort(new UpdateComparer()); int idx = 0; foreach (ZipUpdate update in updates_) { //If last entry, there is no next entry offset to use if (idx == updates_.Count - 1) break; update.OffsetBasedSize = ((ZipUpdate)updates_[idx + 1]).Entry.Offset - update.Entry.Offset; idx++; } updateCount_ = updates_.Count; contentsEdited_ = false; commentEdited_ = false; newComment_ = null; }
public virtual IEnumerable<Parameter> GetWhereParameters (IDynamicDataSource dataSource) { throw new NotImplementedException (); }
public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) { if (archiveStorage == null) { throw new ArgumentNullException("archiveStorage"); } if (dataSource == null) { throw new ArgumentNullException("dataSource"); } if (isDisposed_) { throw new ObjectDisposedException("ZipFile"); } if (IsEmbeddedArchive) { throw new ZipException("Cannot update embedded/SFX archives"); } archiveStorage_ = archiveStorage; updateDataSource_ = dataSource; updateIndex_ = new Hashtable(); updates_ = new ArrayList(entries_.Length); foreach (ZipEntry entry in entries_) { int num = updates_.Add(new ZipUpdate(entry)); updateIndex_.Add(entry.Name, num); } updates_.Sort(new UpdateComparer()); int num2 = 0; foreach (ZipUpdate update in updates_) { if (num2 == (updates_.Count - 1)) { break; } update.OffsetBasedSize = ((ZipUpdate)updates_[num2 + 1]).Entry.Offset - update.Entry.Offset; num2++; } updateCount_ = updates_.Count; contentsEdited_ = false; commentEdited_ = false; newComment_ = null; }
public static void ExpandDynamicWhereParameters(this IDynamicDataSource dataSource) { // http://forums.asp.net/p/1396453/3005197.aspx#3005197 throw new NotImplementedException(); }
private void PostUpdateCleanup() { this.updateDataSource_ = null; this.updates_ = null; this.updateIndex_ = null; if (this.archiveStorage_ != null) { this.archiveStorage_.Dispose(); this.archiveStorage_ = null; } }
// Immediate updating // TBD: Direct form of updating // // public void Update(IEntryMatcher deleteMatcher) // { // } // // public void Update(IScanner addScanner) // { // } // Deferred Updating /// <summary> /// Begin updating this <see cref="BlubbFile"/> archive. /// </summary> /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param> /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param> /// <exception cref="ObjectDisposedException">BlubbFile has been closed.</exception> /// <exception cref="ArgumentNullException">One of the arguments provided is null</exception> /// <exception cref="ObjectDisposedException">BlubbFile has been closed.</exception> public void BeginUpdate( IArchiveStorage archiveStorage, IDynamicDataSource dataSource ) { if( archiveStorage == null ) { throw new ArgumentNullException( "archiveStorage" ); } if( dataSource == null ) { throw new ArgumentNullException( "dataSource" ); } if( isDisposed_ ) { throw new ObjectDisposedException( "BlubbFile" ); } if( IsEmbeddedArchive ) { throw new BlubbZipException( "Cannot update embedded/SFX archives" ); } archiveStorage_ = archiveStorage; updateDataSource_ = dataSource; // NOTE: the baseStream_ may not currently support writing or seeking. updateIndex_ = new Hashtable(); updates_ = new ArrayList( entries_.Length ); foreach( BlubbZipEntry entry in entries_ ) { int index = updates_.Add( new BlubbUpdate( entry ) ); updateIndex_.Add( entry.Name, index ); } updateCount_ = updates_.Count; contentsEdited_ = false; commentEdited_ = false; newComment_ = null; }
private void PostUpdateCleanup() { _updateDataSource = null; _updates = null; _updateIndex = null; if (_archiveStorage != null) { _archiveStorage.Dispose(); _archiveStorage = null; } }
public static void ExpandDynamicWhereParameters(this IDynamicDataSource dataSource) { // http://forums.asp.net/p/1396453/3005197.aspx#3005197 }