Пример #1
1
 public void BinarySearchTest()
 {
     var sa = new StrArray();
     sa.Add("A");
     sa.Add("B");
     sa.Add("C");
     Assert.AreEqual(2, sa.BinarySearch("C"));
 }
Пример #2
1
 public void DeleteAllTest()
 {
     var sa = new StrArray();
     sa.Add("A");
     sa.Add("B");
     sa.Add("C");
     sa.DeleteAll();
     Assert.AreEqual(0, sa.Count());
 }
Пример #3
1
 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]);
 }
Пример #4
1
 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]);
 }
 /// <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);
 }
Пример #6
0
 public void CountTest()
 {
     var sa = new StrArray();
     sa.Add("A");
     sa.Add("B");
     sa.Add("C");
     Assert.AreEqual(3, sa.Count());
 }
Пример #7
0
        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>
        /// 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);
        }
Пример #9
0
 public void ParseDelimetedStringTestChar()
 {
     var target = new StrArray();
     const string cData = "test1|test2";
     const char cDelim = '|';
     target.ParseDelimitedString(cData, cDelim);
     Assert.AreEqual(2, target.Count());
     Assert.AreEqual("test1", target[0]);
 }
Пример #10
0
 public void ParseQuoteCommaStringTest()
 {
     var target = new StrArray();
     const string cData = "test1,test2";
     target.ParseQuoteCommaString(cData);
     Assert.AreEqual(2, target.Count());
     Assert.AreEqual("test1", target[0]);
 }
        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>
        /// 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>
 /// 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);
 }
Пример #14
0
 public void ParseXmlTest1()
 {
     const string cXml = "<wrapper><test><![CDATA[A]]></test><test><![CDATA[B]]></test><test><![CDATA[C&amp;]]></test></wrapper>";
     var sa = new StrArray();
     sa.ParseXml("<test>", cXml, true);
     Assert.AreEqual(3, sa.Count());
     Assert.AreEqual("C&", sa[2]);
 }
Пример #15
0
 public void LoadFromFileTest()
 {
     const string cFileName = @"c:\test\StrArrayTest.txt";
     var satemp = new Collection<string> {"A", "B", "C"};
     FileTools.SSaveArrayToFile(cFileName, satemp);
     var sa = new StrArray();
     sa.LoadFromFile(cFileName);
     Assert.AreEqual(3, sa.Count());
     Assert.AreEqual("A", sa[0]);
     Assert.AreEqual("C", sa[2]);
 }
Пример #16
0
 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]);
 }
Пример #17
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]);
 }
Пример #18
0
 public void ParseDelimetedStringTestString()
 {
     var target = new StrArray();
     const string cDelim = "<delim>";
     const string cData = "Data1" + cDelim + "Data2" + cDelim + "Data3";
     target.ParseDelimitedString(cData, cDelim , true);
     Assert.AreEqual(3, target.Count());
 }
Пример #19
0
 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]);
 }
Пример #20
0
 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));
 }
Пример #21
0
 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());
 }
Пример #22
0
 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&amp;]]></test><test><![CDATA[C]]></test>";
     Assert.AreEqual(expected, sa.WriteCdataXml("test", false, false, true));
 }