Repository: chrisdunelm/DotNetAnywhere
Branch: master
Commit: 95cb3933b5b3
Files: 705
Total size: 3.1 MB
Directory structure:
gitextract_4p48603e/
├── .gitignore
├── ChangeLog.txt
├── CustomDevice/
│ ├── CustomDevice.csproj
│ ├── DeviceGraphics.cs
│ ├── KeyPad.cs
│ ├── KeyPadKey.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── Utils.cs
│ └── WindowsScreen.cs
├── License.txt
├── Managed.sln
├── Snake/
│ ├── ASnake.cs
│ ├── CrashType.cs
│ ├── Program.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── Snake.csproj
│ └── SnakePit.cs
├── System/
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── System.Collections.Generic/
│ │ ├── Queue.cs
│ │ └── Stack.cs
│ ├── System.ComponentModel/
│ │ └── Win32Exception.cs
│ ├── System.Net/
│ │ ├── Dns.cs
│ │ ├── EndPoint.cs
│ │ ├── IPAddress.cs
│ │ ├── IPEndPoint.cs
│ │ ├── IPHostEntry.cs
│ │ └── SocketAddress.cs
│ ├── System.Net.Sockets/
│ │ ├── AddressFamily.cs
│ │ ├── ProtocolType.cs
│ │ ├── Socket.cs
│ │ ├── SocketException.cs
│ │ ├── SocketFlags.cs
│ │ ├── SocketOptionLevel.cs
│ │ ├── SocketOptionName.cs
│ │ └── SocketType.cs
│ └── System.csproj
├── System.Core/
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── System/
│ │ ├── Action.cs
│ │ └── Func.cs
│ ├── System.Collections.Generic/
│ │ └── HashSet.cs
│ ├── System.Core.csproj
│ ├── System.Linq/
│ │ ├── Enumerable.cs
│ │ ├── Grouping.cs
│ │ ├── IGrouping.cs
│ │ ├── ILookup.cs
│ │ ├── IOrderedEnumerable.cs
│ │ ├── Lookup.cs
│ │ └── OrderedEnumerable.cs
│ └── System.Runtime.CompilerServices/
│ └── ExtensionAttribute.cs
├── System.Drawing/
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── System.Drawing/
│ │ ├── Bitmap.cs
│ │ ├── Brush.cs
│ │ ├── Brushes.cs
│ │ ├── Color.cs
│ │ ├── Font.cs
│ │ ├── FontFamily.cs
│ │ ├── FontStyle.cs
│ │ ├── Graphics.cs
│ │ ├── Image.cs
│ │ ├── KnownColor.cs
│ │ ├── KnownColors.cs
│ │ ├── LibIGraph.cs
│ │ ├── Pen.cs
│ │ ├── Pens.cs
│ │ ├── Point.cs
│ │ ├── PointF.cs
│ │ ├── Rectangle.cs
│ │ ├── RectangleF.cs
│ │ ├── Region.cs
│ │ ├── Size.cs
│ │ ├── SizeF.cs
│ │ ├── SolidBrush.cs
│ │ ├── StringAlignment.cs
│ │ ├── StringFormat.cs
│ │ ├── StringFormatFlags.cs
│ │ └── StringTrimming.cs
│ ├── System.Drawing.Drawing2D/
│ │ ├── HatchBrush.cs
│ │ ├── HatchStyle.cs
│ │ ├── LinearGradientBrush.cs
│ │ └── WrapMode.cs
│ ├── System.Drawing.Imaging/
│ │ └── PixelFormat.cs
│ ├── System.Drawing.Text/
│ │ └── TextRenderingHint.cs
│ └── System.Drawing.csproj
├── corlib/
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── System/
│ │ ├── Action.cs
│ │ ├── Activator.cs
│ │ ├── ArgumentException.cs
│ │ ├── ArgumentNullException.cs
│ │ ├── ArgumentOutOfRangeException.cs
│ │ ├── ArithmeticException.cs
│ │ ├── Array.cs
│ │ ├── ArrayTypeMismatchException.cs
│ │ ├── AsyncCallback.cs
│ │ ├── Attribute.cs
│ │ ├── AttributeTargets.cs
│ │ ├── AttributeUsageAttribute.cs
│ │ ├── BitConverter.cs
│ │ ├── Boolean.cs
│ │ ├── Byte.cs
│ │ ├── Char.cs
│ │ ├── CharEnumerator.cs
│ │ ├── Console.cs
│ │ ├── ConsoleKey.cs
│ │ ├── ConsoleKeyInfo.cs
│ │ ├── ConsoleModifiers.cs
│ │ ├── Converter.cs
│ │ ├── DateTime.cs
│ │ ├── DateTimeKind.cs
│ │ ├── DayOfWeek.cs
│ │ ├── Decimal.cs
│ │ ├── Delegate.cs
│ │ ├── Double.cs
│ │ ├── Enum.cs
│ │ ├── Environment.cs
│ │ ├── Exception.cs
│ │ ├── FlagsAttribute.cs
│ │ ├── FormatException.cs
│ │ ├── GC.cs
│ │ ├── IAsyncResult.cs
│ │ ├── ICloneable.cs
│ │ ├── IComparable.cs
│ │ ├── ICustomFormatter.cs
│ │ ├── IDisposable.cs
│ │ ├── IEquatable.cs
│ │ ├── IFormatProvider.cs
│ │ ├── IFormattable.cs
│ │ ├── IndexOutOfRangeException.cs
│ │ ├── Int16.cs
│ │ ├── Int32.cs
│ │ ├── Int64.cs
│ │ ├── IntPtr.cs
│ │ ├── InvalidCastException.cs
│ │ ├── InvalidOperationException.cs
│ │ ├── MarshalByRefObject.cs
│ │ ├── Math.cs
│ │ ├── MulticastDelegate.cs
│ │ ├── MulticastNotSupportedException.cs
│ │ ├── NotImplementedException.cs
│ │ ├── NotSupportedException.cs
│ │ ├── NullReferenceException.cs
│ │ ├── Nullable.cs
│ │ ├── NumberFormatter.cs
│ │ ├── Object.cs
│ │ ├── ObjectDisposedException.cs
│ │ ├── OperatingSystem.cs
│ │ ├── OverflowException.cs
│ │ ├── ParamArrayAttribute.cs
│ │ ├── ParseHelper.cs
│ │ ├── PlatformID.cs
│ │ ├── Predicate.cs
│ │ ├── Random.cs
│ │ ├── RuntimeFieldHandle.cs
│ │ ├── RuntimeMethodHandle.cs
│ │ ├── RuntimeType.cs
│ │ ├── RuntimeTypeHandle.cs
│ │ ├── SByte.cs
│ │ ├── Single.cs
│ │ ├── String.cs
│ │ ├── StringComparison.cs
│ │ ├── StringHelper.cs
│ │ ├── SystemException.cs
│ │ ├── TimeSpan.cs
│ │ ├── Type.cs
│ │ ├── UInt16.cs
│ │ ├── UInt32.cs
│ │ ├── UInt64.cs
│ │ ├── UIntPtr.cs
│ │ ├── ValueType.cs
│ │ ├── Version.cs
│ │ ├── Void.cs
│ │ └── WeakReference.cs
│ ├── System.Collections/
│ │ ├── ArrayList.cs
│ │ ├── DictionaryEntry.cs
│ │ ├── ICollection.cs
│ │ ├── IComparer.cs
│ │ ├── IDictionary.cs
│ │ ├── IDictionaryEnumerator.cs
│ │ ├── IEnumerable.cs
│ │ ├── IEnumerator.cs
│ │ ├── IEqualityComparer.cs
│ │ └── IList.cs
│ ├── System.Collections.Generic/
│ │ ├── Comparer.cs
│ │ ├── Dictionary.cs
│ │ ├── EqualityComparer.cs
│ │ ├── GenericEqualityComparer.cs
│ │ ├── ICollection.cs
│ │ ├── IComparer.cs
│ │ ├── IDictionary.cs
│ │ ├── IEnumerable.cs
│ │ ├── IEnumerator.cs
│ │ ├── IEqualityComparer.cs
│ │ ├── IList.cs
│ │ ├── KeyNotFoundException.cs
│ │ ├── KeyValuePair.cs
│ │ └── List.cs
│ ├── System.Diagnostics/
│ │ └── Debugger.cs
│ ├── System.Globalization/
│ │ ├── Calendar.cs
│ │ ├── CalendarWeekRule.cs
│ │ ├── CalendricalCalculations.cs
│ │ ├── CultureInfo.cs
│ │ ├── CultureTypes.cs
│ │ ├── DateTimeFormatInfo.cs
│ │ ├── DigitShapes.cs
│ │ ├── GregorianCalendar.cs
│ │ ├── GregorianCalendarTypes.cs
│ │ ├── NumberFormatInfo.cs
│ │ ├── NumberStyles.cs
│ │ ├── TextInfo.cs
│ │ └── UnicodeCategory.cs
│ ├── System.IO/
│ │ ├── CheckArgument.cs
│ │ ├── Directory.cs
│ │ ├── DirectoryInfo.cs
│ │ ├── DirectoryNotFoundException.cs
│ │ ├── File.cs
│ │ ├── FileAccess.cs
│ │ ├── FileAttributes.cs
│ │ ├── FileInfo.cs
│ │ ├── FileInternal.cs
│ │ ├── FileMode.cs
│ │ ├── FileNotFoundException.cs
│ │ ├── FileShare.cs
│ │ ├── FileStream.cs
│ │ ├── FileSystemInfo.cs
│ │ ├── IOException.cs
│ │ ├── Path.cs
│ │ ├── SearchPattern.cs
│ │ ├── SeekOrigin.cs
│ │ ├── Stream.cs
│ │ ├── StreamReader.cs
│ │ └── TextReader.cs
│ ├── System.Reflection/
│ │ ├── DefaultMemberAttribute.cs
│ │ └── MemberInfo.cs
│ ├── System.Runtime.CompilerServices/
│ │ ├── IndexerNameAttribute.cs
│ │ ├── MethodImplAttribute.cs
│ │ ├── MethodImplOptions.cs
│ │ └── RuntimeHelpers.cs
│ ├── System.Runtime.InteropServices/
│ │ ├── CallingConvention.cs
│ │ ├── CharSet.cs
│ │ ├── DllImportAttribute.cs
│ │ ├── ExternalException.cs
│ │ ├── InAttribute.cs
│ │ └── OutAttribute.cs
│ ├── System.Text/
│ │ ├── Decoder.cs
│ │ ├── Encoding.cs
│ │ ├── StringBuilder.cs
│ │ ├── UTF8Encoding.cs
│ │ └── UnicodeEncoding.cs
│ ├── System.Threading/
│ │ ├── Interlocked.cs
│ │ ├── Monitor.cs
│ │ ├── ParameterizedThreadStart.cs
│ │ ├── Thread.cs
│ │ ├── ThreadStart.cs
│ │ ├── ThreadState.cs
│ │ └── WaitHandle.cs
│ └── corlib.csproj
├── dna/
│ ├── Bugs.txt
│ ├── CIL_OpCodes.h
│ ├── CLIFile.c
│ ├── CLIFile.h
│ ├── Compat.h
│ ├── Config.h
│ ├── Cultures/
│ │ ├── _
│ │ ├── af
│ │ ├── af-ZA
│ │ ├── ar
│ │ ├── ar-AE
│ │ ├── ar-BH
│ │ ├── ar-DZ
│ │ ├── ar-EG
│ │ ├── ar-IQ
│ │ ├── ar-JO
│ │ ├── ar-KW
│ │ ├── ar-LB
│ │ ├── ar-LY
│ │ ├── ar-MA
│ │ ├── ar-OM
│ │ ├── ar-QA
│ │ ├── ar-SA
│ │ ├── ar-SY
│ │ ├── ar-TN
│ │ ├── ar-YE
│ │ ├── az
│ │ ├── az-Cyrl-AZ
│ │ ├── az-Latn-AZ
│ │ ├── be
│ │ ├── be-BY
│ │ ├── bg
│ │ ├── bg-BG
│ │ ├── bn-IN
│ │ ├── bs-Latn-BA
│ │ ├── ca
│ │ ├── ca-ES
│ │ ├── cs
│ │ ├── cs-CZ
│ │ ├── cy-GB
│ │ ├── da
│ │ ├── da-DK
│ │ ├── de
│ │ ├── de-AT
│ │ ├── de-CH
│ │ ├── de-DE
│ │ ├── de-LI
│ │ ├── de-LU
│ │ ├── dv
│ │ ├── dv-MV
│ │ ├── el
│ │ ├── el-GR
│ │ ├── en
│ │ ├── en-029
│ │ ├── en-AU
│ │ ├── en-BZ
│ │ ├── en-CA
│ │ ├── en-GB
│ │ ├── en-IE
│ │ ├── en-JM
│ │ ├── en-NZ
│ │ ├── en-PH
│ │ ├── en-TT
│ │ ├── en-US
│ │ ├── en-ZA
│ │ ├── en-ZW
│ │ ├── es
│ │ ├── es-AR
│ │ ├── es-BO
│ │ ├── es-CL
│ │ ├── es-CO
│ │ ├── es-CR
│ │ ├── es-DO
│ │ ├── es-EC
│ │ ├── es-ES
│ │ ├── es-GT
│ │ ├── es-HN
│ │ ├── es-MX
│ │ ├── es-NI
│ │ ├── es-PA
│ │ ├── es-PE
│ │ ├── es-PR
│ │ ├── es-PY
│ │ ├── es-SV
│ │ ├── es-UY
│ │ ├── es-VE
│ │ ├── et
│ │ ├── et-EE
│ │ ├── eu
│ │ ├── eu-ES
│ │ ├── fa
│ │ ├── fa-IR
│ │ ├── fi
│ │ ├── fi-FI
│ │ ├── fo
│ │ ├── fo-FO
│ │ ├── fr
│ │ ├── fr-BE
│ │ ├── fr-CA
│ │ ├── fr-CH
│ │ ├── fr-FR
│ │ ├── fr-LU
│ │ ├── fr-MC
│ │ ├── gl
│ │ ├── gl-ES
│ │ ├── gu
│ │ ├── gu-IN
│ │ ├── he
│ │ ├── he-IL
│ │ ├── hi
│ │ ├── hi-IN
│ │ ├── hr
│ │ ├── hr-BA
│ │ ├── hr-HR
│ │ ├── hu
│ │ ├── hu-HU
│ │ ├── hy
│ │ ├── hy-AM
│ │ ├── id
│ │ ├── id-ID
│ │ ├── is
│ │ ├── is-IS
│ │ ├── it
│ │ ├── it-CH
│ │ ├── it-IT
│ │ ├── ja
│ │ ├── ja-JP
│ │ ├── ka
│ │ ├── ka-GE
│ │ ├── kk
│ │ ├── kk-KZ
│ │ ├── kn
│ │ ├── kn-IN
│ │ ├── ko
│ │ ├── ko-KR
│ │ ├── kok
│ │ ├── kok-IN
│ │ ├── ky
│ │ ├── ky-KG
│ │ ├── lt
│ │ ├── lt-LT
│ │ ├── lv
│ │ ├── lv-LV
│ │ ├── mi-NZ
│ │ ├── mk
│ │ ├── mk-MK
│ │ ├── ml-IN
│ │ ├── mn
│ │ ├── mn-MN
│ │ ├── mr
│ │ ├── mr-IN
│ │ ├── ms
│ │ ├── ms-BN
│ │ ├── ms-MY
│ │ ├── mt-MT
│ │ ├── nb-NO
│ │ ├── nl
│ │ ├── nl-BE
│ │ ├── nl-NL
│ │ ├── nn-NO
│ │ ├── no
│ │ ├── ns-ZA
│ │ ├── pa
│ │ ├── pa-IN
│ │ ├── pl
│ │ ├── pl-PL
│ │ ├── pt
│ │ ├── pt-BR
│ │ ├── pt-PT
│ │ ├── quz-BO
│ │ ├── quz-EC
│ │ ├── quz-PE
│ │ ├── ro
│ │ ├── ro-RO
│ │ ├── ru
│ │ ├── ru-RU
│ │ ├── sa
│ │ ├── sa-IN
│ │ ├── se-FI
│ │ ├── se-NO
│ │ ├── se-SE
│ │ ├── sk
│ │ ├── sk-SK
│ │ ├── sl
│ │ ├── sl-SI
│ │ ├── sma-NO
│ │ ├── sma-SE
│ │ ├── smj-NO
│ │ ├── smj-SE
│ │ ├── smn-FI
│ │ ├── sms-FI
│ │ ├── sq
│ │ ├── sq-AL
│ │ ├── sr
│ │ ├── sr-Cyrl-BA
│ │ ├── sr-Cyrl-CS
│ │ ├── sr-Latn-BA
│ │ ├── sr-Latn-CS
│ │ ├── sv
│ │ ├── sv-FI
│ │ ├── sv-SE
│ │ ├── sw
│ │ ├── sw-KE
│ │ ├── syr
│ │ ├── syr-SY
│ │ ├── ta
│ │ ├── ta-IN
│ │ ├── te
│ │ ├── te-IN
│ │ ├── th
│ │ ├── th-TH
│ │ ├── tn-ZA
│ │ ├── tr
│ │ ├── tr-TR
│ │ ├── tt
│ │ ├── tt-RU
│ │ ├── uk
│ │ ├── uk-UA
│ │ ├── ur
│ │ ├── ur-PK
│ │ ├── uz
│ │ ├── uz-Cyrl-UZ
│ │ ├── uz-Latn-UZ
│ │ ├── vi
│ │ ├── vi-VN
│ │ ├── xh-ZA
│ │ ├── zh-CHS
│ │ ├── zh-CHT
│ │ ├── zh-CN
│ │ ├── zh-HK
│ │ ├── zh-MO
│ │ ├── zh-SG
│ │ ├── zh-TW
│ │ └── zu-ZA
│ ├── Delegate.c
│ ├── Delegate.h
│ ├── EvalStack.h
│ ├── Finalizer.c
│ ├── Finalizer.h
│ ├── Generics.c
│ ├── Generics.h
│ ├── Heap.c
│ ├── Heap.h
│ ├── InternalCall.c
│ ├── InternalCall.h
│ ├── JIT.c
│ ├── JIT.h
│ ├── JIT_Execute.c
│ ├── JIT_OpCodes.h
│ ├── Makefile
│ ├── MetaData.c
│ ├── MetaData.h
│ ├── MetaDataTables.h
│ ├── MetaData_Fill.c
│ ├── MetaData_Search.c
│ ├── MethodState.c
│ ├── MethodState.h
│ ├── PInvoke.c
│ ├── PInvoke.h
│ ├── PInvoke_CaseCode.h
│ ├── PInvoke_TypeDef.h
│ ├── RVA.c
│ ├── RVA.h
│ ├── Sys.c
│ ├── Sys.h
│ ├── System.Array.c
│ ├── System.Array.h
│ ├── System.Char.CaseConversion.h
│ ├── System.Char.UC_IndexRuns.h
│ ├── System.Char.c
│ ├── System.Char.h
│ ├── System.Console.c
│ ├── System.Console.h
│ ├── System.DateTime.c
│ ├── System.DateTime.h
│ ├── System.Diagnostics.Debugger.c
│ ├── System.Diagnostics.Debugger.h
│ ├── System.Enum.c
│ ├── System.Enum.h
│ ├── System.Environment.c
│ ├── System.Environment.h
│ ├── System.GC.c
│ ├── System.GC.h
│ ├── System.IO.FileInternal.c
│ ├── System.IO.FileInternal.h
│ ├── System.Math.c
│ ├── System.Math.h
│ ├── System.Net.Dns.c
│ ├── System.Net.Dns.h
│ ├── System.Net.Sockets.Socket.c
│ ├── System.Net.Sockets.Socket.h
│ ├── System.Object.c
│ ├── System.Object.h
│ ├── System.Runtime.CompilerServices.RuntimeHelpers.c
│ ├── System.Runtime.CompilerServices.RuntimeHelpers.h
│ ├── System.RuntimeType.c
│ ├── System.RuntimeType.h
│ ├── System.String.c
│ ├── System.String.h
│ ├── System.Threading.Interlocked.c
│ ├── System.Threading.Interlocked.h
│ ├── System.Threading.Monitor.c
│ ├── System.Threading.Monitor.h
│ ├── System.Threading.Thread.c
│ ├── System.Threading.Thread.h
│ ├── System.Type.c
│ ├── System.Type.h
│ ├── System.ValueType.c
│ ├── System.ValueType.h
│ ├── System.WeakReference.c
│ ├── System.WeakReference.h
│ ├── Thread.c
│ ├── Thread.h
│ ├── Type.c
│ ├── Type.h
│ ├── Types.h
│ ├── dna.c
│ └── dna.vcproj
├── dna.sln
├── libIGraph/
│ ├── Bitmap.c
│ ├── Bitmap.h
│ ├── BitmapLoader.c
│ ├── Brush.c
│ ├── Brush.h
│ ├── Config.h
│ ├── DrawEllipses.c
│ ├── DrawEllipses.h
│ ├── DrawLines.c
│ ├── DrawLines.h
│ ├── DrawRectangles.c
│ ├── DrawRectangles.h
│ ├── Exports.c
│ ├── Font.c
│ ├── Font.h
│ ├── FontFamily.c
│ ├── FontFamily.h
│ ├── GetScreen.c
│ ├── GetScreen.h
│ ├── Graphics.c
│ ├── Graphics.h
│ ├── HatchBrushDefs.h
│ ├── Image.c
│ ├── Image.h
│ ├── Makefile
│ ├── Pen.c
│ ├── Pen.h
│ ├── Pixels.c
│ ├── Pixels.h
│ ├── Region.c
│ ├── Region.h
│ ├── StringFormat.c
│ ├── StringFormat.h
│ ├── Text.c
│ ├── Text.h
│ ├── freetype.txt
│ ├── include/
│ │ ├── freetype/
│ │ │ ├── config/
│ │ │ │ ├── ftconfig.h
│ │ │ │ ├── ftheader.h
│ │ │ │ ├── ftmodule.h
│ │ │ │ ├── ftoption.h
│ │ │ │ └── ftstdlib.h
│ │ │ ├── freetype.h
│ │ │ ├── ftbbox.h
│ │ │ ├── ftbdf.h
│ │ │ ├── ftbitmap.h
│ │ │ ├── ftcache.h
│ │ │ ├── ftchapters.h
│ │ │ ├── fterrdef.h
│ │ │ ├── fterrors.h
│ │ │ ├── ftgasp.h
│ │ │ ├── ftglyph.h
│ │ │ ├── ftgxval.h
│ │ │ ├── ftgzip.h
│ │ │ ├── ftimage.h
│ │ │ ├── ftincrem.h
│ │ │ ├── ftlcdfil.h
│ │ │ ├── ftlist.h
│ │ │ ├── ftlzw.h
│ │ │ ├── ftmac.h
│ │ │ ├── ftmm.h
│ │ │ ├── ftmodapi.h
│ │ │ ├── ftmoderr.h
│ │ │ ├── ftotval.h
│ │ │ ├── ftoutln.h
│ │ │ ├── ftpfr.h
│ │ │ ├── ftrender.h
│ │ │ ├── ftsizes.h
│ │ │ ├── ftsnames.h
│ │ │ ├── ftstroke.h
│ │ │ ├── ftsynth.h
│ │ │ ├── ftsystem.h
│ │ │ ├── fttrigon.h
│ │ │ ├── fttypes.h
│ │ │ ├── ftwinfnt.h
│ │ │ ├── ftxf86.h
│ │ │ ├── internal/
│ │ │ │ ├── autohint.h
│ │ │ │ ├── ftcalc.h
│ │ │ │ ├── ftdebug.h
│ │ │ │ ├── ftdriver.h
│ │ │ │ ├── ftgloadr.h
│ │ │ │ ├── ftmemory.h
│ │ │ │ ├── ftobjs.h
│ │ │ │ ├── ftrfork.h
│ │ │ │ ├── ftserv.h
│ │ │ │ ├── ftstream.h
│ │ │ │ ├── fttrace.h
│ │ │ │ ├── ftvalid.h
│ │ │ │ ├── internal.h
│ │ │ │ ├── pcftypes.h
│ │ │ │ ├── psaux.h
│ │ │ │ ├── pshints.h
│ │ │ │ ├── services/
│ │ │ │ │ ├── svbdf.h
│ │ │ │ │ ├── svgldict.h
│ │ │ │ │ ├── svgxval.h
│ │ │ │ │ ├── svkern.h
│ │ │ │ │ ├── svmm.h
│ │ │ │ │ ├── svotval.h
│ │ │ │ │ ├── svpfr.h
│ │ │ │ │ ├── svpostnm.h
│ │ │ │ │ ├── svpscmap.h
│ │ │ │ │ ├── svpsinfo.h
│ │ │ │ │ ├── svsfnt.h
│ │ │ │ │ ├── svttcmap.h
│ │ │ │ │ ├── svtteng.h
│ │ │ │ │ ├── svttglyf.h
│ │ │ │ │ ├── svwinfnt.h
│ │ │ │ │ └── svxf86nm.h
│ │ │ │ ├── sfnt.h
│ │ │ │ ├── t1types.h
│ │ │ │ └── tttypes.h
│ │ │ ├── t1tables.h
│ │ │ ├── ttnameid.h
│ │ │ ├── tttables.h
│ │ │ ├── tttags.h
│ │ │ └── ttunpat.h
│ │ └── ft2build.h
│ ├── jidctflt.c
│ ├── lib/
│ │ └── freetype.lib
│ ├── libIGraph.c
│ ├── libIGraph.def
│ ├── libIGraph.h
│ ├── libIGraph.vcproj
│ ├── tinyjpeg-internal.h
│ ├── tinyjpeg.c
│ └── tinyjpeg.h
├── mini-demo-dna/
│ ├── HelloWorld/
│ │ ├── HelloWorld.csproj
│ │ └── Program.cs
│ ├── mini-demo-dna/
│ │ └── main.c
│ ├── mini-demo-dna.sln
│ └── readme.md
└── readme.markdown
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
bin
obj
Debug
Release
Builds
.vs
*.ncb
*.suo
*.user
*.pidb
*.userprefs
*.xml
*.nupkg
*.svn
*.opensdf
*.sdf
*.vcxproj
*.vcxproj.filters
================================================
FILE: ChangeLog.txt
================================================
Major changes from v0.2.5 to v0.2.6
dna:
* Command line parameters are now passed to the .NET executable, in the args[] array to Main().
* When calling a method on a null reference, a NullReferenceException is now thrown,
rather than crashing. However - note that internally thrown exceptions don't act quite
as expected, as their constructors are not yet called.
------------------------------------------------------------------------------
Major changes from v0.2.4 to v0.2.5
All Visual Studio solutions have been upgraded to VS2008.
dna:
* Fixed bug with static fields in generic types. The memory location for the field
was not being initialised properly.
* Fixed bug with overridding virtual methods in generic types. Virtual method table
indexes were being generated for partially defined generic types, which shouldn't
be done as virtual method tables are not available for these types.
* Fixed bug where generic method type arguments were not propogated through the type
system correctly. (In fact, at all).
* Fixed bug in finding generic methods in another assembly. The generic method
signature was not being checked correctly.
* Fixed bug in MetaData_LoadTables() where the blob index size was being read incorrecty.
Thanks to Patrick Levesque for report and fix.
* Fixed bug in casting to nullable types.
* Fixed bug in using typeof() on generic arguments.
* Fixed bug in Array.GetValue() and Array.SetValue() when using nullable types.
* Improved error reporting for missing methods. Now shows the correct containing type.
* Improved conversion operations. All conversions are now supported, with more efficient
runtime operation. However, checked conversions run as unchecked conversions.
* Implemented all the unsigned branch instructions, long versions.
corlib:
* Added IComparer[T], IComparer and Comparer.
* Added IEqualityComparer[T], IEqualityComparer and EqualityComparer.
* Dictionary[TKey, TValue], List[T] and ArrayList re-implemented and improved.
* Fixed missing functionality in Nullable[T].Equals() method.
* Implemented Enum.GetNames().
System.Core:
* Added System.Core.dll, containing:
- Most LINQ to Objects extension methods.
- Func[...] and Action[...] delegates.
------------------------------------------------------------------------------
Major changes from v0.2.3 to v0.2.4
All parts of this project are now licensed under the MIT license.
------------------------------------------------------------------------------
Major changes from v0.2.2 to v0.2.3
dna:
* Improved time resolution of DateTime.UtcNow
* Added code to selectively generate combined-opcode versions often-used methods.
It is disabled by default, but may be enabled in config.h
It currently has the following major problems:
- It doesn't appear to actually speed up execution very much (~5% in testing).
- It leaks some memory when 'de-optimizing' methods that are no longer
frequently used. This won't be too difficult to fix.
* Added support for static fields containing value-types.
* Added support for casting from Int64 to Double.
corlib:
* DateTimeFormatInfo implemented
* Calendar and GregorianCalendar very basically implemented. Enough that DateTime
formatting now works.
* DateTime.ToString() now works properly (except for timezones).
* More of Math class implemented.
* Implemented IComparable, IComparable[T] and IEquatable[T] on Int16, Int32,
Int64, Single, Double, UInt16 ,UInt32, UInt64, Byte, SByte and Boolean.
System.Drawing:
* Region is very basically implemented. Only infinite and rectangular regions
are supported.
* Added clipping support to Graphics.
* Graphics.MeasureString() has some overloads implemented.
* Graphics.DrawEllipse() and FillEllipse() with int and rect arguments implemented.
* Fixed bug with line drawing.
libIGraph:
* Implemented native parts of region.
* Implemented native clipping support for all Graphics operations.
* Implemented native parts of MeasureString().
* Implemented ellipse drawing and filling.
System:
* Stack[T] class added.
------------------------------------------------------------------------------
Major changes from v0.2.1 to v0.2.2
dna:
* Added native code for DNS class
* Added native code for System.Threading.Interlocked class
corlib:
* Added all System.Threading.Interlocked methods that operate on Int32 values.
Enumerators defined using yield return therefore now work - they need
CompareExchange().
* Added delegates: Action[T], Predicate[T]
* Added TimeSpan - complete except for Parse() and TryParse()
* Added DateTime - DateTime.Now is not implemented, DateTime.UtcNow is.
Add simple operations are implemented, but not more complex/obscure stuff,
e.g. ToFileTime(). ToString() is only crudely implemented, not taking
any notice of formatting specified, or culture. It is always shown in
UK format (dd/mm/yyyy hh:mm:ss).
System:
* Added the beginnings of the Dns class. It is now possible to get the IPv4
address for a host-name.
------------------------------------------------------------------------------
Major changes from v0.2.0 to v0.2.1
dna:
* Fixed bug in constrained virtual calls.
* Fixed bug with how Single and Double types were handled.
* Added array functionality for floating-point types.
* Improved how internal calls are looked up.
* Updated the VS2005 build config for release, to place the executable
in the correct place.
* Implemented Nullable types.
* Implemented basic native socket functionality.
* A little more reflection implemented.
* Misc other bug-fixes and improvements.
System:
* Implemented Nullable and Nullable[T] classes.
* Implemented the Socket class (and friends). Only the very basic operations
are currently implemented. A socket can be created, used to listen or connect
and can send and receive data. Only IPv4 is supported and at the moment only
TCP is support (UDP to be added later). More will be implemented later.
corlib:
* A little more reflection implemented.
------------------------------------------------------------------------------
Major changes from v0.1 to v0.2.0
The Interpreter:
* The main interpreter loop has changed from a 'loop with switch'
to use direct threading (see http://en.wikipedia.org/wiki/Threaded_code
for details). This gives a performance advantage, although not on Windows
as having __asm code in a function appears to stop all other optimizations.
The assembler code is only required on non-GNU compilers as GNU provides
the computed goto statement.
* A dynamic code generator (strictly, just a combiner) has been
implemented, which dynamically generates multi-opcode instructions.
However, it is disabled by default because it currently generates
dynamic code for all JITted methods, which uses large amounts of
memory, and is not always faster (due to code caching). An algorithm
to selectively re-JIT frequently-used methods is being worked on.
* Split out the configuration into a seperate Config.h file.
* Misc other bug-fixes and improvements.
System.Drawing:
* Implmented LinearGradiantBrush
* Fixed bug in HatchBrush that caused all hatches to be drawn 90
degrees rotated.
================================================
FILE: CustomDevice/CustomDevice.csproj
================================================
Debug
AnyCPU
9.0.30729
2.0
{43619745-0A80-499E-907C-E733FF3DA2BE}
Library
Properties
CustomDevice
CustomDevice
3.5
false
v2.0
publish\
true
Disk
false
Foreground
7
Days
false
false
true
0
1.0.0.%2a
false
true
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
512
AllRules.ruleset
pdbonly
true
bin\Release\
TRACE
prompt
4
512
AllRules.ruleset
Form
False
.NET Framework 3.5 SP1 Client Profile
false
False
.NET Framework 2.0 %28x86%29
true
False
.NET Framework 3.0 %28x86%29
false
False
.NET Framework 3.5
false
False
.NET Framework 3.5 SP1
false
xcopy $(TargetPath) $(SolutionDir)Builds\$(ConfigurationName)\ /Y
================================================
FILE: CustomDevice/DeviceGraphics.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Threading;
namespace CustomDevice {
public static class DeviceGraphics {
private const int ScreenX = 320;
private const int ScreenY = 240;
private static int whichScreen = 0;
public static int ScreenXSize {
get {
return ScreenX;
}
}
public static int ScreenYSize {
get {
return ScreenY;
}
}
public static Graphics GetScreen() {
if (whichScreen == 0) {
if (Utils.IsInterNet2) {
whichScreen = 1;
} else {
whichScreen = 2;
}
}
if (whichScreen == 1) {
return GetScreen_InterNet2();
} else {
return GetScreen_Windows();
}
}
private static Graphics GetScreen_InterNet2() {
// In the InterNet2 System.Drawing dll Graphics.FromHdc() will always
// return the Graphics object for the screen.
return Graphics.FromHdc(IntPtr.Zero);
}
private static Graphics GetScreen_Windows() {
if (WindowsScreen.winScreen == null) {
Thread t = new Thread(WindowsScreen.WindowsMessagePump);
t.IsBackground = true;
t.Start();
while (WindowsScreen.winScreen == null) {
Thread.Sleep(2);
}
}
lock (WindowsScreen.winScreen) {
Graphics g = Graphics.FromImage(WindowsScreen.winScreen.FormSurface);
return g;
}
}
}
}
================================================
FILE: CustomDevice/KeyPad.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Threading;
namespace CustomDevice {
public static class KeyPad {
[DllImport("libIGraph")]
extern private static bool IsKeyDown_Internal(KeyPadKey key);
[DllImport("libIGraph")]
extern private static int LatestKeyUp_Internal();
[DllImport("libIGraph")]
extern private static int LatestKeyDown_Internal();
public static bool IsKeyDown(KeyPadKey key) {
if (Utils.IsInterNet2) {
return IsKeyDown_Internal(key);
} else {
return WindowsScreen.WinScreen.IsKeyDown(key);
}
}
private static bool WindowsLatestKeyUp(out KeyPadKey key) {
return WindowsScreen.WinScreen.LatestKeyUp(out key);
}
private static bool WindowsLatestKeyDown(out KeyPadKey key) {
return WindowsScreen.WinScreen.LatestKeyDown(out key);
}
public static bool LatestKeyUp(out KeyPadKey key) {
if (Utils.IsInterNet2) {
int iKey = LatestKeyUp_Internal();
if (iKey >= 0) {
key = (KeyPadKey)iKey;
return true;
} else {
key = KeyPadKey.B0;
return false;
}
} else {
return WindowsLatestKeyUp(out key);
}
}
public static bool LatestKeyDown(out KeyPadKey key) {
if (Utils.IsInterNet2) {
int iKey = LatestKeyDown_Internal();
if (iKey >= 0) {
key = (KeyPadKey)iKey;
return true;
} else {
key = KeyPadKey.B0;
return false;
}
} else {
return WindowsLatestKeyDown(out key);
}
}
public static KeyPadKey? ReadKey(int timeoutMs) {
DateTime end = DateTime.UtcNow.AddMilliseconds(timeoutMs);
do {
KeyPadKey key;
if (LatestKeyDown(out key)) {
return key;
}
Thread.Sleep(1);
} while (DateTime.UtcNow < end && timeoutMs >= 0);
return null;
}
public static KeyPadKey? ReadKey() {
return ReadKey(-1);
}
}
}
================================================
FILE: CustomDevice/KeyPadKey.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace CustomDevice {
public enum KeyPadKey {
B0 = 0,
B1 = 1,
B2 = 2,
B3 = 3,
B4 = 4,
B5 = 5,
B6 = 6,
B7 = 7,
B8 = 8,
B9 = 9,
C = 10,
OK = 11
}
}
================================================
FILE: CustomDevice/Properties/AssemblyInfo.cs
================================================
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DeviceGraphics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Docobo")]
[assembly: AssemblyProduct("DeviceGraphics")]
[assembly: AssemblyCopyright("Copyright © Docobo 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a7a488bb-a22b-4377-ab45-d2139150ff7d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
================================================
FILE: CustomDevice/Utils.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace CustomDevice {
static class Utils {
private static bool isDNA, isDNASet = false;
public static bool IsInterNet2 {
get {
if (!isDNASet) {
isDNA = Environment.OSVersion.VersionString.EndsWith("(DNA)");
isDNASet = true;
}
return isDNA;
}
}
}
}
================================================
FILE: CustomDevice/WindowsScreen.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
namespace CustomDevice {
class WindowsScreen : Form {
internal static WindowsScreen winScreen = null;
public static WindowsScreen WinScreen {
get {
if (winScreen == null) {
using (Graphics g = DeviceGraphics.GetScreen()) {
}
}
return winScreen;
}
}
public WindowsScreen(int width, int height) {
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.FixedWidth, true);
this.SetStyle(ControlStyles.FixedHeight, true);
this.SetStyle(ControlStyles.Opaque, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.formSurface = new Bitmap(width, height);
this.ClientSize = new Size(width, height);
this.Show();
this.Activate();
}
private Bitmap formSurface;
public Bitmap FormSurface {
get {
return this.formSurface;
}
}
protected override void OnPaint(PaintEventArgs e) {
lock (this) {
e.Graphics.DrawImageUnscaled(this.formSurface, new Point());
}
}
internal static void WindowsMessagePump(object state) {
WindowsScreen.winScreen = new WindowsScreen(DeviceGraphics.ScreenXSize, DeviceGraphics.ScreenYSize);
for (; ; ) {
Application.DoEvents();
Thread.Sleep(40);
WindowsScreen.winScreen.Refresh();
}
}
private bool[] keyState = new bool[12];
private KeyPadKey MapKey(Keys pcKey, out bool isValid) {
isValid = true;
switch (pcKey) {
case Keys.D0:
case Keys.NumPad0:
return KeyPadKey.B0;
case Keys.D1:
case Keys.NumPad1:
return KeyPadKey.B1;
case Keys.D2:
case Keys.NumPad2:
return KeyPadKey.B2;
case Keys.D3:
case Keys.NumPad3:
return KeyPadKey.B3;
case Keys.D4:
case Keys.NumPad4:
return KeyPadKey.B4;
case Keys.D5:
case Keys.NumPad5:
return KeyPadKey.B5;
case Keys.D6:
case Keys.NumPad6:
return KeyPadKey.B6;
case Keys.D7:
case Keys.NumPad7:
return KeyPadKey.B7;
case Keys.D8:
case Keys.NumPad8:
return KeyPadKey.B8;
case Keys.D9:
case Keys.NumPad9:
return KeyPadKey.B9;
case Keys.Enter:
return KeyPadKey.OK;
case Keys.Escape:
return KeyPadKey.C;
default:
isValid = false;
return KeyPadKey.B0;
}
}
protected override void OnKeyDown(KeyEventArgs e) {
bool isValid;
KeyPadKey key = this.MapKey(e.KeyCode, out isValid);
if (isValid) {
e.Handled = true;
this.keyState[(int)key] = true;
this.latestKeyDown = key;
return;
}
base.OnKeyDown(e);
}
protected override void OnKeyUp(KeyEventArgs e) {
bool isValid;
KeyPadKey key = this.MapKey(e.KeyCode, out isValid);
if (isValid) {
e.Handled = true;
this.keyState[(int)key] = false;
this.latestKeyUp = key;
return;
}
base.OnKeyUp(e);
}
public bool IsKeyDown(KeyPadKey key) {
return this.keyState[(int)key];
}
private KeyPadKey? latestKeyUp = null;
public bool LatestKeyUp(out KeyPadKey key) {
if (this.latestKeyUp.HasValue) {
key = this.latestKeyUp.Value;
this.latestKeyUp = null;
return true;
} else {
key = KeyPadKey.B0;
return false;
}
}
private KeyPadKey? latestKeyDown = null;
public bool LatestKeyDown(out KeyPadKey key) {
if (this.latestKeyDown.HasValue) {
key = this.latestKeyDown.Value;
this.latestKeyDown = null;
return true;
} else {
key = KeyPadKey.B0;
return false;
}
}
}
}
================================================
FILE: License.txt
================================================
Copyright (c) 2012 DotNetAnywhere
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Managed.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 11
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "corlib", "corlib\corlib.csproj", "{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Drawing", "System.Drawing\System.Drawing.csproj", "{0F7F935F-E3F5-40AD-BD22-0BA43721560F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System", "System\System.csproj", "{388F5D73-0211-4A64-B501-92CDC4E32ACF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snake", "Snake\Snake.csproj", "{C26A3309-7A61-40B6-9998-69B78CF226C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomDevice", "CustomDevice\CustomDevice.csproj", "{43619745-0A80-499E-907C-E733FF3DA2BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Core", "System.Core\System.Core.csproj", "{429C3225-3A36-427A-A44E-2AA3563FCD6D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
LocalTest|Any CPU = LocalTest|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F7F935F-E3F5-40AD-BD22-0BA43721560F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F7F935F-E3F5-40AD-BD22-0BA43721560F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F7F935F-E3F5-40AD-BD22-0BA43721560F}.LocalTest|Any CPU.ActiveCfg = Release|Any CPU
{0F7F935F-E3F5-40AD-BD22-0BA43721560F}.LocalTest|Any CPU.Build.0 = Release|Any CPU
{0F7F935F-E3F5-40AD-BD22-0BA43721560F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F7F935F-E3F5-40AD-BD22-0BA43721560F}.Release|Any CPU.Build.0 = Release|Any CPU
{388F5D73-0211-4A64-B501-92CDC4E32ACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{388F5D73-0211-4A64-B501-92CDC4E32ACF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{388F5D73-0211-4A64-B501-92CDC4E32ACF}.LocalTest|Any CPU.ActiveCfg = Release|Any CPU
{388F5D73-0211-4A64-B501-92CDC4E32ACF}.LocalTest|Any CPU.Build.0 = Release|Any CPU
{388F5D73-0211-4A64-B501-92CDC4E32ACF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{388F5D73-0211-4A64-B501-92CDC4E32ACF}.Release|Any CPU.Build.0 = Release|Any CPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}.LocalTest|Any CPU.ActiveCfg = Release|Any CPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}.LocalTest|Any CPU.Build.0 = Release|Any CPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}.Release|Any CPU.Build.0 = Release|Any CPU
{43619745-0A80-499E-907C-E733FF3DA2BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43619745-0A80-499E-907C-E733FF3DA2BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43619745-0A80-499E-907C-E733FF3DA2BE}.LocalTest|Any CPU.ActiveCfg = Release|Any CPU
{43619745-0A80-499E-907C-E733FF3DA2BE}.LocalTest|Any CPU.Build.0 = Release|Any CPU
{43619745-0A80-499E-907C-E733FF3DA2BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43619745-0A80-499E-907C-E733FF3DA2BE}.Release|Any CPU.Build.0 = Release|Any CPU
{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}.LocalTest|Any CPU.ActiveCfg = LocalTest|Any CPU
{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}.LocalTest|Any CPU.Build.0 = LocalTest|Any CPU
{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A77A7C0-FB66-4CAA-94EE-142DBA20655D}.Release|Any CPU.Build.0 = Release|Any CPU
{C26A3309-7A61-40B6-9998-69B78CF226C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C26A3309-7A61-40B6-9998-69B78CF226C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C26A3309-7A61-40B6-9998-69B78CF226C1}.LocalTest|Any CPU.ActiveCfg = Release|Any CPU
{C26A3309-7A61-40B6-9998-69B78CF226C1}.LocalTest|Any CPU.Build.0 = Release|Any CPU
{C26A3309-7A61-40B6-9998-69B78CF226C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C26A3309-7A61-40B6-9998-69B78CF226C1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: Snake/ASnake.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Snake {
class ASnake {
private SnakePit snakePit;
private Queue bodyParts = new Queue();
private Point head;
private int xSpeed, ySpeed;
private Color col;
private int increaseBy;
public ASnake(SnakePit snakePit, int startLength, Point startPosition, Color col) {
this.snakePit = snakePit;
for (int i = 0; i < startLength; i++) {
Point cell = new Point(startPosition.X - startLength + i + 1, startPosition.Y);
snakePit.SetCell(cell, col);
this.bodyParts.Enqueue(cell);
this.head = cell;
}
this.col = col;
this.xSpeed = 1;
this.ySpeed = 0;
this.increaseBy = 0;
snakePit.AddSnake(this);
}
public CrashType Move() {
if (this.increaseBy == 0) {
Point tail = this.bodyParts.Dequeue();
snakePit.ClearCell(tail);
} else {
this.increaseBy--;
}
this.head.X += this.xSpeed;
this.head.Y += this.ySpeed;
if (this.DoesIntersect(this.head)) {
Console.WriteLine("!!!SELF CRASH!!!");
return CrashType.Self;
}
this.bodyParts.Enqueue(this.head);
snakePit.SetCell(this.head, this.col);
CrashType crash = this.snakePit.IsCrash(head);
return crash;
}
public void DrawHead() {
snakePit.SetCell(this.head, this.col);
}
public void SetDirection(int x, int y) {
// Do nothing if trying to set current or opposite direction
if (x != 0 && this.xSpeed != 0) {
return;
}
if (y != 0 && this.ySpeed != 0) {
return;
}
// Set new speeds
this.xSpeed = x;
this.ySpeed = y;
}
public bool DoesIntersect(IEnumerable cells) {
foreach (Point cell in cells) {
if (this.DoesIntersect(cell)) {
return true;
}
}
return false;
}
public bool DoesIntersect(Point cell) {
foreach (Point p in this.bodyParts) {
if (p == cell) {
return true;
}
}
return false;
}
public void IncreaseLength(int amount) {
this.increaseBy += amount;
}
public Point Head {
get {
return this.head;
}
}
}
}
================================================
FILE: Snake/CrashType.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace Snake {
public enum CrashType {
None,
Self,
Wall,
Food,
}
}
================================================
FILE: Snake/Program.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Threading;
using CustomDevice;
namespace Snake {
class Program {
static void Main(string[] args) {
for (; ; ) {
bool res = Play();
if (!res) {
break;
}
}
}
static bool Play() {
Font f = new Font("tahoma", 25);
SnakePit snakePit = new SnakePit();
Random rnd = new Random();
int delay = 300;
ASnake snake = new ASnake(snakePit, 5, snakePit.Centre, Color.Black);
CrashType crashType;
for (; ; ) {
Thread.Sleep(delay);
KeyPadKey key;
if (KeyPad.LatestKeyDown(out key)) {
switch (key) {
case KeyPadKey.B6: // Left
snake.SetDirection(-1, 0);
break;
case KeyPadKey.B7: // Down
snake.SetDirection(0, 1);
break;
case KeyPadKey.B8: // Up
snake.SetDirection(0, -1);
break;
case KeyPadKey.B9: // Right
snake.SetDirection(1, 0);
break;
case KeyPadKey.C:
return false;
}
}
crashType = snake.Move();
bool finish = false;
switch (crashType) {
case CrashType.None:
break;
case CrashType.Self:
case CrashType.Wall:
default:
finish = true;
break;
case CrashType.Food:
bool levelUp = snakePit.EatFood();
if (levelUp) {
delay = (delay * 3) / 4;
}
snake.IncreaseLength(4);
break;
}
snake.DrawHead();
if (finish) {
break;
}
int r = rnd.Next(1000);
if (r < 50) {
snakePit.CreateFood(r < 5);
}
r = rnd.Next(1000);
if (r < 20) {
snakePit.AddObstacle();
}
}
snakePit.Msg(crashType.ToString());
Thread.Sleep(5000);
return true;
}
}
}
================================================
FILE: Snake/Properties/AssemblyInfo.cs
================================================
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Snake")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Docobo")]
[assembly: AssemblyProduct("Snake")]
[assembly: AssemblyCopyright("Copyright © Docobo 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a65d79de-9fdb-4e50-aa31-5aff8c5f8744")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
================================================
FILE: Snake/Snake.csproj
================================================
Debug
AnyCPU
9.0.30729
2.0
{C26A3309-7A61-40B6-9998-69B78CF226C1}
Exe
Properties
Snake
Snake
3.5
false
v2.0
publish\
true
Disk
false
Foreground
7
Days
false
false
true
0
1.0.0.%2a
false
true
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
AllRules.ruleset
pdbonly
true
bin\Release\
TRACE
prompt
4
512
AllRules.ruleset
{43619745-0A80-499E-907C-E733FF3DA2BE}
CustomDevice
False
.NET Framework 3.5 SP1 Client Profile
false
False
.NET Framework 2.0 %28x86%29
true
False
.NET Framework 3.0 %28x86%29
false
False
.NET Framework 3.5
false
False
.NET Framework 3.5 SP1
false
xcopy $(TargetPath) $(SolutionDir)Builds\$(ConfigurationName)\ /Y
================================================
FILE: Snake/SnakePit.cs
================================================
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using CustomDevice;
using System.Drawing.Drawing2D;
namespace Snake {
class SnakePit {
private const int cellSize = 8;
private const int scoreBoardHeight = 48;
private Graphics screen;
private int cellOfsX, cellOfsY;
private int numCellsX, numCellsY;
private Random rnd;
private Point[] food;
private List snakes = new List();
private int score, level;
private List obstacles = new List();
public SnakePit() {
this.screen = DeviceGraphics.GetScreen();
this.screen.Clear(Color.White);
this.numCellsX = (DeviceGraphics.ScreenXSize / cellSize) - 2;
this.numCellsY = ((DeviceGraphics.ScreenYSize - scoreBoardHeight) / cellSize) - 2;
this.cellOfsX = cellSize;
this.cellOfsY = cellSize;
this.rnd = new Random();
this.food = null;
this.score = 0;
this.level = 1;
using (Brush brush = new HatchBrush(HatchStyle.DiagonalCross, Color.Black, Color.White)) {
this.screen.FillRectangle(brush, 0, 0, DeviceGraphics.ScreenXSize, cellSize);
this.screen.FillRectangle(brush, 0, cellSize, cellSize, this.numCellsY * cellSize);
this.screen.FillRectangle(brush, (1 + this.numCellsX) * cellSize, cellSize, cellSize, this.numCellsY * cellSize);
this.screen.FillRectangle(brush, 0, (1 + this.numCellsY) * cellSize, DeviceGraphics.ScreenXSize, cellSize);
}
this.screen.DrawRectangle(Pens.Black, cellSize - 1, cellSize - 1,
this.numCellsX * cellSize + 1, this.numCellsY * cellSize + 1);
using (Font f = new Font("tahoma", 15)) {
using (StringFormat sf = new StringFormat()) {
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
this.screen.DrawString("<", f, Brushes.Black, new RectangleF(0, 220, 64, 20), sf);
this.screen.DrawString("v", f, Brushes.Black, new RectangleF(64, 220, 64, 20), sf);
this.screen.DrawString("^", f, Brushes.Black, new RectangleF(128, 220, 64, 20), sf);
this.screen.DrawString(">", f, Brushes.Black, new RectangleF(192, 220, 64, 20), sf);
}
}
this.ShowScore();
}
private void FillCell(Point cell, Color col) {
using (Brush brush = new SolidBrush(col)) {
screen.FillRectangle(brush,
this.cellOfsX + cell.X * cellSize, this.cellOfsY + cell.Y * cellSize, cellSize, cellSize);
}
}
public void FillAndOutlineCells(IEnumerable points, Color fillCol, Color outlineCol) {
using (Brush brush = new SolidBrush(fillCol)) {
this.FillAndOutlineCells(points, brush, outlineCol);
}
}
public void FillAndOutlineCells(IEnumerable points, Brush fillBrush, Color outlineCol) {
int minX = int.MaxValue, maxX = int.MinValue;
int minY = int.MaxValue, maxY = int.MinValue;
foreach (Point p in points) {
minX = Math.Min(minX, p.X);
maxX = Math.Max(maxX, p.X);
minY = Math.Min(minY, p.Y);
maxY = Math.Max(maxY, p.Y);
}
int x = this.cellOfsX + minX * cellSize;
int y = this.cellOfsY + minY * cellSize;
int width = (maxX - minX + 1) * cellSize;
int height = (maxY - minY + 1) * cellSize;
this.screen.FillRectangle(fillBrush, x, y, width, height);
using (Pen pen = new Pen(outlineCol)) {
this.screen.DrawRectangle(pen, x, y, width - 1, height - 1);
}
}
public void AddSnake(ASnake snake) {
this.snakes.Add(snake);
}
public Point Centre {
get {
return new Point(numCellsX >> 1, numCellsY >> 1);
}
}
public Size Size {
get {
return new Size(numCellsX, numCellsY);
}
}
public void SetCell(Point cell, Color col) {
this.FillCell(cell, col);
}
public void ClearCell(Point cell) {
this.FillCell(cell, Color.White);
}
public bool IsCrashObstacle(Point cell) {
foreach (Point[] obs in this.obstacles) {
foreach (Point pt in obs) {
if (pt == cell) {
return true;
}
}
}
return false;
}
public CrashType IsCrash(Point cell) {
if (cell.X < 0 || cell.X >= this.numCellsX || cell.Y < 0 || cell.Y >= this.numCellsY) {
return CrashType.Wall;
}
if (this.IsCrashObstacle(cell)) {
return CrashType.Wall;
}
if (this.food != null) {
for (int i = 0; i < this.food.Length; i++) {
if (this.food[i] == cell) {
return CrashType.Food;
}
}
}
return CrashType.None;
}
public void CreateFood(bool canMoveFood) {
if (this.food != null && !canMoveFood) {
// Don't move the food
return;
}
this.RemoveFood();
Point[] newFood;
for (; ; ) {
int x = this.rnd.Next(this.numCellsX - 1);
int y = this.rnd.Next(this.numCellsY - 1);
newFood = new Point[4];
newFood[0] = new Point(x, y);
newFood[1] = new Point(x + 1, y);
newFood[2] = new Point(x, y + 1);
newFood[3] = new Point(x + 1, y + 1);
bool ok = true;
foreach (ASnake snake in this.snakes) {
if (snake.DoesIntersect(newFood)) {
ok = false;
break;
}
}
if (ok) {
foreach (Point pt in newFood) {
if (IsCrashObstacle(pt)) {
ok = false;
break;
}
}
}
if (ok) {
break;
}
}
this.food = newFood;
this.FillAndOutlineCells(this.food, Color.Gray, Color.Black);
}
public void RemoveFood() {
if (this.food == null) {
return;
}
for (int i = 0; i < this.food.Length; i++) {
this.ClearCell(this.food[i]);
}
this.food = null;
}
public bool EatFood() {
this.RemoveFood();
this.score++;
bool ret = false;
if (this.score >= this.level * 4) {
this.level++;
ret = true;
}
this.ShowScore();
return ret;
}
public void Msg(string msg) {
using (Font f = new Font("tahoma", 40)) {
this.screen.DrawString(msg, f, Brushes.Black, 30, 80);
}
}
public void ShowScore() {
this.screen.FillRectangle(Brushes.White, 0,
DeviceGraphics.ScreenYSize - scoreBoardHeight, DeviceGraphics.ScreenXSize, scoreBoardHeight - 20);
using (Font f = new Font("tahoma", 15)) {
string s = string.Format("Level: {0}", this.level);
this.screen.DrawString(s, f, Brushes.Black, 0, DeviceGraphics.ScreenYSize - scoreBoardHeight);
s = string.Format("Score: {0}", this.score);
this.screen.DrawString(s, f, Brushes.Black, DeviceGraphics.ScreenXSize >> 1, DeviceGraphics.ScreenYSize - scoreBoardHeight);
}
}
public int Level {
get {
return this.level;
}
}
private int Dist(Point a, Point b) {
int dx = a.X - b.Y;
int dy = a.Y - b.Y;
return Math.Max(Math.Abs(dx), Math.Abs(dy));
}
public void AddObstacle() {
Point[] obs;
for (; ; ) {
int x = this.rnd.Next(this.numCellsX - 1);
int y = this.rnd.Next(this.numCellsY - 1);
obs = new Point[4];
obs[0] = new Point(x, y);
obs[1] = new Point(x + 1, y);
obs[2] = new Point(x, y + 1);
obs[3] = new Point(x + 1, y + 1);
bool ok = true;
foreach (ASnake snake in this.snakes) {
if (snake.DoesIntersect(obs) || this.Dist(snake.Head, obs[0]) < 10) {
ok = false;
break;
}
}
if (ok) {
break;
}
}
using (HatchBrush brush = new HatchBrush(HatchStyle.DiagonalCross,Color.Black, Color.White)) {
this.FillAndOutlineCells(obs, brush, Color.Black);
}
this.obstacles.Add(obs);
if (this.obstacles.Count > this.Level * 2) {
// Remove an obstacle
obs = this.obstacles[0];
foreach (Point pt in obs) {
this.ClearCell(pt);
}
this.obstacles.RemoveAt(0);
}
}
}
}
================================================
FILE: System/Properties/AssemblyInfo.cs
================================================
/*using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("System")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Docobo")]
[assembly: AssemblyProduct("System")]
[assembly: AssemblyCopyright("Copyright © Docobo 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ac7fc7c3-9352-46c9-a145-9737bfab7e1a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
*/
================================================
FILE: System/System.Collections.Generic/Queue.cs
================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Collections.Generic {
public class Queue : IEnumerable, ICollection, IEnumerable {
T[] _array;
int _head;
int _tail;
int _size;
int _version;
private const int INITIAL_SIZE = 16;
public Queue() {
}
public Queue(int count) {
if (count < 0)
throw new ArgumentOutOfRangeException("count");
_array = new T[count];
}
public Queue(IEnumerable collection) {
if (collection == null)
throw new ArgumentNullException("collection");
foreach (T t in collection)
Enqueue(t);
}
public void Clear() {
if (_array != null)
Array.Clear(_array, 0, _array.Length);
_head = _tail = _size = 0;
_version++;
}
public bool Contains(T item) {
if (item == null) {
foreach (T t in this)
if (t == null)
return true;
} else {
foreach (T t in this)
if (item.Equals(t))
return true;
}
return false;
}
public void CopyTo(T[] array, int idx) {
if (array == null)
throw new ArgumentNullException();
if ((uint)idx > (uint)array.Length)
throw new ArgumentOutOfRangeException();
if (array.Length - idx < _size)
throw new ArgumentOutOfRangeException();
if (_size == 0)
return;
int contents_length = _array.Length;
int length_from_head = contents_length - _head;
Array.Copy(_array, _head, array, idx, Math.Min(_size, length_from_head));
if (_size > length_from_head)
Array.Copy(_array, 0, array,
idx + length_from_head,
_size - length_from_head);
}
void ICollection.CopyTo(Array array, int idx) {
if (array == null)
throw new ArgumentNullException();
if ((uint)idx < (uint)array.Length)
throw new ArgumentOutOfRangeException();
if (array.Length - idx < _size)
throw new ArgumentOutOfRangeException();
if (_size == 0)
return;
try {
int contents_length = _array.Length;
int length_from_head = contents_length - _head;
Array.Copy(_array, _head, array, idx, Math.Min(_size, length_from_head));
if (_size > length_from_head)
Array.Copy(_array, 0, array,
idx + length_from_head,
_size - length_from_head);
} catch (ArrayTypeMismatchException) {
throw new ArgumentException();
}
}
public T Dequeue() {
T ret = Peek();
// clear stuff out to make the GC happy
_array[_head] = default(T);
if (++_head == _array.Length)
_head = 0;
_size--;
_version++;
return ret;
}
public T Peek() {
if (_size == 0)
throw new InvalidOperationException();
return _array[_head];
}
public void Enqueue(T item) {
if (_array == null || _size == _array.Length)
SetCapacity(Math.Max(_size * 2, 4));
_array[_tail] = item;
if (++_tail == _array.Length)
_tail = 0;
_size++;
_version++;
}
public T[] ToArray() {
T[] t = new T[_size];
CopyTo(t, 0);
return t;
}
public void TrimExcess() {
if (_array != null && (_size < _array.Length * 0.9))
SetCapacity(_size);
}
void SetCapacity(int new_size) {
if (_array != null && new_size == _array.Length)
return;
if (new_size < _size)
throw new InvalidOperationException("shouldnt happen");
T[] new_data = new T[new_size];
if (_size > 0)
CopyTo(new_data, 0);
_array = new_data;
_tail = _size;
_head = 0;
_version++;
}
public int Count {
get { return _size; }
}
bool ICollection.IsSynchronized {
get { return false; }
}
object ICollection.SyncRoot {
get { return this; }
}
public Enumerator GetEnumerator() {
return new Enumerator(this);
}
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
public struct Enumerator : IEnumerator, IEnumerator, IDisposable {
const int NOT_STARTED = -2;
// this MUST be -1, because we depend on it in move next.
// we just decr the _size, so, 0 - 1 == FINISHED
const int FINISHED = -1;
Queue q;
int idx;
int ver;
internal Enumerator(Queue q) {
this.q = q;
idx = NOT_STARTED;
ver = q._version;
}
public void Dispose() {
idx = NOT_STARTED;
}
public bool MoveNext() {
if (ver != q._version)
throw new InvalidOperationException();
if (idx == NOT_STARTED)
idx = q._size;
return idx != FINISHED && --idx != FINISHED;
}
public T Current {
get {
if (idx < 0)
throw new InvalidOperationException();
return q._array[(q._size - 1 - idx + q._head) % q._array.Length];
}
}
void IEnumerator.Reset() {
if (ver != q._version)
throw new InvalidOperationException();
idx = NOT_STARTED;
}
object IEnumerator.Current {
get { return Current; }
}
}
}
}
================================================
FILE: System/System.Collections.Generic/Stack.cs
================================================
//
// System.Collections.Generic.Stack
//
// Authors:
// Martin Baulig (martin@ximian.com)
// Ben Maurer (bmaurer@ximian.com)
//
// (C) 2003, 2004 Novell, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
//using System.Runtime.InteropServices;
namespace System.Collections.Generic
{
public class Stack : IEnumerable , ICollection, IEnumerable
{
T [] _array;
int _size;
int _version;
private const int INITIAL_SIZE = 16;
public Stack ()
{
}
public Stack (int count)
{
if (count < 0)
throw new ArgumentOutOfRangeException ("count");
_array = new T [count];
}
public Stack (IEnumerable collection)
{
if (collection == null)
throw new ArgumentNullException ("collection");
ICollection col = collection as ICollection ;
if (col != null) {
_size = col.Count;
_array = new T [_size];
col.CopyTo (_array, 0);
} else {
foreach (T t in collection)
Push (t);
}
}
public void Clear ()
{
if (_array != null)
Array.Clear (_array, 0, _array.Length);
_size = 0;
_version ++;
}
public bool Contains (T t)
{
return _array != null && Array.IndexOf (_array, t, 0, _size) != -1;
}
public void CopyTo (T [] dest, int idx)
{
// this gets copied in the order that it is poped
if (_array != null) {
Array.Copy (_array, 0, dest, idx, _size);
Array.Reverse (dest, idx, _size);
}
}
public T Peek ()
{
if (_size == 0)
throw new InvalidOperationException ();
return _array [_size - 1];
}
public T Pop ()
{
if (_size == 0)
throw new InvalidOperationException ();
_version ++;
T popped = _array [--_size];
// clear stuff out to make the GC happy
_array [_size] = default(T);
return popped;
}
public void Push (T t)
{
if (_size == 0 || _size == _array.Length)
Array.Resize (ref _array, _size == 0 ? INITIAL_SIZE : 2 * _size);
_version ++;
_array [_size++] = t;
}
public T [] ToArray ()
{
T [] copy = new T [_size];
CopyTo (copy, 0);
return copy;
}
public void TrimExcess ()
{
if (_array != null && (_size < _array.Length * 0.9))
Array.Resize (ref _array, _size);
_version ++;
}
public int Count {
get { return _size; }
}
bool ICollection.IsSynchronized {
get { return false; }
}
object ICollection.SyncRoot {
get { return this; }
}
void ICollection.CopyTo (Array dest, int idx)
{
try {
if (_array != null) {
_array.CopyTo (dest, idx);
Array.Reverse (dest, idx, _size);
}
} catch (ArrayTypeMismatchException) {
throw new ArgumentException ();
}
}
public Enumerator GetEnumerator ()
{
return new Enumerator (this);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return GetEnumerator ();
}
IEnumerator IEnumerable.GetEnumerator ()
{
return GetEnumerator ();
}
public struct Enumerator : IEnumerator , IEnumerator, IDisposable {
const int NOT_STARTED = -2;
// this MUST be -1, because we depend on it in move next.
// we just decr the _size, so, 0 - 1 == FINISHED
const int FINISHED = -1;
Stack parent;
int idx;
int _version;
internal Enumerator (Stack t)
{
parent = t;
idx = NOT_STARTED;
_version = t._version;
}
public void Dispose ()
{
idx = NOT_STARTED;
}
public bool MoveNext ()
{
if (_version != parent._version)
throw new InvalidOperationException ();
if (idx == -2)
idx = parent._size;
return idx != FINISHED && -- idx != FINISHED;
}
public T Current {
get {
if (idx < 0)
throw new InvalidOperationException ();
return parent._array [idx];
}
}
void IEnumerator.Reset ()
{
if (_version != parent._version)
throw new InvalidOperationException ();
idx = NOT_STARTED;
}
object IEnumerator.Current {
get { return Current; }
}
}
}
}
================================================
FILE: System/System.ComponentModel/Win32Exception.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace System.ComponentModel {
public class Win32Exception : ExternalException {
private int nativeError = 0;
public Win32Exception() : base("Win32 exception", 0) { }
public Win32Exception(int err)
: base("Win32 exception", err) {
this.nativeError = err;
}
public Win32Exception(int err, string msg)
: base(msg, err) {
this.nativeError = err;
}
public int NativeErrorCode {
get {
return this.nativeError;
}
}
}
}
================================================
FILE: System/System.Net/Dns.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.CompilerServices;
namespace System.Net {
public static class Dns {
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static int[] Internal_GetHostEnt(string dnsName, out string hostName);
public static IPHostEntry GetHostEntry(string hostNameOrAddress) {
IPAddress ipAddr;
bool isIPAddr = IPAddress.TryParse(hostNameOrAddress, out ipAddr);
if (!isIPAddr) {
string hostName;
int[] ips = Internal_GetHostEnt(hostNameOrAddress, out hostName);
IPAddress[] addresses = new IPAddress[ips.Length];
for (int i = 0; i < ips.Length; i++) {
addresses[i] = new IPAddress((uint)ips[i]);
}
IPHostEntry hostEnt = new IPHostEntry();
hostEnt.AddressList = addresses;
hostEnt.HostName = hostName;
return hostEnt;
} else {
return GetHostEntry(ipAddr);
}
}
public static IPHostEntry GetHostEntry(IPAddress addr) {
if (addr == null) {
throw new ArgumentNullException("address");
}
throw new NotImplementedException();
}
}
}
================================================
FILE: System/System.Net/EndPoint.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
namespace System.Net {
public abstract class EndPoint {
protected EndPoint() { }
public virtual EndPoint Create(SocketAddress address) {
throw new NotSupportedException();
}
public virtual AddressFamily AddressFamily {
get {
throw new NotSupportedException();
}
}
public virtual SocketAddress Serialize() {
throw new NotSupportedException();
}
}
}
================================================
FILE: System/System.Net/IPAddress.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
namespace System.Net {
public class IPAddress {
public static readonly IPAddress Any = new IPAddress(0);
public static readonly IPAddress Broadcast = IPAddress.Parse("255.255.255.255");
public static readonly IPAddress Loopback = IPAddress.Parse("127.0.0.1");
public static readonly IPAddress None = IPAddress.Parse("255.255.255.255");
public static IPAddress Parse(string ip) {
IPAddress addr;
if (TryParse(ip, out addr)) {
return addr;
}
throw new FormatException("An invalid IP address was specified");
}
public static bool TryParse(string ip, out IPAddress address) {
// Only handle IPv4
if (ip == null) {
throw new ArgumentNullException("ip");
}
if (ip.Length == 0 || ip == " ") {
address = new IPAddress(0);
return true;
}
string[] parts = ip.Split('.');
if (parts.Length != 4) {
address = null;
return false;
}
uint a = 0;
for (int i = 0; i < 4; i++) {
int val;
if (!int.TryParse(parts[i], out val)) {
address = null;
return false;
}
a |= ((uint)val) << (i << 3);
}
address = new IPAddress((long)a);
return true;
}
private uint ip4Address;
private AddressFamily family = AddressFamily.InterNetwork;
public IPAddress(long addr) {
this.ip4Address = (uint)addr;
}
public AddressFamily AddressFamily {
get {
return this.family;
}
}
internal uint InternalIPv4Address {
get { return this.ip4Address; }
}
public override int GetHashCode() {
return (int)this.ip4Address;
}
public override bool Equals(object obj) {
IPAddress a = obj as IPAddress;
return a != null && a.ip4Address == this.ip4Address;
}
public override string ToString() {
return string.Format("{0}.{1}.{2}.{3}",
this.ip4Address & 0xff, (this.ip4Address >> 8) & 0xff,
(this.ip4Address >> 16) & 0xff, this.ip4Address >> 24);
}
}
}
================================================
FILE: System/System.Net/IPEndPoint.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
namespace System.Net {
public class IPEndPoint : EndPoint {
public const int MinPort = 0;
public const int MaxPort = 0xffff;
public IPAddress address;
public int port;
public IPEndPoint(IPAddress addr, int port) {
if (addr == null) {
throw new ArgumentNullException();
}
this.Address = addr;
this.Port = port;
}
public IPEndPoint(long addr, int port) : this(new IPAddress(addr), port) { }
public IPAddress Address {
get {
return this.address;
}
set {
this.address = value;
}
}
public int Port {
get {
return this.port;
}
set {
if (value < MinPort || value > MaxPort) {
throw new ArgumentOutOfRangeException("Port");
}
this.port = value;
}
}
public override AddressFamily AddressFamily {
get {
return this.address.AddressFamily;
}
}
public override EndPoint Create(SocketAddress sockaddr) {
if (sockaddr.Size < 8) {
return null;
}
if (sockaddr.Family != AddressFamily.InterNetwork) {
// Only support IP4
return null;
}
int port = (((int)sockaddr[2]) << 8) | (int)sockaddr[3];
long address = (((long)sockaddr[7]) << 24) |
(((long)sockaddr[6]) << 16) |
(((long)sockaddr[5]) << 8) |
(long)sockaddr[4];
return new IPEndPoint(address, port);
}
public override SocketAddress Serialize() {
SocketAddress sockaddr = null;
switch (this.address.AddressFamily) {
case AddressFamily.InterNetwork:
// .net produces a 16 byte buffer, even though
// only 8 bytes are used. I guess its just a
// holdover from struct sockaddr padding.
sockaddr = new SocketAddress(AddressFamily.InterNetwork, 16);
// bytes 2 and 3 store the port, the rest
// stores the address
sockaddr[2] = (byte)((this.port >> 8) & 0xff);
sockaddr[3] = (byte)(this.port & 0xff);
uint addr = this.address.InternalIPv4Address;
sockaddr[4] = (byte)(addr & 0xff);
sockaddr[5] = (byte)((addr >> 8) & 0xff);
sockaddr[6] = (byte)((addr >> 16) & 0xff);
sockaddr[7] = (byte)((addr >> 24) & 0xff);
break;
}
return sockaddr;
}
public override string ToString() {
return this.address.ToString() + ":" + this.port.ToString();
}
public override int GetHashCode() {
return this.address.GetHashCode() + this.port;
}
public override bool Equals(Object obj) {
IPEndPoint p = obj as IPEndPoint;
return p != null &&
p.port == this.port &&
p.address.Equals(this.address);
}
}
}
================================================
FILE: System/System.Net/IPHostEntry.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net {
public class IPHostEntry {
private IPAddress[] addressList;
private String[] aliases;
private String hostName;
public IPHostEntry() {
}
public IPAddress[] AddressList {
get { return addressList; }
set { addressList = value; }
}
public string[] Aliases {
get { return aliases; }
set { aliases = value; }
}
public string HostName {
get { return hostName; }
set { hostName = value; }
}
}
}
================================================
FILE: System/System.Net/SocketAddress.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
namespace System.Net {
public class SocketAddress {
private byte[] data;
public SocketAddress(AddressFamily family, int size) {
if (size < 2) {
throw new ArgumentOutOfRangeException("size is too small");
}
data = new byte[size];
data[0] = (byte)family;
data[1] = (byte)((int)family >> 8);
}
public SocketAddress(AddressFamily family) : this(family, 32) { }
public AddressFamily Family {
get {
return (AddressFamily)(data[0] + (data[1] << 8));
}
}
public int Size {
get {
return data.Length;
}
}
public byte this[int offset] {
get {
return (data[offset]);
}
set {
data[offset] = value;
}
}
public override string ToString() {
string af = ((AddressFamily)data[0]).ToString();
int size = data.Length;
string ret = af + ":" + size + ":{";
for (int i = 2; i < size; i++) {
int val = (int)data[i];
ret = ret + val;
if (i < size - 1) {
ret = ret + ",";
}
}
ret = ret + "}";
return (ret);
}
public override bool Equals(object obj) {
if (obj is System.Net.SocketAddress &&
((System.Net.SocketAddress)obj).data.Length == data.Length) {
byte[] otherData = ((System.Net.SocketAddress)obj).data;
for (int i = 0; i < data.Length; i++)
if (otherData[i] != data[i])
return false;
return true;
}
return false;
}
public override int GetHashCode() {
int code = 0;
for (int i = 0; i < data.Length; i++)
code += data[i] + i;
return code;
}
}
}
================================================
FILE: System/System.Net.Sockets/AddressFamily.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net.Sockets {
public enum AddressFamily {
Unknown = -1,
Unspecified = 0,
Unix = 1,
InterNetwork = 2,
ImpLink = 3,
Pup = 4,
Chaos = 5,
NS = 6,
Ipx = 6,
Iso = 7,
Osi = 7,
Ecma = 8,
DataKit = 9,
Ccitt = 10,
Sna = 11,
DecNet = 12,
DataLink = 13,
Lat = 14,
HyperChannel = 15,
AppleTalk = 16,
NetBios = 17,
VoiceView = 18,
FireFox = 19,
Banyan = 21,
Atm = 22,
InterNetworkV6 = 23,
Cluster = 24,
Ieee12844 = 25,
Irda = 26,
NetworkDesigners = 28,
Max = 29,
}
}
================================================
FILE: System/System.Net.Sockets/ProtocolType.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net.Sockets {
public enum ProtocolType {
IP = 0,
Icmp = 1,
Igmp = 2,
Ggp = 3,
Tcp = 6,
Pup = 12,
Udp = 17,
Idp = 22,
IPv6 = 41,
ND = 77,
Raw = 255,
Unspecified = 0,
Ipx = 1000,
Spx = 1256,
SpxII = 1257,
Unknown = -1,
IPv4 = 4,
IPv6RoutingHeader = 43,
IPv6FragmentHeader = 44,
IPSecEncapsulatingSecurityPayload = 50,
IPSecAuthenticationHeader = 51,
IcmpV6 = 58,
IPv6NoNextHeader = 59,
IPv6DestinationOptions = 60,
IPv6HopByHopOptions = 0,
}
}
================================================
FILE: System/System.Net.Sockets/Socket.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.CompilerServices;
namespace System.Net.Sockets {
public class Socket : IDisposable {
#region Internal Methods
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static IntPtr Internal_CreateSocket(int family, int type, int proto, out int error);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static void Internal_Close(IntPtr native);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static void Internal_Bind(IntPtr native, uint address, int port, out int error);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static void Internal_Listen(IntPtr native, int backLog, out int error);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static IntPtr Internal_Accept(IntPtr native, out int error);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static void Internal_Connect(IntPtr native, uint address, int port, out int error);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static int Internal_Receive(IntPtr native, byte[] buffer, int offset, int size, int flags, out int error);
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static int Internal_Send(IntPtr native, byte[] buffer, int offset, int size, int flags, out int error);
#endregion
private IntPtr native;
private AddressFamily family;
private SocketType type;
private ProtocolType proto;
public Socket(AddressFamily family, SocketType type, ProtocolType proto) {
this.family = family;
this.type = type;
this.proto = proto;
int error;
this.native = Internal_CreateSocket((int)family, (int)type, (int)proto, out error);
this.CheckError(error);
}
private Socket(AddressFamily family, SocketType type, ProtocolType proto, IntPtr native) {
this.family = family;
this.type = type;
this.proto = proto;
this.native = native;
}
~Socket() {
this.Dispose(false);
}
private void Dispose(bool disposing) {
if (this.native != IntPtr.Zero) {
Internal_Close(this.native);
this.native = IntPtr.Zero;
if (disposing) {
GC.SuppressFinalize(this);
}
}
}
void IDisposable.Dispose() {
this.Dispose(true);
}
public void Close() {
this.Dispose(true);
}
private void CheckDisposed() {
if (this.native == IntPtr.Zero) {
throw new ObjectDisposedException(this.GetType().ToString());
}
}
private void CheckError(int error) {
if (error != 0) {
Console.WriteLine("SOCKET_ERROR {0}", error);
throw new SocketException(error);
}
}
private void GetIPInfo(EndPoint ep, out uint addr, out int port) {
if (ep.AddressFamily != AddressFamily.InterNetwork) {
throw new ArgumentException("EndPoint", "Can only handle IPv4 addresses");
}
SocketAddress sockAddr = ep.Serialize();
port = (((int)sockAddr[2]) << 8) | sockAddr[3];
addr = ((((uint)sockAddr[7]) << 24) | (((uint)sockAddr[6]) << 16) |
(((uint)sockAddr[5]) << 8) | (uint)sockAddr[4]);
}
public void Bind(EndPoint epLocal) {
this.CheckDisposed();
if (epLocal == null) {
throw new ArgumentNullException("epLocal");
}
int port;
uint addr;
this.GetIPInfo(epLocal, out addr, out port);
int error;
Internal_Bind(this.native, addr, port, out error);
this.CheckError(error);
}
public void Listen(int backLog) {
this.CheckDisposed();
int error;
Internal_Listen(this.native, backLog, out error);
this.CheckError(error);
}
public Socket Accept() {
this.CheckDisposed();
int error;
IntPtr socket = Internal_Accept(this.native, out error);
this.CheckError(error);
return new Socket(this.family, this.type, this.proto, socket);
}
public void Connect(EndPoint epRemote) {
this.CheckDisposed();
if (epRemote == null) {
throw new ArgumentNullException("epRemote");
}
int port;
uint addr;
this.GetIPInfo(epRemote, out addr, out port);
int error;
Internal_Connect(this.native, addr, port, out error);
this.CheckError(error);
}
public int Send(byte[] buffer) {
return this.Send(buffer, 0, buffer.Length, SocketFlags.None);
}
public int Send(byte[] buffer, SocketFlags flags) {
return this.Send(buffer, 0, buffer.Length, flags);
}
public int Send(byte[] buffer, int size, SocketFlags flags) {
return this.Send(buffer, 0, size, flags);
}
public int Send(byte[] buffer, int offset, int size, SocketFlags flags) {
this.CheckDisposed();
if (buffer == null) {
throw new ArgumentNullException("buffer");
}
if (offset < 0 || size < 0 || offset + size > buffer.Length) {
throw new ArgumentOutOfRangeException();
}
int error;
int ret = Internal_Send(this.native, buffer, offset, size, (int)flags, out error);
this.CheckError(error);
return ret;
}
public int Receive(byte[] buffer) {
return this.Receive(buffer, 0, buffer.Length, SocketFlags.None);
}
public int Receive(byte[] buffer, SocketFlags flags) {
return this.Receive(buffer, 0, buffer.Length, flags);
}
public int Receive(byte[] buffer, int size, SocketFlags flags) {
return this.Receive(buffer, 0, size, flags);
}
public int Receive(byte[] buffer, int offset, int size, SocketFlags flags) {
this.CheckDisposed();
if (buffer == null) {
throw new ArgumentNullException("buffer");
}
if (offset < 0 || size < 0 || offset + size > buffer.Length) {
throw new ArgumentOutOfRangeException();
}
int error;
int ret = Internal_Receive(this.native, buffer, offset, size, (int)flags, out error);
this.CheckError(error);
return ret;
}
}
}
================================================
FILE: System/System.Net.Sockets/SocketException.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace System.Net.Sockets {
public class SocketException : Win32Exception {
public SocketException(int error) : base(error) { }
public override int ErrorCode {
get {
return NativeErrorCode;
}
}
}
}
================================================
FILE: System/System.Net.Sockets/SocketFlags.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net.Sockets {
[Flags]
public enum SocketFlags {
None = 0x00000000,
OutOfBand = 0x00000001,
Peek = 0x00000002,
DontRoute = 0x00000004,
MaxIOVectorLength = 0x00000010,
Truncated = 0x00000100,
ControlDataTruncated = 0x00000200,
Broadcast = 0x00000400,
Multicast = 0x00000800,
Partial = 0x00008000,
}
}
================================================
FILE: System/System.Net.Sockets/SocketOptionLevel.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net.Sockets {
public enum SocketOptionLevel {
Socket = 65535,
IP = 0,
IPv6 = 41,
Tcp = 6,
Udp = 17,
}
}
================================================
FILE: System/System.Net.Sockets/SocketOptionName.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net.Sockets {
public enum SocketOptionName {
Debug = 1,
AcceptConnection = 2,
ReuseAddress = 4,
KeepAlive = 8,
DontRoute = 16,
Broadcast = 32,
UseLoopback = 64,
Linger = 128,
OutOfBandInline = 256,
DontLinger = -129,
ExclusiveAddressUse = -5,
SendBuffer = 4097,
ReceiveBuffer = 4098,
SendLowWater = 4099,
ReceiveLowWater = 4100,
SendTimeout = 4101,
ReceiveTimeout = 4102,
Error = 4103,
Type = 4104,
MaxConnections = 2147483647,
IPOptions = 1,
HeaderIncluded = 2,
TypeOfService = 3,
IpTimeToLive = 4,
MulticastInterface = 9,
MulticastTimeToLive = 10,
MulticastLoopback = 11,
AddMembership = 12,
DropMembership = 13,
DontFragment = 14,
AddSourceMembership = 15,
DropSourceMembership = 16,
BlockSource = 17,
UnblockSource = 18,
PacketInformation = 19,
NoDelay = 1,
BsdUrgent = 2,
Expedited = 2,
NoChecksum = 1,
ChecksumCoverage = 20,
HopLimit = 21,
UpdateAcceptContext = 28683,
UpdateConnectContext = 28688,
}
}
================================================
FILE: System/System.Net.Sockets/SocketType.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Net.Sockets {
public enum SocketType {
Stream = 1,
Dgram = 2,
Raw = 3,
Rdm = 4,
Seqpacket = 5,
Unknown = -1,
}
}
================================================
FILE: System/System.csproj
================================================
Debug
AnyCPU
9.0.30729
2.0
{388F5D73-0211-4A64-B501-92CDC4E32ACF}
Library
Properties
System
System
3.5
false
v2.0
publish\
true
Disk
false
Foreground
7
Days
false
false
true
0
1.0.0.%2a
false
true
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
512
true
AllRules.ruleset
pdbonly
true
bin\Release\
TRACE
prompt
4
512
true
AllRules.ruleset
False
.NET Framework 3.5 SP1 Client Profile
false
False
.NET Framework 2.0 %28x86%29
true
False
.NET Framework 3.0 %28x86%29
false
False
.NET Framework 3.5
false
False
.NET Framework 3.5 SP1
false
{6a77a7c0-fb66-4caa-94ee-142dba20655d}
corlib
xcopy $(TargetPath) $(SolutionDir)Builds\$(ConfigurationName)\ /Y
================================================
FILE: System.Core/Properties/AssemblyInfo.cs
================================================
//using System.Reflection;
//using System.Runtime.CompilerServices;
//using System.Runtime.InteropServices;
//// General Information about an assembly is controlled through the following
//// set of attributes. Change these attribute values to modify the information
//// associated with an assembly.
//[assembly: AssemblyTitle("System.Core")]
//[assembly: AssemblyDescription("")]
//[assembly: AssemblyConfiguration("")]
//[assembly: AssemblyCompany("")]
//[assembly: AssemblyProduct("System.Core")]
//[assembly: AssemblyCopyright("Copyright © 2012")]
//[assembly: AssemblyTrademark("")]
//[assembly: AssemblyCulture("")]
//// Setting ComVisible to false makes the types in this assembly not visible
//// to COM components. If you need to access a type in this assembly from
//// COM, set the ComVisible attribute to true on that type.
//[assembly: ComVisible(false)]
//// The following GUID is for the ID of the typelib if this project is exposed to COM
//[assembly: Guid("60bd1f97-8a45-4bdb-9b4e-344f479dd643")]
//// Version information for an assembly consists of the following four values:
////
//// Major Version
//// Minor Version
//// Build Number
//// Revision
////
//// You can specify all the values or you can default the Build and Revision Numbers
//// by using the '*' as shown below:
//// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
================================================
FILE: System.Core/System/Action.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace System {
public delegate void Action(T arg);
public delegate void Action(T1 arg1, T2 arg2);
public delegate void Action(T1 arg1, T2 arg2, T3 arg3);
public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
}
================================================
FILE: System.Core/System/Func.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace System {
public delegate TResult Func();
public delegate TResult Func(T arg);
public delegate TResult Func(T1 arg1, T2 arg2);
public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3);
public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
}
================================================
FILE: System.Core/System.Collections.Generic/HashSet.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace System.Collections.Generic {
public class HashSet : ICollection, IEnumerable, IEnumerable {
public struct Enumerator : IEnumerator, IEnumerator, IDisposable {
internal Enumerator(HashSet hashSet) {
this.en = hashSet.dict.Keys.GetEnumerator();
}
private IEnumerator en;
public T Current {
get {
return this.en.Current;
}
}
public void Dispose() {
}
object IEnumerator.Current {
get {
return this.en.Current;
}
}
public bool MoveNext() {
return this.en.MoveNext();
}
public void Reset() {
this.en.Reset();
}
}
private Dictionary dict;
public HashSet() {
this.dict = new Dictionary();
}
public HashSet(IEnumerable collection) : this(collection, null) { }
public HashSet(IEqualityComparer comparer) {
this.dict = new Dictionary(comparer);
}
public HashSet(IEnumerable collection, IEqualityComparer comparer) {
if (collection == null) {
throw new ArgumentNullException();
}
this.dict = new Dictionary(comparer);
foreach (T item in collection) {
this.dict[item] = null;
}
}
public bool Add(T item) {
bool ret = !this.dict.ContainsKey(item);
this.dict[item] = null;
return ret;
}
public void Clear() {
this.dict.Clear();
}
public bool Contains(T item) {
return this.dict.ContainsKey(item);
}
public void CopyTo(T[] array) {
throw new NotImplementedException();
}
public void CopyTo(T[] array, int arrayIndex) {
throw new NotImplementedException();
}
public void CopyTo(T[] array, int arrayIndex, int count) {
throw new NotImplementedException();
}
public Enumerator GetEnumerator() {
return new Enumerator(this);
}
public bool Remove(T item) {
return this.dict.Remove(item);
}
public IEqualityComparer Comparer {
get {
return this.dict.Comparer;
}
}
public int Count {
get {
return this.dict.Count;
}
}
#region Interface Members
void ICollection.Add(T item) {
this.Add(item);
}
bool ICollection.IsReadOnly {
get {
return false;
}
}
IEnumerator IEnumerable.GetEnumerator() {
return new Enumerator(this);
}
IEnumerator IEnumerable.GetEnumerator() {
return new Enumerator(this);
}
#endregion
}
}
================================================
FILE: System.Core/System.Core.csproj
================================================
Debug
AnyCPU
{429C3225-3A36-427A-A44E-2AA3563FCD6D}
Library
Properties
System.Core
System.Core
v2.0
512
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
512
true
pdbonly
true
bin\Release\
TRACE
prompt
4
512
true
{6a77a7c0-fb66-4caa-94ee-142dba20655d}
corlib
{388f5d73-0211-4a64-b501-92cdc4e32acf}
System
xcopy $(TargetPath) $(SolutionDir)Builds\$(ConfigurationName)\ /Y
================================================
FILE: System.Core/System.Linq/Enumerable.cs
================================================
// Copyright (c) 2009 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace System.Linq {
public static class Enumerable {
private static class Funcs {
public static readonly Func True = x => true;
public static readonly Func Identity = x => x;
}
#region Aggregate
public static T Aggregate(this IEnumerable source, Func func) {
Check(source, func);
using (var en = source.GetEnumerator()) {
if (!en.MoveNext()) {
throw new InvalidOperationException();
}
T value = en.Current;
while (en.MoveNext()) {
value = func(value, en.Current);
}
return value;
}
}
public static TAcc Aggregate(this IEnumerable source, TAcc seed, Func func) {
return source.Aggregate(seed, func, Funcs.Identity);
}
public static TResult Aggregate
(this IEnumerable source, TAcc seed, Func func, Func resultSelector) {
Check(source, func, resultSelector);
foreach (var item in source) {
seed = func(seed, item);
}
return resultSelector(seed);
}
#endregion
#region All
public static bool All(this IEnumerable source, Func predicate) {
Check(source);
foreach (T item in source) {
if (!predicate(item)) {
return false;
}
}
return true;
}
#endregion
#region Any
public static bool Any(this IEnumerable source) {
return source.Any(Funcs.True);
}
public static bool Any(this IEnumerable source, Func predicate) {
Check(source, predicate);
foreach (T item in source) {
if (predicate(item)) {
return true;
}
}
return false;
}
#endregion
#region Average
public static double Average(this IEnumerable source) {
return Avg(source, (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static double? Average(this IEnumerable source) {
return AvgNullable(source, (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static double Average(this IEnumerable source) {
return Avg(source, (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static double? Average(this IEnumerable source) {
return AvgNullable(source, (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static float Average(this IEnumerable source) {
return Avg(source, (a, v) => a + v, (a, c) => a / c);
}
public static float? Average(this IEnumerable source) {
return AvgNullable(source, (a, v) => a + v, (a, c) => a / c);
}
public static double Average(this IEnumerable source) {
return Avg(source, (a, v) => a + v, (a, c) => a / c);
}
public static double? Average(this IEnumerable source) {
return AvgNullable(source, (a, v) => a + v, (a, c) => a / c);
}
public static Decimal Average(this IEnumerable source) {
throw new NotImplementedException();
}
public static Decimal? Average(this IEnumerable source) {
throw new NotImplementedException();
}
public static double Average(this IEnumerable source, Func selector) {
return Avg(source.Select(selector), (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static double? Average(this IEnumerable source, Func selector) {
return AvgNullable(source.Select(selector), (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static double Average(this IEnumerable source, Func selector) {
return Avg(source.Select(selector), (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static double? Average(this IEnumerable source, Func selector) {
return AvgNullable(source.Select(selector), (a, v) => a + v, (a, c) => (double)a / (double)c);
}
public static float Average(this IEnumerable source, Func selector) {
return Avg(source.Select(selector), (a, v) => a + v, (a, c) => a / c);
}
public static float? Average(this IEnumerable source, Func selector) {
return AvgNullable(source.Select(selector), (a, v) => a + v, (a, c) => a / c);
}
public static double Average(this IEnumerable source, Func selector) {
return Avg(source.Select(selector), (a, v) => a + v, (a, c) => a / c);
}
public static double? Average(this IEnumerable source, Func selector) {
return AvgNullable(source.Select(selector), (a, v) => a + v, (a, c) => a / c);
}
public static Decimal Average(this IEnumerable source, Func selector) {
throw new NotImplementedException();
}
public static Decimal? Average(this IEnumerable source, Func selector) {
throw new NotImplementedException();
}
private static TRes Avg(IEnumerable source,
Func accFn, Func resFn) {
Check(source);
TAcc acc = default(TAcc);
int counter = 0;
foreach (var item in source) {
acc = accFn(acc, item);
counter++;
}
if (counter == 0) {
throw new InvalidOperationException();
}
return resFn(acc, counter);
}
private static TRes? AvgNullable(IEnumerable source,
Func accFn, Func resFn)
where T : struct
where TRes : struct {
Check(source);
TAcc acc = default(TAcc);
int counter = 0;
foreach (var item in source) {
if (item != null) {
acc = accFn(acc, item.Value);
counter++;
}
}
if (counter == 0) {
return null;
}
return resFn(acc, counter);
}
#endregion
#region AsEnumerable
public static IEnumerable AsEnumerable(this IEnumerable source) {
return source;
}
#endregion
#region Cast
public static IEnumerable Cast(IEnumerable source) {
Check(source);
return CastIterator(source);
}
private static IEnumerable CastIterator(IEnumerable source) {
foreach (T item in source) {
yield return item;
}
}
#endregion
#region Concat
public static IEnumerable Concat
(this IEnumerable first, IEnumerable second) {
Check(first, second);
return ConcatIterator(first, second);
}
private static IEnumerable ConcatIterator
(IEnumerable first, IEnumerable second) {
foreach (T item in first) {
yield return item;
}
foreach (T item in second) {
yield return item;
}
}
#endregion
#region Contains
public static bool Contains(this IEnumerable source, T value) {
return source.Contains(value, null);
}
public static bool Contains
(this IEnumerable source, T value, IEqualityComparer comparer) {
Check(source);
if (comparer == null) {
comparer = EqualityComparer.Default;
}
foreach (T item in source) {
if (comparer.Equals(item, value)) {
return true;
}
}
return false;
}
#endregion
#region Count, LongCount
public static int Count(this IEnumerable source) {
Check(source);
ICollection collection = source as ICollection;
if (collection != null) {
return collection.Count;
} else {
return source.Count(Funcs.True);
}
}
public static int Count(this IEnumerable source, Func predicate) {
Check(source, predicate);
int count = 0;
foreach (T item in source) {
if (predicate(item)) {
count++;
}
}
return count;
}
public static long LongCount(this IEnumerable source) {
return (long)Count(source);
}
public static long LongCount(this IEnumerable source, Func predicate) {
return (long)Count(source, predicate);
}
#endregion
#region DefaultIfEmpty
public static IEnumerable DefaultIfEmpty(this IEnumerable source) {
return source.DefaultIfEmpty(default(T));
}
public static IEnumerable DefaultIfEmpty(this IEnumerable source, T defaultValue) {
Check(source);
return DefaultIfEmptyIterator(source, defaultValue);
}
private static IEnumerable DefaultIfEmptyIterator(IEnumerable source, T defaultValue) {
using (IEnumerator en = source.GetEnumerator()) {
if (en.MoveNext()) {
do {
yield return en.Current;
} while (en.MoveNext());
} else {
yield return defaultValue;
}
}
}
#endregion
#region Distinct
public static IEnumerable Distinct(this IEnumerable source) {
return Distinct(source, null);
}
public static IEnumerable Distinct(this IEnumerable source, IEqualityComparer comparer) {
return DistinctIterator(source, comparer);
}
private static IEnumerable DistinctIterator(IEnumerable source, IEqualityComparer comparer) {
HashSet h = new HashSet(comparer);
foreach (T item in source) {
if (h.Add(item)) {
yield return item;
}
}
}
#endregion
#region ElementAt, ElementAtOrDefault
public static T ElementAt(IEnumerable source, int index) {
return ElementAt(source, index, false);
}
public static T ElementAtOrDefault(IEnumerable source, int index) {
return ElementAt(source, index, true);
}
private static T ElementAt(IEnumerable source, int index, bool orDefault) {
Check(source);
if (index >= 0) {
IList list = source as IList;
if (list != null) {
if (index < list.Count) {
return list[index];
}
} else {
int count = 0;
foreach (T item in source) {
if (count == index) {
return item;
}
count++;
}
}
}
if (orDefault) {
return default(T);
} else {
throw new ArgumentOutOfRangeException();
}
}
#endregion
#region Empty
public static IEnumerable Empty() {
return new T[0];
}
#endregion
#region Except
public static IEnumerable Except(this IEnumerable first, IEnumerable second) {
return Except(first, second, null);
}
public static IEnumerable Except
(this IEnumerable first, IEnumerable second, IEqualityComparer comparer) {
Check(first, second);
return ExceptIterator(first, second, comparer);
}
private static IEnumerable ExceptIterator
(IEnumerable first, IEnumerable second, IEqualityComparer comparer) {
HashSet h = new HashSet(second, comparer);
foreach (T item in first) {
if (!h.Contains(item)) {
yield return item;
}
}
}
#endregion
#region First, FirstOrDefault, Single, SingleOrDefault
private static T FirstSingle(IEnumerable source, Func predicate, bool single, bool retDefault) {
Check(source, predicate);
using (var en = source.Where(predicate).GetEnumerator()) {
if (en.MoveNext()) {
T value = en.Current;
if (single) {
if (en.MoveNext()) {
throw new InvalidOperationException();
}
}
return value;
} else {
if (retDefault) {
return default(T);
} else {
throw new InvalidOperationException();
}
}
}
}
public static T First(this IEnumerable source) {
return FirstSingle(source, Funcs.True, false, false);
}
public static T First(this IEnumerable source, Func predicate) {
return FirstSingle(source, predicate, false, false);
}
public static T FirstOrDefault(this IEnumerable source) {
return FirstSingle(source, Funcs.True, false, true);
}
public static T FirstOrDefault(this IEnumerable source, Func predicate) {
return FirstSingle(source, predicate, false, true);
}
public static T Single(this IEnumerable source) {
return FirstSingle(source, Funcs.True, true, false);
}
public static T Single(this IEnumerable source, Func predicate) {
return FirstSingle(source, predicate, true, false);
}
public static T SingleOrDefault(this IEnumerable source) {
return FirstSingle(source, Funcs.True, true, true);
}
public static T SingleOrDefault(this IEnumerable source, Func