/// <summary> /// Check the Name and Alias properties of the given Raster Function Variable to see /// if they contain a field name and get the value of the corresponding field if needed. /// </summary> /// <param name="rasterFunctionVar">The Raster Function Variable to check.</param> /// <param name="pRow">The row corresponding to the function raster dataset.</param> /// <returns></returns> private object FindPropertyInRow(IRasterFunctionVariable rasterFunctionVar, IRow pRow) { string varName = ""; IStringArray varNames = new StrArray(); varName = rasterFunctionVar.Name; // If the name of the variable contains '@Field' if (varName.Contains("@Field.")) { varNames.Add(varName); // Add it to the list of names. } // Check the aliases of the variable for (int i = 0; i < rasterFunctionVar.Aliases.Count; ++i) { // Check the list of aliases for the '@Field' string varName = rasterFunctionVar.Aliases.get_Element(i); if (varName.Contains("@Field.")) { varNames.Add(varName); // and add any that are found to the list of names. } } // Use the list of names and find the value by looking up the appropriate field. for (int i = 0; i < varNames.Count; ++i) { // Get the variable name containing the field string varName = varNames.get_Element(i); // Replace the '@Field' with nothing to get just the name of the field. string fieldName = varName.Replace("@Field.", ""); IFields rowFields = pRow.Fields; // Look up the index of the field name in the row. int fieldIndex = rowFields.FindField(fieldName); // If it is a valid index and the field type is string, return the value. if (fieldIndex != -1 && ((rowFields.get_Field(fieldIndex)).Type == esriFieldType.esriFieldTypeString)) { return(pRow.get_Value(fieldIndex)); } } // If no value has been returned yet, return null. return(null); }
/// <summary> /// Check the Name and Alias properties of the given Raster Function Variable to see /// if they contain a field name and get the value of the corresponding field if needed. /// </summary> /// <param name="rasterFunctionVar">The Raster Function Variable to check.</param> /// <param name="pRow">The row corresponding to the function raster dataset.</param> /// <returns></returns> private object FindPropertyInRow(IRasterFunctionVariable rasterFunctionVar, IRow pRow) { string varName = ""; IStringArray varNames = new StrArray(); varName = rasterFunctionVar.Name; // If the name of the variable contains '@Field' if (varName.Contains("@Field.")) varNames.Add(varName); // Add it to the list of names. // Check the aliases of the variable for (int i = 0; i < rasterFunctionVar.Aliases.Count; ++i) { // Check the list of aliases for the '@Field' string varName = rasterFunctionVar.Aliases.get_Element(i); if (varName.Contains("@Field.")) varNames.Add(varName); // and add any that are found to the list of names. } // Use the list of names and find the value by looking up the appropriate field. for (int i = 0; i < varNames.Count; ++i) { // Get the variable name containing the field string varName = varNames.get_Element(i); // Replace the '@Field' with nothing to get just the name of the field. string fieldName = varName.Replace("@Field.", ""); IFields rowFields = pRow.Fields; // Look up the index of the field name in the row. int fieldIndex = rowFields.FindField(fieldName); // If it is a valid index and the field type is string, return the value. if (fieldIndex != -1 && ((rowFields.get_Field(fieldIndex)).Type == esriFieldType.esriFieldTypeString)) return pRow.get_Value(fieldIndex); } // If no value has been returned yet, return null. return null; }