コード例 #1
0
        /// <summary>
        /// Dump the contents of an array into a string builder
        /// </summary>
        static void RenderArray(Array array, StringBuilder buffer)
        {
            if (array == null)
                buffer.Append(SystemInfo.NullText);
            else
            {
                if (array.Rank != 1)
                    buffer.Append(array.ToString());
                else
                {
                    buffer.Append("{");
                    var len = array.Length;

                    if (len > 0)
                    {
                        RenderObject(array.GetValue(0), buffer);
                        for (var i = 1; i < len; i++)
                        {
                            buffer.Append(", ");
                            RenderObject(array.GetValue(i), buffer);
                        }
                    }
                    buffer.Append("}");
                }
            }
        }
コード例 #2
0
        private void speakAll()
        {
            synthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
            CultureInfo culture = new CultureInfo("en-US");

            synthesizer.SelectVoiceByHints(System.Speech.Synthesis.VoiceGender.Female, System.Speech.Synthesis.VoiceAge.Teen, 1, culture);

            List <string> lis = new List <string>(174);

            foreach (var it in colorsArray)
            {
                lis.Add(colorsArray.ToString());
            }
            // System.Threading.Thread.Sleep(20000);
            Random random = new Random();
            int    item   = 0;
            int    count  = lis.Count;

            for (int i = 0; i <= count; i++)
            {
                item = random.Next(0, lis.Count);
                synthesizer.Speak(lis[item]);
                lis.Remove(lis[item]);
            }
        }
コード例 #3
0
        public List <Object> ObtenerContenido()
        {
            Trace.TraceInformation("Ingresa a metodo ObtenerContenido");
            List <Object> lista = new List <Object>();

            lista.Clear();
            for (int i = 2; i < lastRow; i++)
            {
                System.Array MyValues = (System.Array)MySheet.get_Range("A" + i.ToString(), "H" + i.ToString()).Cells.Value;
                Trace.TraceInformation(MyValues.ToString());
                lista.Add(MyValues);
            }
            Trace.TraceInformation("finaliza a metodo ObtenerContenido");
            return(lista);
        }
コード例 #4
0
		/// <summary>
		/// Render the array argument into a string
		/// </summary>
		/// <param name="rendererMap">The map used to lookup renderers</param>
		/// <param name="array">the array to render</param>
		/// <param name="writer">The writer to render to</param>
		/// <remarks>
		/// <para>
		/// For a one dimensional array this is the
		///	array type name, an open brace, followed by a comma
		///	separated list of the elements (using the appropriate
		///	renderer), followed by a close brace. For example:
		///	<c>int[] {1, 2, 3}</c>.
		///	</para>
		///	<para>
		///	If the array is not one dimensional the 
		///	<c>Array.ToString()</c> is returned.
		///	</para>
		/// </remarks>
		private void RenderArray(RendererMap rendererMap, Array array, TextWriter writer)
		{
			if (array.Rank != 1)
			{
				writer.Write(array.ToString());
			}
			else
			{
				writer.Write(array.GetType().Name + " {");
				int len = array.Length;

				if (len > 0)
				{
					rendererMap.FindAndRender(array.GetValue(0), writer);
					for(int i=1; i<len; i++)
					{
						writer.Write(", ");
						rendererMap.FindAndRender(array.GetValue(i), writer);
					}
				}
				writer.Write("}");
			}
		}
コード例 #5
0
		private void CompareUnSorted(Array a, Array b)
		{
			string msg = string.Format("Failed while comparing(Array a ={0} ({1}), Array b = {2} ({3}))]", a.ToString(), a.GetType().FullName, b.ToString(), b.GetType().FullName);
			foreach (object item in a) {
				if (Array.IndexOf(b, item) < 0) //b does not contain the current item.
					Assert.Fail(msg);
			}

			foreach (object item in b) {
				if (Array.IndexOf(a, item) < 0) //a does not contain the current item.
					Assert.Fail(msg);
			}
		}
コード例 #6
0
		/// <summary>
		/// Render the array argument into a string
		/// </summary>
		/// <param name="rendererMap">The map used to lookup renderers</param>
		/// <param name="array">the array to render</param>
		/// <returns>the string representation of the array</returns>
		/// <remarks>
		/// <para>For a one dimensional array this is the
		///	array type name, an open brace, followed by a comma
		///	separated list of the elements (using the appropriate
		///	renderer), followed by a close brace. For example:
		///	<c>int[] {1, 2, 3}</c>.</para>
		///	<para>If the array is not one dimensional the 
		///	<c>Array.ToString()</c> is returned.</para>
		/// </remarks>
		virtual protected string RenderArray(RendererMap rendererMap, Array array)
		{
			if (array.Rank != 1)
			{
				return array.ToString();
			}
			else
			{
				StringBuilder buffer = new StringBuilder(array.GetType().Name + " {");
				int len = array.Length;

				if (len > 0)
				{
					buffer.Append(rendererMap.FindAndRender(array.GetValue(0)));
					for(int i=1; i<len; i++)
					{
						buffer.Append(", ").Append(rendererMap.FindAndRender(array.GetValue(i)));
					}
				}
				return buffer.Append("}").ToString();
			}
		}
コード例 #7
0
        /// <summary>
        /// Dump the contents of an array into a string builder
        /// </summary>
        private static void RenderArray(Array array, StringBuilder buffer)
        {
            if (array == null)
            {
                buffer.Append(nullText);
            }
            else
            {
                if (array.Rank != 1)
                {
                    buffer.Append(array.ToString());
                }
                else
                {
                    buffer.Append("{");
                    int len = array.Length;

                    if (len > 0)
                    {
                        RenderObject(array.GetValue(0), buffer);
                        for (int i = 1; i < len; i++)
                        {
                            buffer.Append(", ");
                            RenderObject(array.GetValue(i), buffer);
                        }
                    }
                    buffer.Append("}");
                }
            }
        }
コード例 #8
0
ファイル: GHTBase.cs プロジェクト: nlhepler/mono
		/// <summary>Compare two Object Arrays. 
		/// <param name="a">First array.</param>
		/// <param name="b">Second array.</param>
		/// <param name="Sorted">Used to indicate if both arrays are sorted.</param>
		/// </summary>
		protected bool Compare(Array a, Array b)
		{
			Assert.AreEqual(b, a);
			//signal that the Compare method has been called
			this._testCase.CompareInvoked=true;
			//a string that holds the description of the objects for log
			string ObjectData;

			//check if both objects are null
			if ( (a == null && b == null) )
			{
				ObjectData = "Array a = null, Array b = null";
				this._testCase.Success = true; //both objects are null, TestCase Succeed
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			//Check if one of the objects is null.
			//(If both were null, we wouldn't have reached here).
			if (a == null || b == null)
			{
				string aData = (a==null) ? "null" : "'" + a.ToString() + "' (" + a.GetType().FullName + ")";
				string bData = (b==null) ? "null" : "'" +b.ToString() + "' (" + b.GetType().FullName + ")";
				ObjectData = "Array a = "  + aData + ", Array b = " + bData;
				this._testCase.Success = false; //objects are different, testCase Failed.
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			//check if both arrays are of the same rank.
			if (a.Rank != b.Rank)
			{
				this._testCase.Success = false;
				ObjectData = string.Format("Array a.Rank = {0}, Array b.Rank = {1}", a.Rank, b.Rank);
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			//Do not handle multi dimentional arrays.
			if (a.Rank != 1)
			{
				this._testCase.Success = false;
				ObjectData = "Multi-dimension array comparison is not supported";
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			//Check if both arrays are of the same length.
			if (a.Length != b.Length)
			{
				this._testCase.Success = false;
				ObjectData = string.Format("Array a.Length = {0}, Array b.Length = {1}", a.Length, b.Length);
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			ObjectData = "Array a.ToString() = '" + a.ToString() + "'(" + a.GetType().FullName + ") Array b.ToString = '" + b.ToString() + "'(" + b.GetType().FullName + ")";

			//Compare elements of the Array.
			int iLength = a.Length;
			for (int i=0; i<iLength; i++)
			{
				object aValue = a.GetValue(i);
				object bValue = b.GetValue(i);

				if (aValue == null && bValue == null)
				{
					continue;
				}

				if (aValue == null || bValue == null  ||  !aValue.Equals(bValue) )
				{
					string aData = (aValue==null) ? "null" : "'" + aValue.ToString() + "' (" + aValue.GetType().FullName + ")";
					string bData = (bValue==null) ? "null" : "'" + bValue.ToString() + "' (" + bValue.GetType().FullName + ")";
					ObjectData = string.Format("Array a[{0}] = {1}, Array b[{0}] = {2}", i, aData, bData);
					this._testCase.Success = false; //objects are different, testCase Failed.
					LogCompareResult(ObjectData);
					return this._testCase.Success;
				}
			}


			this._testCase.Success = true;
			LogCompareResult(ObjectData);
			return this._testCase.Success;
		}
コード例 #9
0
ファイル: DataTable_Select_S.cs プロジェクト: nlhepler/mono
		private void CompareUnSorted(Array a, Array b)
		{
			string msg = string.Format("Failed while comparing(Array a ={0} ({1}), Array b = {2} ({3}))]", a.ToString(), a.GetType().FullName, b.ToString(), b.GetType().FullName);
			foreach (object item in a)
			{
				if (Array.IndexOf(b, item) < 0)	//b does not contain the current item.
				{
					this.Fail(msg);
					return;
				}
			}

			foreach (object item in b)
			{
				if (Array.IndexOf(a, item) < 0)	//a does not contain the current item.
				{
					this.Fail(msg);
					return;
				}
			}
			
			//b contains all items of a, and a contains all items of b.
			this.Pass(msg);
		}
コード例 #10
0
ファイル: InvokeArgument.cs プロジェクト: Feinbube/hybridNet
 public override string ToString()
 {
     return(m_Value.ToString());
 }