/// <summary> /// Post validates the given set of values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> /// <param name="messages">The messages that are reported to the user.</param> /// <remarks> /// This method is called after returning from the internal validation routine performed by the geoprocessing /// framework. This method is where you can examine the messages created from internal validation and change them if /// desired. /// You should only change existing messages here and should not add any new messages. /// </remarks> public void UpdateMessages(IArray parameters, IGPEnvironmentManager environmentManager, IGPMessages messages) { try { var list = parameters.AsEnumerable <IGPParameter>().ToDictionary(o => o.Name, o => o); this.UpdateMessages(list, environmentManager, messages, this.Utilities); } catch (Exception ex) { messages.AddError(-1, ex.StackTrace); } }
/// <summary> /// Executes the geoprocessing function using the given array of parameter values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="trackCancel">The track cancel.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> /// <param name="messages">The messages.</param> /// <exception cref="System.ArgumentOutOfRangeException"> /// parameters;A function tool must always have an output. At the minimum, /// your function should output a Boolean value containing success or failure. /// </exception> public virtual void Execute(IArray parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages) { try { if (parameters.AsEnumerable <IGPParameter>().All(o => o.Direction != esriGPParameterDirection.esriGPParameterDirectionOutput)) { throw new ArgumentOutOfRangeException(nameof(parameters), @"A function tool must always have an output. At the minimum, your function should output a Boolean value containing success or failure."); } var list = this.Unpack(parameters); this.Execute(list, trackCancel, environmentManager, messages, this.Utilities); } catch (Exception ex) { messages.AddError(-1, ex.StackTrace); } }
/// <summary> /// Unpacks the specified parameters. /// </summary> /// <param name="parameters">The parameters.</param> /// <returns>Returns a <see cref="Dictionary{TKey,TValue}" /> representing the unpacked parameters.</returns> protected Dictionary <string, IGPValue> Unpack(IArray parameters) { return(parameters.AsEnumerable <IGPParameter>().ToDictionary(o => o.Name, o => this.Utilities.UnpackGPValue(o))); }
/// <summary> /// Pre validates the given set of values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> public void UpdateParameters(IArray parameters, IGPEnvironmentManager environmentManager) { var list = parameters.AsEnumerable <IGPParameter>().ToDictionary(o => o.Name, o => o); this.UpdateParameters(list, environmentManager, this.Utilities); }