示例#1
0
文件: Integer.cs 项目: Frassle/Ibasa
        void Operations()
        {
            WriteLine("#region Operations");

            WriteLine("/// <summary>");
            WriteLine("/// Returns the identity of a specified integer.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">An integer.</param>");
            WriteLine("/// <returns>The identity of value.</returns>");
            WriteLine("public static {0} operator +({0} value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return value;");
            Dedent();
            WriteLine("}");

            var neg_result = new Integer(Size, true);

            WriteLine("/// <summary>");
            WriteLine("/// Returns the additive inverse of a specified integer.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">An integer.</param>");
            WriteLine("/// <returns>The negative of value.</returns>");
            WriteLine("public static {0} operator -({1} value)", neg_result, Name);
            WriteLine("{");
            Indent();
            WriteLine("return ({0})(~value + {1}.One);", neg_result, Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Adds two integers and returns the result.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The first value to add.</param>");
            WriteLine("/// <param name=\"right\">The second value to add.</param>");
            WriteLine("/// <returns>The sum of left and right.</returns>");
            WriteLine("public static {0} operator +({0} left, {0} right)", Name);
            Indent("{");
            WriteLine("unsafe");
            Indent("{");
            WriteLine("uint* parts = stackalloc uint[{0}];", Parts.Length);
            WriteLine("ulong carry = 0;");
            WriteLine("ulong n = 0;");
            for (int i = 0; i < Parts.Length; ++i)
            {
                WriteLine("n = carry + left.{0} + right.{0};", Parts[i]);
                WriteLine("parts[{0}] = (uint)n;", i);
                WriteLine("carry = n >> 32;");
            }

            WriteLine("return new {0}({1});", Name,
                string.Join(", ", Enumerable.Range(0, Parts.Length).Select(i => string.Format("parts[{0}]", i))));

            Dedent("}");
            Dedent("}");

            WriteLine("/// <summary>");
            WriteLine("/// Subtracts one integer from another and returns the result.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The value to subtract from (the minuend).</param>");
            WriteLine("/// <param name=\"right\">The value to subtract (the subtrahend).</param>");
            WriteLine("/// <returns>The result of subtracting right from left (the difference).</returns>");
            WriteLine("public static {0} operator -({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return left + ({0})(-right);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Returns the product of a integer and scalar.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The first integer to multiply.</param>");
            WriteLine("/// <param name=\"right\">The second integer to multiply.</param>");
            WriteLine("/// <returns>The product of the left and right parameters.</returns>");
            WriteLine("public static {0} operator *({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("throw new System.NotImplementedException(\"operator *\");"); 
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Divides a integer by a scalar and returns the result.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The integer to be divided (the dividend).</param>");
            WriteLine("/// <param name=\"right\">The integer to divide by (the divisor).</param>");
            WriteLine("/// <returns>The result of dividing left by right (the quotient).</returns>");
            WriteLine("public static {0} operator /({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("throw new System.NotImplementedException(\"operator /\");"); 
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Divides a integer by a scalar and returns the remainder.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The integer to be divided (the dividend).</param>");
            WriteLine("/// <param name=\"right\">The integer to divide by (the divisor).</param>");
            WriteLine("/// <returns>The modulus from dividing left by right (the remainder).</returns>");
            WriteLine("public static {0} operator %({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("throw new System.NotImplementedException(\"operator %\");"); 
            Dedent();
            WriteLine("}"); 
            
            WriteLine("/// <summary>");
            WriteLine("/// Returns the bitwise not of an integer.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">An integer.</param>");
            WriteLine("/// <returns>The bitwise not of value.</returns>");
            WriteLine("public static {0} operator ~({0} value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}({1});", Name, string.Join(", ",
                Parts.Select(part => string.Format("~value.{0}", part))));
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Returns the bitwise AND of two integers.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The first integer.</param>");
            WriteLine("/// <param name=\"right\">The second integer.</param>");
            WriteLine("/// <returns>The bitwise AND of left and right.</returns>");
            WriteLine("public static {0} operator &({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}({1});", Name, string.Join(", ",
                Parts.Select(part => string.Format("left.{0} & right.{0}", part))));
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Returns the bitwise OR of two integers.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The first integer.</param>");
            WriteLine("/// <param name=\"right\">The second integer.</param>");
            WriteLine("/// <returns>The bitwise OR of left and right.</returns>");
            WriteLine("public static {0} operator |({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}({1});", Name, string.Join(", ",
                Parts.Select(part => string.Format("left.{0} | right.{0}", part))));
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Returns the bitwise XOR of two integers.");
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"left\">The first integer.</param>");
            WriteLine("/// <param name=\"right\">The second integer.</param>");
            WriteLine("/// <returns>The bitwise XOR of left and right.</returns>");
            WriteLine("public static {0} operator ^({0} left, {0} right)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}({1});", Name, string.Join(", ",
                Parts.Select(part => string.Format("left.{0} ^ right.{0}", part))));
            Dedent();
            WriteLine("}");

            WriteLine("public static {0} operator <<({0} value, int amount)", Name);
            Indent("{");
            WriteLine("unsafe");
            Indent("{");

            WriteLine("uint* parts = stackalloc uint[{0}];", Parts.Length);
            WriteLine("uint* vparts = stackalloc uint[{0}];", Parts.Length);
            for (int i = 0; i < Parts.Length; ++i)
            {
                WriteLine("vparts[{0}] = value.{1};", i, Parts[i]);
            }

            WriteLine("int k = amount / 32;");
            WriteLine("int shift = amount % 32;");
            WriteLine("for (int i = 0; i < {0}; i++)", Parts.Length);
            Indent("{");
            WriteLine("if (i + k + 1 < {0})", Parts.Length);
            Indent("{");
            WriteLine("parts[i + k + 1] |= (vparts[i] >> (32 - shift));");
            Dedent("}");            
            WriteLine("if (i + k < {0})", Parts.Length);
            Indent("{");
            WriteLine("parts[i + k] |= (vparts[i] << shift);");
            Dedent("}");
            Dedent("}");

            WriteLine("return new {0}({1});", Name,
                string.Join(", ", Enumerable.Range(0, Parts.Length).Select(i => string.Format("parts[{0}]", i))));

            Dedent("}");
            Dedent("}");

            WriteLine("public static {0} operator >>({0} value, int amount)", Name);
            Indent("{");
            WriteLine("unsafe");
            Indent("{");

            WriteLine("uint* parts = stackalloc uint[{0}];", Parts.Length);
            WriteLine("uint* vparts = stackalloc uint[{0}];", Parts.Length);
            for (int i = 0; i < Parts.Length; ++i)
            {
                WriteLine("vparts[{0}] = value.{1};", i, Parts[i]);
            }

            WriteLine("int k = amount / 32;");
            WriteLine("int shift = amount % 32;");
            WriteLine("for (int i = 0; i < {0}; i++)", Parts.Length);
            Indent("{");
            WriteLine("if (i - k - 1 >= 0)");
            Indent("{");
            WriteLine("parts[i - k - 1] |= (vparts[i] << (32 - shift));");
            Dedent("}");
            WriteLine("if (i - k >= 0)");
            Indent("{");
            WriteLine("parts[i - k] |= (vparts[i] >> shift);");
            Dedent("}");
            Dedent("}");

            if (Signed)
            {
                WriteLine("uint negative = (uint)((int)vparts[{0}] >> 32);", Parts.Length - 1);
                WriteLine("for (int i = System.Math.Max(0, {0} - k); i < {0}; i++)", Parts.Length);
                Indent("{");
                WriteLine("parts[i] = negative;");
                Dedent("}");
                WriteLine("negative <<= (32 - shift);");
                WriteLine("if({0} - k - 1 >= 0)", Parts.Length);
                Indent("{");
                WriteLine("parts[{0} - k - 1] |= negative;", Parts.Length);
                Dedent("}");
            }

            WriteLine("return new {0}({1});", Name,
                string.Join(", ", Enumerable.Range(0, Parts.Length).Select(i => string.Format("parts[{0}]", i))));

            Dedent("}");
            Dedent("}");

            WriteLine("public byte[] ToByteArray()");
            WriteLine("{");
            Indent();
            WriteLine("var bytes = new byte[{0}];", Bytes);
            for (int i = 0; i < Parts.Length; ++i)
            {
                WriteLine("bytes[{0}] = (byte)({1} >> 0);", i * 4 + 0, Parts[i]);
                WriteLine("bytes[{0}] = (byte)({1} >> 8);", i * 4 + 1, Parts[i]);
                WriteLine("bytes[{0}] = (byte)({1} >> 16);", i * 4 + 2, Parts[i]);
                WriteLine("bytes[{0}] = (byte)({1} >> 24);", i * 4 + 3, Parts[i]);
            }
            WriteLine("return bytes;");
            Dedent();
            WriteLine("}");

            WriteLine("#endregion");
        }
示例#2
0
文件: Integer.cs 项目: Frassle/Ibasa
        void Conversions()
        {
            WriteLine("#region Conversions");

            var other = new Integer(Size, !Signed);

            WriteLine("/// <summary>");
            WriteLine("/// Defines an explicit conversion of an {0} value to an {1}.", Name, other);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that is bitwise equal to value.</returns>", other);
            WriteLine("public static explicit operator {0}({1} value)", other, Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}({1});", other, 
                string.Join(", ", Parts.Select(part => string.Format("value.{0}", part))));
            Dedent();
            WriteLine("}");
            
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a signed 8-bit value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a signed 8-bit value.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.SByte.MinValue.-or-value is greater than System.SByte.MaxValue.
            //[CLSCompliant(false)]
            //public static explicit operator sbyte(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a System.Decimal value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a System.Decimal.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.Decimal.MinValue.-or-value is greater than System.Decimal.MaxValue.
            //public static explicit operator decimal(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a System.Double value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a System.Double.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            //public static explicit operator double(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a single-precision floating-point value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a single-precision floating-point value.
            ////
            //// Returns:
            ////     An object that contains the closest possible representation of the value
            ////     parameter.
            //public static explicit operator float(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     an unsigned 64-bit integer value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to an unsigned 64-bit integer.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.UInt64.MinValue.-or-value is greater than System.UInt64.MaxValue.
            //[CLSCompliant(false)]
            //public static explicit operator ulong(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a 64-bit signed integer value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a 64-bit signed integer.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.Int64.MinValue.-or-value is greater than System.Int64.MaxValue.
            //public static explicit operator long(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     an unsigned 32-bit integer value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to an unsigned 32-bit integer.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.UInt32.MinValue.-or-value is greater than System.UInt32.MaxValue.
            //[CLSCompliant(false)]
            //public static explicit operator uint(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a 32-bit signed integer value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a 32-bit signed integer.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.Int32.MinValue.-or-value is greater than System.Int32.MaxValue.
            //public static explicit operator int(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     a 16-bit signed integer value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a 16-bit signed integer.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.Int16.MinValue.-or-value is greater than System.Int16.MaxValue.
            //public static explicit operator short(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     an unsigned 16-bit integer value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to an unsigned 16-bit integer.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.UInt16.MinValue.-or-value is greater than System.UInt16.MaxValue.
            //[CLSCompliant(false)]
            //public static explicit operator ushort(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Numerics.BigInteger object to
            ////     an unsigned byte value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a System.Byte.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is less than System.Byte.MinValue. -or-value is greater than System.Byte.MaxValue.
            //public static explicit operator byte(BigInteger value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Decimal object to a System.Numerics.BigInteger
            ////     value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a System.Numerics.BigInteger.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            //public static explicit operator BigInteger(decimal value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Double value to a System.Numerics.BigInteger
            ////     value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a System.Numerics.BigInteger.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is System.Double.NaN.-or-value is System.Double.PositiveInfinity.-or-value
            ////     is System.Double.NegativeInfinity.
            //public static explicit operator BigInteger(double value);
            ////
            //// Summary:
            ////     Defines an explicit conversion of a System.Single object to a System.Numerics.BigInteger
            ////     value.
            ////
            //// Parameters:
            ////   value:
            ////     The value to convert to a System.Numerics.BigInteger.
            ////
            //// Returns:
            ////     An object that contains the value of the value parameter.
            ////
            //// Exceptions:
            ////   System.OverflowException:
            ////     value is System.Single.NaN.-or-value is System.Single.PositiveInfinity.-or-value
            ////     is System.Single.NegativeInfinity.
            //public static explicit operator BigInteger(float value);
            
            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of a signed byte to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("[System.CLSCompliant(false)]");
            WriteLine("public static implicit operator {0}(sbyte value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}((int)value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of a signed 16-bit integer to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("public static implicit operator {0}(short value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}((int)value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of a signed 32-bit integer to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("public static implicit operator {0}(int value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}(value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of a signed 64-bit integer to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("public static implicit operator {0}(long value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}(value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of an unsigned byte to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("public static implicit operator {0}(byte value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}((uint)value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of an unsigned 16-bit integer to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("[System.CLSCompliant(false)]");
            WriteLine("public static implicit operator {0}(ushort value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}((uint)value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of an unsigned 32-bit integer to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("[System.CLSCompliant(false)]");
            WriteLine("public static implicit operator {0}(uint value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}(value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("/// <summary>");
            WriteLine("/// Defines an implicit conversion of an unsigned 64-bit integer to an {0}.", Name);
            WriteLine("/// </summary>");
            WriteLine("/// <param name=\"value\">The value to convert to an {0}.</param>", other);
            WriteLine("/// <returns>An {0} that contains the value of the value parameter.</returns>", other);
            WriteLine("[System.CLSCompliant(false)]");
            WriteLine("public static implicit operator {0}(ulong value)", Name);
            WriteLine("{");
            Indent();
            WriteLine("return new {0}(value);", Name);
            Dedent();
            WriteLine("}");

            WriteLine("#endregion");
        }
示例#3
0
文件: Program.cs 项目: Frassle/Ibasa
        static void Main(string[] args)
        {
            string root = System.IO.Path.Combine("..", "..", "..", "Numerics");

            var integer_path = System.IO.Path.Combine(root, "Integer.cs");
            System.IO.File.Delete(integer_path);
            foreach (var size in Integer.Sizes)
            {
                var integer = new Integer(size, true);
                integer.Generate();

                System.IO.File.AppendAllText(integer_path, integer.Text);
                Console.WriteLine("Done - " + integer.Name);

                var uinteger = new Integer(size, false);
                uinteger.Generate();

                System.IO.File.AppendAllText(integer_path, uinteger.Text);
                Console.WriteLine("Done - " + uinteger.Name);
            }

            foreach (var type in Color.Types)
            {
                var color = new Color(type);
                color.Generate();

                var path = System.IO.Path.Combine(root, color.Name + ".cs");
                System.IO.File.WriteAllText(path, color.Text);
                Console.WriteLine("Done - " + color.Name);
            }

            foreach (var type in Quaternion.Types)
            {
                var quaternion = new Quaternion(type);
                quaternion.Generate();

                var path = System.IO.Path.Combine(root, "Geometry", quaternion.Name + ".cs");
                System.IO.File.WriteAllText(path, quaternion.Text);
                Console.WriteLine("Done - " + quaternion.Name);
            } 
            
            foreach (var type in Plane.Types)
            {
                var plane = new Plane(type);
                plane.Generate();

                var path = System.IO.Path.Combine(root, "Geometry", plane.Name + ".cs");
                System.IO.File.WriteAllText(path, plane.Text);
                Console.WriteLine("Done - " + plane.Name);
            }

            foreach (int dimension in Vector.Sizes)
            {
                foreach (var type in Vector.Types)
                {
                    var vector = new Vector(type, dimension);
                    vector.Generate();

                    var path = System.IO.Path.Combine(root, "Vectors", vector.Name + ".cs");
                    System.IO.File.WriteAllText(path, vector.Text);
                    Console.WriteLine("Done - " + vector.Name);
                }
            }

            foreach (int rows in Matrix.Sizes)
            {
                foreach (int columns in Matrix.Sizes)
                {
                    foreach (var type in Matrix.Types)
                    {
                        var matrix = new Matrix(type, rows, columns);
                        matrix.Generate();
                        var path = System.IO.Path.Combine(root, "Matrices", matrix.Name + ".cs");
                        System.IO.File.WriteAllText(path, matrix.Text);
                        Console.WriteLine("Done - " + matrix.Name);
                    }
                }
            }

            foreach (var type in Shapes.Types)
            {
                var rpath = System.IO.Path.Combine(root, "Geometry");

                var line1 = new Line(type, 1);
                line1.Generate();
                System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, line1.Name + ".cs"), line1.Text);
                Console.WriteLine("Done - " + line1.Name);

                foreach (int dimension in Shapes.Sizes)
                {
                    var point = new Point(type, dimension);
                    point.Generate();
                    System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, point.Name + ".cs"), point.Text);
                    Console.WriteLine("Done - " + point.Name);

                    var size = new Size(type, dimension);
                    size.Generate();
                    System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, size.Name + ".cs"), size.Text);
                    Console.WriteLine("Done - " + size.Name);

                    var polygon = new Polygon(type, dimension);
                    polygon.Generate();
                    System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, polygon.Name + ".cs"), polygon.Text);
                    Console.WriteLine("Done - " + polygon.Name);

                    var line = new Line(type, dimension);
                    line.Generate();
                    System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, line.Name + ".cs"), line.Text);
                    Console.WriteLine("Done - " + line.Name);
                }

                var rectangle = new Rectangle(type);
                rectangle.Generate();
                System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, rectangle.Name + ".cs"), rectangle.Text);
                Console.WriteLine("Done - " + rectangle.Name);

                var box = new Box(type);
                box.Generate();
                System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, box.Name + ".cs"), box.Text);
                Console.WriteLine("Done - " + box.Name);

                var ellipse = new Ellipse(type);
                ellipse.Generate();
                System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, ellipse.Name + ".cs"), ellipse.Text);
                Console.WriteLine("Done - " + ellipse.Name);

                var circle = new Circle(type);
                circle.Generate();
                System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, circle.Name + ".cs"), circle.Text);
                Console.WriteLine("Done - " + circle.Name);

                var sphere = new Sphere(type);
                sphere.Generate();
                System.IO.File.WriteAllText(System.IO.Path.Combine(rpath, sphere.Name + ".cs"), sphere.Text);
                Console.WriteLine("Done - " + sphere.Name);
            }

            foreach (var type in Ray.Types)
            {
                var ray = new Ray(type);
                ray.Generate();

                var path = System.IO.Path.Combine(root, "Geometry", ray.Name + ".cs");
                System.IO.File.WriteAllText(path, ray.Text);
                Console.WriteLine("Done - " + ray.Name);
            }
        }