public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            IGPParameter targetDatasetParameter = paramvalues.get_Element(out_targetDatasetNumber) as IGPParameter;
            IGPValue targetDatasetGPValue = gpUtilities3.UnpackGPValue(targetDatasetParameter);

            IDEFeatureDataset targetDEFeatureDataset = targetDatasetGPValue as IDEFeatureDataset;

            IGPParameter3 outPointsFeatureClassParameter = null;
            IGPValue outPointsFeatureClass = null;
            string outpointsPath = String.Empty;

            IGPParameter3 outLinesFeatureClassParameter = null;
            IGPValue outLinesFeatureClass = null;
            string outlinesPath = String.Empty;

            IGPParameter3 outPolygonFeatureClassParameter = null;
            IGPValue outPolygonFeatureClass = null;
            string outpolygonsPath = String.Empty;

            if (((IGPValue)targetDEFeatureDataset).GetAsText().Length != 0)
            {
                IDataElement dataElement = targetDEFeatureDataset as IDataElement;
                try
                {
                    gpUtilities3.QualifyOutputDataElement(gpUtilities3.UnpackGPValue(targetDatasetParameter));
                }
                catch
                {
                    return;
                }

                string nameOfPointFeatureClass = dataElement.GetBaseName() + "_osm_pt";
                string nameOfLineFeatureClass = dataElement.GetBaseName() + "_osm_ln";
                string nameOfPolygonFeatureClass = dataElement.GetBaseName() + "_osm_ply";


                try
                {
                    outpointsPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfPointFeatureClass;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
                outPointsFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter3;
                outPointsFeatureClass = gpUtilities3.UnpackGPValue(outPointsFeatureClassParameter);

                outlinesPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfLineFeatureClass;
                outLinesFeatureClassParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter3;
                outLinesFeatureClass = gpUtilities3.UnpackGPValue(outLinesFeatureClassParameter);

                outpolygonsPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfPolygonFeatureClass;
                outPolygonFeatureClassParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter3;
                outPolygonFeatureClass = gpUtilities3.UnpackGPValue(outPolygonFeatureClassParameter);
            }


            // TE - 10/20/2014
            if (((IGPParameter)paramvalues.get_Element(in_attributeSelector)).Altered)
            {
                IGPParameter tagCollectionParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter;
                IGPMultiValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionParameter) as IGPMultiValue;

                IGPCodedValueDomain codedTagDomain = tagCollectionParameter.Domain as IGPCodedValueDomain;

                for (int attributeValueIndex = 0; attributeValueIndex < tagCollectionGPValue.Count; attributeValueIndex++)
                {
                    string valueString = tagCollectionGPValue.get_Value(attributeValueIndex).GetAsText();
                    IGPValue testFieldValue = codedTagDomain.FindValue(valueString);

                    if (testFieldValue == null)
                    {
                        codedTagDomain.AddStringCode(valueString, valueString);
                    }
                }

                string illegalCharacters = "`~@#$%^&()-+=,{}.![];";
                IFieldsEdit fieldsEdit = new FieldsClass();

                for (int valueIndex = 0; valueIndex < tagCollectionGPValue.Count; valueIndex++)
                {
                    string tagString = tagCollectionGPValue.get_Value(valueIndex).GetAsText();

                    if (tagString != "ALL")
                    {
                        // Check if the input field already exists.
                        string cleanedTagKey = OSMToolHelper.convert2AttributeFieldName(tagString, illegalCharacters);

                        IFieldEdit fieldEdit = new FieldClass();
                        fieldEdit.Name_2 = cleanedTagKey;
                        fieldEdit.AliasName_2 = tagCollectionGPValue.get_Value(valueIndex).GetAsText();
                        fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                        fieldEdit.Length_2 = 100;
                        fieldsEdit.AddField(fieldEdit);
                    }
                }
                IFields fields = fieldsEdit as IFields;

                // Get the derived output feature class schema and empty the additional fields. This ensures 
                // that you don't get dublicate entries. 
                if (outPointsFeatureClassParameter != null)
                {
                    IGPFeatureSchema polySchema = outPolygonFeatureClassParameter.Schema as IGPFeatureSchema;
                    if (polySchema != null)
                    {
                        // Add the additional field to the polygon output.
                        polySchema.AdditionalFields = fields;
                    }
                    else
                    {
                        polySchema = new GPFeatureSchemaClass();
                        polySchema.AdditionalFields = fields;
                        polySchema.GeometryType = esriGeometryType.esriGeometryPolygon;
                        polySchema.FeatureType = esriFeatureType.esriFTSimple;
                    }
                }

                if (outLinesFeatureClassParameter != null)
                {
                    IGPFeatureSchema lineSchema = outLinesFeatureClassParameter.Schema as IGPFeatureSchema;
                    if (lineSchema != null)
                    {
                        // Add the additional field to the line output.
                        lineSchema.AdditionalFields = fields;
                    }
                    else
                    {
                        lineSchema = new GPFeatureSchemaClass();
                        lineSchema.AdditionalFields = fields;
                        lineSchema.GeometryType = esriGeometryType.esriGeometryPolyline;
                        lineSchema.FeatureType = esriFeatureType.esriFTSimple;
                    }
                }


                if (outPointsFeatureClassParameter != null)
                {
                    IGPFeatureSchema pointSchema = outPointsFeatureClassParameter.Schema as IGPFeatureSchema;
                    if (pointSchema != null)
                    {
                        // Add the additional field to the point output.
                        pointSchema.AdditionalFields = fields;
                    }
                    else
                    {
                        pointSchema = new GPFeatureSchemaClass();
                        pointSchema.AdditionalFields = fields;
                        pointSchema.GeometryType = esriGeometryType.esriGeometryPoint;
                        pointSchema.FeatureType = esriFeatureType.esriFTSimple;
                    }
                }
            }

            if (outPointsFeatureClassParameter != null)
            {
                outPointsFeatureClass.SetAsText(outpointsPath);
                gpUtilities3.PackGPValue(outPointsFeatureClass, outPointsFeatureClassParameter);
            }

            if (outLinesFeatureClassParameter != null)
            {
                outLinesFeatureClass.SetAsText(outlinesPath);
                gpUtilities3.PackGPValue(outLinesFeatureClass, outLinesFeatureClassParameter);
            }

            if (outPolygonFeatureClassParameter != null)
            {
                outPolygonFeatureClass.SetAsText(outpolygonsPath);
                gpUtilities3.PackGPValue(outPolygonFeatureClass, outPolygonFeatureClassParameter);
            }

            gpUtilities3.ReleaseInternals();

            if (gpUtilities3 != null)
                ComReleaser.ReleaseCOMObject(gpUtilities3);
        }
        public void UpdateMessages(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr, ESRI.ArcGIS.Geodatabase.IGPMessages Messages)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            IGPParameter targetDatasetParameter = paramvalues.get_Element(out_targetDatasetNumber) as IGPParameter;
            try
            {
                gpUtilities3.QualifyOutputDataElement(gpUtilities3.UnpackGPValue(targetDatasetParameter));
            }
            catch
            {
                Messages.ReplaceError(out_targetDatasetNumber, -2, resourceManager.GetString("GPTools_OSMGPFileReader_targetDataset_notexist"));
            }

            // check for valid geodatabase path
            // if the user is pointing to a valid directory on disk, flag it as an error
            IGPValue targetDatasetGPValue = gpUtilities3.UnpackGPValue(targetDatasetParameter);

            if (targetDatasetGPValue.IsEmpty() == false)
            {
                if (System.IO.Directory.Exists(targetDatasetGPValue.GetAsText()))
                {
                    Messages.ReplaceError(out_targetDatasetNumber, -4, resourceManager.GetString("GPTools_OSMGPDownload_directory_is_not_target_dataset"));
                }
            }

            // check one of the output feature classes for version compatibility
            IGPParameter pointFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter;
            IDEFeatureClass pointDEFeatureClass = gpUtilities3.UnpackGPValue(pointFeatureClassParameter) as IDEFeatureClass;

            if (pointDEFeatureClass != null)
            {
                if (((IGPValue)pointDEFeatureClass).IsEmpty() == false)
                {
                    if (gpUtilities3.Exists((IGPValue)pointDEFeatureClass))
                    {
                        IFeatureClass ptfc = gpUtilities3.Open(gpUtilities3.UnpackGPValue(pointFeatureClassParameter)) as IFeatureClass;
                        IPropertySet osmExtensionPropertySet = ptfc.ExtensionProperties;

                        if (osmExtensionPropertySet == null)
                        {
                            Messages.ReplaceError(out_targetDatasetNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            Messages.ReplaceError(out_osmPointsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            Messages.ReplaceError(out_osmLinesNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            Messages.ReplaceError(out_osmPolygonsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                        }
                        else
                        {
                            try
                            {
                                int extensionVersion = Convert.ToInt32(osmExtensionPropertySet.GetProperty("VERSION"));

                                if (extensionVersion != OSMClassExtensionManager.Version)
                                {
                                    Messages.ReplaceError(out_targetDatasetNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                    Messages.ReplaceError(out_osmPointsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                    Messages.ReplaceError(out_osmLinesNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                    Messages.ReplaceError(out_osmPolygonsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), extensionVersion, OSMClassExtensionManager.Version));
                                }
                            }
                            catch
                            {
                                Messages.ReplaceError(out_targetDatasetNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                                Messages.ReplaceError(out_osmPointsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                                Messages.ReplaceError(out_osmLinesNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                                Messages.ReplaceError(out_osmPolygonsNumber, -5, string.Format(resourceManager.GetString("GPTools_IncompatibleExtensionVersion"), 1, OSMClassExtensionManager.Version));
                            }
                        }
                    }
                }
            }

            gpUtilities3.ReleaseInternals();

            if (gpUtilities3 != null)
                ComReleaser.ReleaseCOMObject(gpUtilities3);

        }