Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Static Code Analysis

, 15 Mar 2010
A static code analyzer building method call networks + sample applications.
CodeAnalyzerAndToDoSample.zip
Generator
bin
.noclean
Arebis.CodeAnalysis.Static.dll
Arebis.CodeGeneration.dll
Arebis.CodeGeneration.VisualStudio.dll
Arebis.CodeGenerator.dll
Arebis.Common.dll
CGen.exe
Content.cst
Content.cst.gen
COperation.cst
COperation.cst.gen
files
GeneratorMain.cst
GeneratorMain.cst.gen
Index.cst
Index.cst.gen
IndexTop.cst
IndexTop.cst.gen
SOperation.cst
SOperation.cst.gen
UIOperation.cst
UIOperation.cst.gen
Output
SampleApp
LocalTestRun.testrunconfig
ToDoApplication
Infrastructure
Properties
Service References
ToDoContract
Properties
ToDoSample.vsmdi
ToDoService
Entities.edmx
Infrastructure
Properties
ToDoSample.Service.csproj.user
ToDoSampleDb.mdf
ToDoSampleDb_log.ldf
ToDoUnitTests
Properties
Testing
ToDoSample.UnitTests.csproj.user
UnitTests
StaticCodeAnalyzer
Arebis.CodeAnalysis.Static
Arebis.CodeAnalysis.Static.csproj.user
CodeModel.cd
Processors
Rules
Properties
Arebis.Common
Arebis
Collections
Generic
Reflection
Properties
System
Collections
Generic
Net2
Threading
Net2
using System;
using System.Text;

namespace System.Collections.Generic.Net2
{
	/// <summary>
	/// A collection of unique unordered members.
	/// </summary>
	/// <typeparam name="T">Member type.</typeparam>
	[Serializable]
	[Obsolete("Since .NET 3.5, prefer System.Collections.Generic.HashSet, from System.Core.dll.", false)]
	public class HashSet<T> : ICollection<T>
	{
		private Dictionary<T, object> internalList;

		#region Constructor methods

		public HashSet()
			: this(new DefaultEqualityComparer<T>())
		{ }

		public HashSet(IEqualityComparer<T> customComparer)
		{
			this.internalList = new Dictionary<T, object>(customComparer);
		}

		public HashSet(IEnumerable<T> range)
			: this()
		{
			this.AddRange(range);
		}

		public HashSet(IEnumerable<T> range, IEqualityComparer<T> customComparer)
			: this(customComparer)
		{
			this.AddRange(range);
		}

		#endregion Constructor methods

		#region ICollection<T> Members

		public void Add(T item)
		{
			if (!this.internalList.ContainsKey(item))
				this.internalList.Add(item, null);
		}

		public void Clear()
		{
			this.internalList.Clear();
		}

		public bool Contains(T item)
		{
			return this.internalList.ContainsKey(item);
		}

		public void CopyTo(T[] array, int arrayIndex)
		{
			this.internalList.Keys.CopyTo(array, arrayIndex);
		}

		public int Count
		{
			get { return this.internalList.Count; }
		}

		public bool IsReadOnly
		{
			get { return false; }
		}

		public bool Remove(T item)
		{
			return this.internalList.Remove(item);
		}

		#endregion

		#region IEnumerable<T> Members

		public IEnumerator<T> GetEnumerator()
		{
			return this.internalList.Keys.GetEnumerator();
		}

		#endregion

		#region Additional Members

		public void AddRange(IEnumerable<T> range)
		{
			foreach (T item in range)
				this.Add(item);
		}

		#endregion

		#region IEnumerable Members

		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
		{
			return ((System.Collections.IEnumerable)this.internalList.Keys).GetEnumerator();
		}

		#endregion

		#region Default Comparer

		[Serializable]
		private class DefaultEqualityComparer<U> : IEqualityComparer<U>
		{
			public bool Equals(U x, U y)
			{
				if (Object.ReferenceEquals(x, y))
					return true;
				else if (Object.ReferenceEquals(x, null))
					return false;
				else
					return x.Equals(y);
			}

			public int GetHashCode(U obj)
			{
				return obj.GetHashCode();
			}
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rudi Breedenraedt
Architect Wolters Kluwer Belgium
Belgium Belgium
Rudi is a Software Architect at Wolters Kluwer Belgium.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 15 Mar 2010
Article Copyright 2010 by Rudi Breedenraedt
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid