Exemplo n.º 1
0
        public static void AreEqual(System.Collections.ICollection expected, System.Collections.ICollection actual)
        {
            if (expected == null && actual == null)
            {
                return;
            }

            if (expected == null || actual == null)
            {
                Assert.IsTrue(false, expected == null ? "expected" : "actual" + " is null");
            }

            Assert.AreEqual(expected.Count, actual.Count, "Count not equal");

            var ie = expected.GetEnumerator();
            var ia = actual.GetEnumerator();
            while (true)
            {
                bool b1 = ie.MoveNext();
                bool b2 = ia.MoveNext();
                Assert.AreEqual(b1, b2);

                if (!b1) break;
                Assert.AreEqual(ie.Current, ia.Current);
            }
        }
Exemplo n.º 2
0
        //
        // Compare two collections for equality (as implemented by the Equals() method of its elements).
        // Order is significant.
        //
        public static bool Equals(System.Collections.ICollection c1, System.Collections.ICollection c2)
        {
            try
            {
                bool result;
                if(cheapComparison(c1, c2, out result))
                {
                    return result;
                }

                System.Collections.IEnumerator e = c2.GetEnumerator();
                foreach(object o in c1)
                {
                    e.MoveNext();
                    if(!Equals(o, e.Current))
                    {
                        return false;
                    }
                }
                return true;
            }
            catch(System.Exception)
            {
                return false;
            }
        }
        public void ShouldUseQueryExecuterToReadInformationFromTheChangelogTable() 
        {
            var readResults = new[] { true, true, true, false };
            var readEnumerator = readResults.GetEnumerator();

            this.expectedResultSet.Setup(rs => rs.Read()).Returns(() =>
            {
                readEnumerator.MoveNext();
                return (bool)readEnumerator.Current;
            });
        
            var getResults = new[] { 5, 9, 12 };
            var getEnumerator = getResults.GetEnumerator();
        
            this.expectedResultSet.Setup(rs => rs.GetValue(0)).Returns(() =>
            {
                getEnumerator.MoveNext();
                return (int)getEnumerator.Current;
            });

            List<int> numbers = this.schemaVersionManager.GetAppliedChanges().ToList();
        
            Assert.Contains(5, numbers);
            Assert.Contains(9, numbers);
            Assert.Contains(12, numbers);
        }
 /// <summary>
 /// Sql parameter array with encrypt values
 /// </summary>
 /// <param name="fields">The fields list which needs the encryption</param>
 /// <param name="ht">Collection of all parameters</param>
 /// <returns>sql parameter array</returns>
 internal SqlParameter[] GetSqlParamterArray(List<string> fields, System.Collections.Hashtable ht)
 {
     var sqlParams = new List<SqlParameter>();
     try
     {
         var en = ht.GetEnumerator();
         while (en.MoveNext())
         {
             string paramtername = en.Key.ToString();
             string paramtervalue = string.Empty;
             var x = new List<string>(fields);
             if (x.Contains(paramtername))
             {
                 paramtervalue = EncryptData(en.Value.ToString(), GetEncryptType());
             }
             else
             {
                 if (en.Value != null)
                     paramtervalue = en.Value.ToString();
                 else
                     paramtervalue = "";
             }
             var oParam = new SqlParameter(paramtername, paramtervalue);
             sqlParams.Add(oParam);
         }
     }
     catch (Exception ex)
     {
         string y = ex.ToString();
     }
     return sqlParams.ToArray();
 }
Exemplo n.º 5
0
        public static SyntaxTree GetTree(System.Collections.ArrayList Tokens)
        {
            TokenEnm = Tokens.GetEnumerator();

            GetToken();

            return StatementBlock();
        }
        private static void HandleArgs (System.Collections.ObjectModel.ReadOnlyCollection<string> args)
        {
        	for (var position = args.GetEnumerator(); position.MoveNext();)
            {
        		string arg = position.Current;
				downloadImmediately = arg.Contains("start", StringComparison.OrdinalIgnoreCase);
            }
        }
Exemplo n.º 7
0
		/// <summary>Create set from a Collection of char[] or String </summary>
		public CharArraySet(System.Collections.ICollection c, bool ignoreCase):this(c.Count, ignoreCase)
		{
			System.Collections.IEnumerator e = c.GetEnumerator();
			while (e.MoveNext())
			{
				Add(e.Current);
			}
		}
        public static RadicalCoroutine StartRadicalCoroutine(this MonoBehaviour behaviour, System.Collections.IEnumerable routine, RadicalCoroutineDisableMode disableMode = RadicalCoroutineDisableMode.Default)
        {
            if (behaviour == null) throw new System.ArgumentNullException("behaviour");
            if (routine == null) throw new System.ArgumentNullException("routine");

            var co = new RadicalCoroutine(routine.GetEnumerator());
            co.Start(behaviour, disableMode);
            return co;
        }
Exemplo n.º 9
0
		/// <param name="names">The names of the fields
		/// </param>
		/// <param name="storeTermVectors">Whether the fields store term vectors or not
		/// </param>
		public void  AddIndexed(System.Collections.ICollection names, bool storeTermVectors)
		{
			System.Collections.IEnumerator i = names.GetEnumerator();
			int j = 0;
			while (i.MoveNext())
			{
                System.Collections.DictionaryEntry t = (System.Collections.DictionaryEntry) i.Current;
				Add((System.String) t.Key, true, storeTermVectors);
			}
		}
Exemplo n.º 10
0
 public static void AddAll(System.Collections.Hashtable hashtable, System.Collections.ICollection items)
 {
     System.Collections.IEnumerator iter = items.GetEnumerator();
     System.Object item;
     while (iter.MoveNext())
     {
         item = iter.Current;
         hashtable.Add(item, item);
     }
 }
Exemplo n.º 11
0
 public System.Collections.Generic.IEnumerable<char> Transcribe(System.Collections.Generic.IEnumerable<char> input)
 {
     LetterCategory lastCategory = LetterCategory.Whitespace;
     System.Collections.Generic.IEnumerator<char> enumerator = input.GetEnumerator();
     bool evenInsertVowel = false;
     if (!enumerator.MoveNext())
         yield break;
     bool done = false;
     while (!done)
     {
         char current = enumerator.Current;
         if (!enumerator.MoveNext())
             done = true;
         else if (current == enumerator.Current)
             done = !enumerator.MoveNext();
         else if (current == 'c' && enumerator.Current == 'k')
         {
             done = !enumerator.MoveNext();
             current = 'k';
         }
         else if (current == 'c' && enumerator.Current == 'h')
         {
             done = !enumerator.MoveNext();
             current = lastCategory == LetterCategory.Vowel ? 'k' : 's';
         }
         current = this.Map(current);
         LetterCategory category = this.Categorize(current);
         switch (category)
         {
             case LetterCategory.Other:
                 break;
             case LetterCategory.Vowel:
                 if (lastCategory != LetterCategory.Consonant)
                     yield return 'h';
                 yield return current;
                 break;
             case LetterCategory.Consonant:
                 if (lastCategory == LetterCategory.Consonant)
                     yield return (evenInsertVowel = !evenInsertVowel) ? 'u' : 'i';
                 yield return current;
                 break;
             case LetterCategory.Whitespace:
                 if (lastCategory == LetterCategory.Consonant)
                     yield return !evenInsertVowel ? 'u' : 'i';
                 evenInsertVowel = false;
                 if (lastCategory != LetterCategory.Whitespace)
                     yield return ' ';
                 break;
         }
         if (category != LetterCategory.Other)
             lastCategory = category;
     }
     if (lastCategory == LetterCategory.Consonant)
         yield return (evenInsertVowel = !evenInsertVowel) ? 'u' : 'i';
 }
Exemplo n.º 12
0
		public static void Display(string title, System.Collections.ICollection list)
		{
			System.Console.Out.WriteLine("***" + title);
			System.Collections.IEnumerator iterator = list.GetEnumerator();
			int i = 1;
			while (iterator.MoveNext())
			{
				System.Console.Out.WriteLine(i + "=" + iterator.Current);
				i++;
			}
		}
Exemplo n.º 13
0
 public async Task SelectMany_Should_Be_Lazy()
 {
     var counter = new int[1];
     var enumerable =
         new[] { 1, 2, 3 }
             .SelectManyAsync(i => Task.FromResult<IEnumerable<int>>(
                 new[] { ++counter[0], ++counter[0] }));
     var enumeratorAsync = enumerable.GetEnumerator();
     counter[0].Should().Be(0);
     await enumeratorAsync.MoveNext();
     counter[0].Should().Be(2);
 }
 public void SetTravelBugs(System.Collections.Generic.List<TravelBug> bugs)
 {
     tbStore.Clear ();
     IEnumerator<TravelBug> itr = bugs.GetEnumerator ();
     while (itr.MoveNext ()) {
         tbStore.AppendValues (itr.Current);
     }
     if (bugs.Count == 0)
         tbugExpander.Sensitive = false;
     else
         tbugExpander.Sensitive = true;
 }
Exemplo n.º 15
0
			internal TermPositionsQueue(System.Collections.IList termPositions)
			{
				Initialize(termPositions.Count);
				
				System.Collections.IEnumerator i = termPositions.GetEnumerator();
				while (i.MoveNext())
				{
					TermPositions tp = (TermPositions) i.Current;
					if (tp.Next())
						Put(tp);
				}
			}
Exemplo n.º 16
0
		/// <seealso cref="Graph.addAllEdges(Collection)">
		/// </seealso>
		public virtual bool addAllEdges(System.Collections.ICollection edges)
		{
			bool modified = false;
			
			//UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
			for (System.Collections.IEnumerator iter = edges.GetEnumerator(); iter.MoveNext(); )
			{
				//UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
				modified |= addEdge((Edge) iter.Current);
			}
			
			return modified;
		}
Exemplo n.º 17
0
 public static string CollectionToString(System.Collections.ICollection set_Renamed, string sep)
 {
     var buffer = new System.Text.StringBuilder();
     System.Collections.IEnumerator iter = set_Renamed.GetEnumerator();
     buffer.Append("{");
     while (iter.MoveNext())
     {
         buffer.Append(iter.Current).Append(sep);
     }
     buffer.Remove(buffer.Length - sep.Length, 1);
     buffer.Append("}");
     return buffer.ToString();
 }
Exemplo n.º 18
0
        public static void EnumeratorExample()
        {
            Console.WriteLine("--- Enumeration iteration example start ---");

            var stocks = new[] { "MSFT", "GOOG", "AAPL" };
            IEnumerator enumerator = stocks.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }

            Console.WriteLine("--- Enumeration iteration example end ---");
        }
Exemplo n.º 19
0
 public static System.Collections.Generic.List<ServiceStack.Translators.Generator.Tests.Support.DataContract.Address> ToAddresss(System.Collections.Generic.IEnumerable<ServiceStack.Translators.Generator.Tests.Support.Model.Address> from)
 {
     if ((from == null))
     {
         return null;
     }
     System.Collections.Generic.List<ServiceStack.Translators.Generator.Tests.Support.DataContract.Address> to = new System.Collections.Generic.List<ServiceStack.Translators.Generator.Tests.Support.DataContract.Address>();
     for (System.Collections.Generic.IEnumerator<ServiceStack.Translators.Generator.Tests.Support.Model.Address> iter = from.GetEnumerator(); iter.MoveNext();
     )
     {
         ServiceStack.Translators.Generator.Tests.Support.Model.Address item = iter.Current;
         to.Add(ServiceStack.Translators.Generator.Tests.Support.DataContract.Address.ToAddress(item));
     }
     return to;
 }
Exemplo n.º 20
0
 private static System.Drawing.Bitmap getImageFromResource(System.Resources.ResourceReader resourceReader, string bitmapName)
 {
     System.Collections.IDictionaryEnumerator dictEnum = resourceReader.GetEnumerator();
     System.Drawing.Bitmap bitmap = null;
     while (dictEnum.MoveNext())
     {
         if (String.Equals(dictEnum.Key, bitmapName))
         {
             bitmap = dictEnum.Value as System.Drawing.Bitmap;
             System.Drawing.Color pixel = bitmap.GetPixel(bitmap.Width - 1, 0);
             bitmap.MakeTransparent(pixel);
             break;
         }
     }
     return bitmap;
 }
Exemplo n.º 21
0
        public void should_always_call_move_next_before_using_dereferenced_value()
        {
            var collection = new[] {1, 2, 3};

            IEnumerator enumerator = collection.GetEnumerator();
            Action getCurrentValueWithoutMoveNext = () =>
            {
                object value = enumerator.Current;
            };

            Exception error = getCurrentValueWithoutMoveNext.RunAndGetUnhandledException();

            // change the variable value to fix the test.
            Type expectedExceptionType = typeof(Exception);

            Assert.Equal(expectedExceptionType, error.GetType());
        }
		public static System.Collections.Generic.List<ServiceStack.Translators.Generator.Tests.Support.Model.Customer> ToCustomers(System.Collections.Generic.IEnumerable<ServiceStack.Translators.Generator.Tests.Support.DataContract.Customer> from)
		{
			if ((from == null))
			{
				return null;
			}
			System.Collections.Generic.List<ServiceStack.Translators.Generator.Tests.Support.Model.Customer> to = new System.Collections.Generic.List<ServiceStack.Translators.Generator.Tests.Support.Model.Customer>();
			for (System.Collections.Generic.IEnumerator<ServiceStack.Translators.Generator.Tests.Support.DataContract.Customer> iter = from.GetEnumerator(); iter.MoveNext(); 
			)
			{
				ServiceStack.Translators.Generator.Tests.Support.DataContract.Customer item = iter.Current;
				if ((item != null))
				{
					to.Add(item.ToCustomer());
				}
			}
			return to;
		}
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            var matrix = Matrix.GetIdenticalMatrix(10);
            Console.WriteLine(matrix.Add(Matrix.GetIdenticalMatrix(10)));

            LogMessage("Hello", "World");
            LogMessage("Hello");
            LogMessage(new[] { "Hello" });
            LogMessage(new[] { "Hello", "World" });

            var words = new []{ "Hello", " ", "World", "!" };
            IEnumerator enumerator = words.GetEnumerator();
            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                string current = (string)enumerator.Current;
                Console.Write(current.ToUpper());
            }
        }
Exemplo n.º 24
0
        public void DteEventsModeChangeActivatesDebugOutputWindowWhenEnabled()
        {
            var mockDte2 = new Mock<DTE2>();
            var mockEvents = new Mock<Events>();
            var mockDteEvents = new Mock<DTEEvents>();
            var mockBuildEvents = new Mock<BuildEvents>();
            var mockServiceProvider = new Mock<IServiceProvider>();
            var mockToolWindows = new Mock<ToolWindows>();
            var mockOutputWindow = new Mock<OutputWindow>();
            var mockOutputWindowPanes = new Mock<OutputWindowPanes>();
            var mockOutputWindowPane = new Mock<OutputWindowPane>();
            var mockWindow = new Mock<Window>();
            mockServiceProvider.Setup(sp => sp.GetService(typeof(DTE))).Returns(mockDte2.Object);
            mockDte2.SetupGet(d => d.Events).Returns(mockEvents.Object);
            mockDte2.SetupGet(d => d.ToolWindows).Returns(mockToolWindows.Object);
            mockToolWindows.SetupGet(t => t.OutputWindow).Returns(mockOutputWindow.Object);
            mockOutputWindow.SetupGet(o => o.OutputWindowPanes).Returns(mockOutputWindowPanes.Object);
            mockOutputWindow.SetupGet(o => o.Parent).Returns(mockWindow.Object);
            mockWindow.Setup(w => w.Activate());
            mockOutputWindowPane.SetupGet(op => op.Guid).Returns(VSConstants.OutputWindowPaneGuid.DebugPane_string);
            mockOutputWindowPane.Setup(op => op.Activate());
            var panes = new[] { mockOutputWindowPane.Object };
            mockOutputWindowPanes.Setup(op => op.GetEnumerator()).Returns(panes.GetEnumerator());
            mockEvents.SetupGet(e => e.DTEEvents).Returns(mockDteEvents.Object);
            mockEvents.SetupGet(e => e.BuildEvents).Returns(() => mockBuildEvents.Object);

            var buildEvents = new BlueOnionSoftware.BuildEvents(mockServiceProvider.Object);
            buildEvents.ShowDebugWindowOnDebug = true;
            mockDteEvents.Raise(de => de.ModeChanged += null, vsIDEMode.vsIDEModeDesign);

            mockDte2.VerifyAll();
            mockEvents.VerifyAll();
            mockDteEvents.VerifyAll();
            mockBuildEvents.VerifyAll();
            mockServiceProvider.VerifyAll();
            mockToolWindows.VerifyAll();
            mockOutputWindow.VerifyAll();
            mockOutputWindowPane.VerifyAll();
            mockOutputWindowPanes.VerifyAll();
            mockWindow.VerifyAll();
        }
Exemplo n.º 25
0
        public override void Flush(System.Collections.ICollection threads, SegmentWriteState state)
        {
            System.Collections.IDictionary childThreadsAndFields = new System.Collections.Hashtable();
            System.Collections.IEnumerator it = threads.GetEnumerator();
            while (it.MoveNext())
            {
                DocFieldProcessorPerThread perThread = (DocFieldProcessorPerThread) ((System.Collections.DictionaryEntry) it.Current).Key;
                childThreadsAndFields[perThread.consumer] = perThread.Fields();
                perThread.TrimFields(state);
            }
            fieldsWriter.Flush(state);
            consumer.Flush(childThreadsAndFields, state);

            // Important to save after asking consumer to flush so
            // consumer can alter the FieldInfo* if necessary.  EG,
            // FreqProxTermsWriter does this with
            // FieldInfo.storePayload.
            System.String fileName = state.SegmentFileName(IndexFileNames.FIELD_INFOS_EXTENSION);
            fieldInfos.Write(state.directory, fileName);
            SupportClass.CollectionsHelper.AddIfNotContains(state.flushedFiles, fileName);
        }
Exemplo n.º 26
0
        public void BuildNodes( TreeNodeCollection nodes  , System.Collections.IEnumerable list )
        {
            TreeNodeCollection tempnodes = new TreeNodeCollection ();

            System.Collections.IEnumerator lt = list.GetEnumerator();

            while( lt.MoveNext() )
            {
                object o = lt.Current ;

                tempnodes.Add( _c.ToTreeNode( o ) );
            }

            TreeNodeCollection roots = this.GetRootNodes( tempnodes ) ;

            foreach( TreeNode n in roots )
            {
                nodes.Add( n );
                this.build( tempnodes , n.ChildNodes , n ) ;
            }
        }
        public override object Call(System.Collections.Generic.List<Parameter> parameters)
        {
            lock(LockObj)
            {
                var tmpMyParams = this.Parameters;

                var tmpMainParams = tmpMyParams.Take(parameters.Count).ToList();

                var tmpTail = tmpMyParams.Skip(parameters.Count).ToList();

                var tmpParamsEnumerator = parameters.GetEnumerator();

                var tmpNativeParams = new List<object>();

                foreach (var param in tmpMainParams)
                {
                    tmpParamsEnumerator.MoveNext();

                    var tmpInputParam = tmpParamsEnumerator.Current;

                    var tmpVal = tmpInputParam.GetNativeValue(param.NativeType);

                    tmpNativeParams.Add(tmpVal);
                }

                if(!StillOneScriptCore.Common.TypeHelpers.ListHelper.IsEmpty(tmpTail))
                {
                    foreach(var param in tmpTail)
                    {
                        tmpNativeParams.Add(param.NativeDefaultValue);
                    }
                }

                return this.MethodInfo.Invoke(mObject, tmpNativeParams.ToArray());
            }
        }
Exemplo n.º 28
0
		public virtual float Idf(System.Collections.ICollection terms, Searcher searcher)
		{
			float idf = 0.0f;
			System.Collections.IEnumerator i = terms.GetEnumerator();
			while (i.MoveNext())
			{
				idf += Idf((Term) i.Current, searcher);
			}
			return idf;
		}
Exemplo n.º 29
0
 /// <summary>Adds all of the elements in the specified collection to this collection </summary>
 public virtual bool AddAll(System.Collections.ICollection items)
 {
     bool added = false;
     System.Collections.IEnumerator iter = items.GetEnumerator();
     System.Object item;
     while (iter.MoveNext())
     {
         item = iter.Current;
         added = Add(item);
     }
     return added;
 }
Exemplo n.º 30
0
		/// <summary> Assumes the fields are not storing term vectors.
		/// 
		/// </summary>
		/// <param name="names">The names of the fields
		/// </param>
		/// <param name="isIndexed">Whether the fields are indexed or not
		/// 
		/// </param>
		/// <seealso cref="Add(String, boolean)">
		/// </seealso>
        public void Add(System.Collections.Generic.ICollection<string> names, bool isIndexed)
		{
			lock (this)
			{
				System.Collections.IEnumerator i = names.GetEnumerator();
				while (i.MoveNext())
				{
					Add((System.String) i.Current, isIndexed);
				}
			}
		}