public void BinarySearchTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); Assert.AreEqual(2, sa.BinarySearch("C")); }
public void DeleteAllTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); sa.DeleteAll(); Assert.AreEqual(0, sa.Count()); }
public void InsertTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); sa.Insert(0, "XX"); Assert.AreEqual(4, sa.Count()); Assert.AreEqual("XX", sa[0]); }
public void CopyTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); var sa1 = new StrArray(); sa1.Copy(sa); Assert.AreEqual(3, sa1.Count()); Assert.AreEqual("C", sa1[2]); }
public void CountTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); Assert.AreEqual(3, sa.Count()); }
/// <summary> /// Serialize the argument object into the stream provided. /// </summary> /// <param name="data">Xml stream to serialize the argument object into</param> public void Serialize(IXMLSerializeData data) { #region Prepare PropertySet object names = null, values = null; myProperties.GetAllProperties(out names, out values); IStringArray myNames = new StrArray(); string[] nameArray = (string[])names; IVariantArray myValues = new VarArray(); object[] valArray = (object[])values; for (int i = 0; i < nameArray.GetLength(0); ++i) { myNames.Add(nameArray[i]); if (valArray[i] is IDataset) { IName myDatasetName = ((IDataset)valArray[i]).FullName; myValues.Add(myDatasetName); } else { myValues.Add(valArray[i]); } } #endregion data.TypeName = "WatermarkFunctionArguments"; data.TypeNamespaceURI = @"http://www.esri.com/schemas/ArcGIS/10.2"; data.AddObject("Names", myNames); data.AddObject("Values", myValues); }
/// <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); }
public override void OnClick() { IHookActions hookActions = null; IBasicMap basicMap = null; //Get basic map and set hook actions if (m_hookHelper != null) { basicMap = m_hookHelper.FocusMap as IBasicMap; hookActions = m_hookHelper as IHookActions; } else if (m_globeHookHelper != null) { basicMap = m_globeHookHelper.Globe as IBasicMap; hookActions = m_globeHookHelper as IHookActions; } //Get feature selection ISelection selection = basicMap.FeatureSelection; //Get enumerator IEnumFeature enumFeature = selection as IEnumFeature; enumFeature.Reset(); //Set first feature IFeature feature; feature = enumFeature.Next(); //Loop though the features IArray array = new ESRI.ArcGIS.esriSystem.Array(); IStringArray sArray = new StrArray(); while (feature != null) { //Add feature to array array.Add(feature.Shape); //Add the value of the first field to the string array sArray.Add(feature.get_Value(0).ToString()); //Set next feature feature = enumFeature.Next(); } //If the action is supported perform the action if (hookActions.get_ActionSupportedOnMultiple(array, esriHookActions.esriHookActionsLabel)) { hookActions.DoActionWithNameOnMultiple(array, sArray, esriHookActions.esriHookActionsLabel); } }
public void ToStringCollectionTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); Collection<string> aC = sa.ToStringCollection(); Assert.AreEqual(3, aC.Count); Assert.AreEqual("A", aC[0]); }
public void ReplaceTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); const string expected = "XX"; sa.Replace(2, expected); Assert.AreEqual(expected, sa[2]); }
public void WriteCdataXmlTest1() { var sa = new StrArray(); sa.Add("A"); sa.Add("B&"); sa.Add("C"); const string expected = "<test><![CDATA[A]]></test><test><![CDATA[B&]]></test><test><![CDATA[C]]></test>"; Assert.AreEqual(expected, sa.WriteCdataXml("test", false, false, true)); }
public override void OnClick() { IHookActions hookActions = null; IBasicMap basicMap = null; //Get basic map and set hook actions if (m_hookHelper != null) { basicMap = m_hookHelper.FocusMap as IBasicMap; hookActions = m_hookHelper as IHookActions; } else if (m_globeHookHelper != null) { basicMap = m_globeHookHelper.Globe as IBasicMap; hookActions = m_globeHookHelper as IHookActions; } //Get feature selection ISelection selection = basicMap.FeatureSelection; //Get enumerator IEnumFeature enumFeature = selection as IEnumFeature; enumFeature.Reset(); //Set first feature IFeature feature; feature = enumFeature.Next(); //Loop though the features IArray array = new ESRI.ArcGIS.esriSystem.Array(); IStringArray sArray = new StrArray(); while (feature != null) { //Add feature to array array.Add(feature.Shape); //Add the value of the first field to the string array sArray.Add(feature.get_Value(0).ToString()); //Set next feature feature = enumFeature.Next(); } //If the action is supported perform the action if (hookActions.get_ActionSupportedOnMultiple(array, esriHookActions.esriHookActionsLabel)) hookActions.DoActionWithNameOnMultiple(array, sArray, esriHookActions.esriHookActionsLabel); }
/// <summary> /// Serialize the argument object into the stream provided. /// </summary> /// <param name="data">Xml stream to serialize the argument object into</param> public void Serialize(IXMLSerializeData data) { #region Prepare PropertySet object names = null, values = null; myProperties.GetAllProperties(out names, out values); IStringArray myNames = new StrArray(); string[] nameArray = (string[])names; IVariantArray myValues = new VarArray(); object[] valArray = (object[])values; for (int i = 0; i < nameArray.GetLength(0); ++i) { myNames.Add(nameArray[i]); if (valArray[i] is IDataset) { IName myDatasetName = ((IDataset)valArray[i]).FullName; myValues.Add(myDatasetName); } else myValues.Add(valArray[i]); } #endregion data.TypeName = "NDVICustomFunctionArguments"; data.TypeNamespaceURI = @"http://www.esri.com/schemas/ArcGIS/10.2"; data.AddObject("Names", myNames); data.AddObject("Values", myValues); }
/// <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; }
public void WriteStringTest() { char cr = Convert.ToChar(13); char lf = Convert.ToChar(10); string crlf = Convert.ToString(cr); crlf += lf; var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); string expected = "A" + crlf + "B" + crlf + "C" + crlf; Assert.AreEqual(expected, sa.WriteString()); }
public void WriteXmlTest() { var sa = new StrArray(); sa.Add("A"); sa.Add("B"); sa.Add("C"); const string expected = "<test>A</test><test>B</test><test>C</test>"; Assert.AreEqual(expected, sa.WriteXml("test", false, false)); }
public void SortTest() { var sa = new StrArray(); sa.Add("C"); sa.Add("B"); sa.Add("A"); sa.Sort(); Assert.AreEqual(3, sa.Count()); Assert.AreEqual("A", sa[0]); Assert.AreEqual("C", sa[2]); }