Ejemplo n.º 1
0
        /// <summary>
        ///     Returns a dictionary of the fields and model names that are assigned to the field for the specified
        ///     <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class.</param>
        /// <returns>
        ///     Returns a <see cref="Dictionary{Key, Value}" /> representing the model names assigned to the field.
        /// </returns>
        /// <exception cref="ArgumentNullException">field</exception>
        public static Dictionary <IField, List <string> > GetFieldModelNames(this ITable source)
        {
            if (source == null)
            {
                return(null);
            }
            IObjectClass table = source as IObjectClass;

            if (table == null)
            {
                return(null);
            }

            return(table.GetFieldModelNames());
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Returns a dictionary of the fields and model names that are assigned to the field for the specified
        ///     <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class.</param>
        /// <returns>
        ///     Returns a <see cref="Dictionary{Key, Value}" /> representing the model names assigned to the field.
        /// </returns>
        /// <exception cref="ArgumentNullException">field</exception>
        public static Dictionary <IField, List <string> > GetFieldModelNames(this IObjectClass source)
        {
            if (source == null)
            {
                return(null);
            }

            Dictionary <IField, List <string> > list = new Dictionary <IField, List <string> >();

            foreach (var field in source.Fields.AsEnumerable())
            {
                var modelNames = source.GetFieldModelNames(field).ToList();
                if (modelNames.Any())
                {
                    list.Add(field, modelNames);
                }
            }

            return(list);
        }
Ejemplo n.º 3
0
        /// <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>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities)
        {
            // Retrieve the input parameter value.
            IGPValue table = utilities.UnpackGPValue(parameters["in_table"]);

            if (!table.IsEmpty())
            {
                // Create the domain based on the fields on the table.
                IObjectClass oclass = utilities.OpenTable(table);
                if (oclass != null)
                {
                    IFields fields = oclass.Fields;
                    if (fields != null)
                    {
                        IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();
                        foreach (var o in fields.AsEnumerable())
                        {
                            codedValueDomain.AddStringCode(o.Name, o.Name);
                        }

                        IGPParameterEdit3 derivedFields = (IGPParameterEdit3)parameters["in_field"];
                        derivedFields.Domain = (IGPDomain)codedValueDomain;
                    }

                    IGPValue field = utilities.UnpackGPValue(parameters["in_field"]);
                    if (!field.IsEmpty())
                    {
                        int index = oclass.FindField(field.GetAsText());

                        IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass();
                        foreach (var o in oclass.GetFieldModelNames(oclass.Fields.Field[index]))
                        {
                            codedValueDomain.AddStringCode(o, o);
                        }

                        IGPParameterEdit3 derivedParameter = (IGPParameterEdit3)parameters["in_field_model_names"];
                        derivedParameter.Domain = (IGPDomain)codedValueDomain;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Returns a list of the model names that are assigned to the <paramref name="field" /> for the specified
 ///     <paramref name="source" />.
 /// </summary>
 /// <param name="source">The object class.</param>
 /// <param name="field">The field.</param>
 /// <returns>
 ///     Returns a <see cref="IEnumerable{T}" /> representing the model names assigned to the field.
 /// </returns>
 /// <exception cref="ArgumentNullException">field</exception>
 public static IEnumerable <string> GetFieldModelNamesAsync(this IObjectClass source, IField field)
 {
     return(Task.Wait(() => source.GetFieldModelNames(field)));
 }
Ejemplo n.º 5
0
 /// <summary>
 ///     Returns a dictionary of the fields and model names that are assigned to the field for the specified
 ///     <paramref name="source" />.
 /// </summary>
 /// <param name="source">The object class.</param>
 /// <returns>
 ///     Returns a <see cref="Dictionary{Key, Value}" /> representing the model names assigned to the field.
 /// </returns>
 /// <exception cref="ArgumentNullException">field</exception>
 public static Dictionary <IField, List <string> > GetFieldModelNamesAsync(this IObjectClass source)
 {
     return(Task.Wait(() => source.GetFieldModelNames()));
 }