Line
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
    public class Line : Curve
    {
        internal ILineEntity LineEntity => HostImpl as ILineEntity;
        public Vector Direction => Vector.Wrap(LineEntity.get_Direction(), true);
        internal Line(ILineEntity host, bool persist)
            : base(host, persist)
        {
        }
        public override string ToString()
        {
            return "Line(StartPoint = " + base.StartPoint?.ToString() + ", EndPoint = " + base.EndPoint?.ToString() + ", Direction = " + Direction?.ToString() + ")";
        }
        internal new static void InitType()
        {
            Geometry.RegisterHostType(typeof(ILineEntity), (IGeometryEntity host, bool persist) => new Line(host as ILineEntity, persist));
        }
        internal static Line Wrap(ILineEntity host, bool persist = true)
        {
            if (host == null)
                return null;
            return new Line(host, persist);
        }
        internal static Line[] Wrap(ILineEntity[] hosts, bool persist = true)
        {
            return (from x in hosts
            select Wrap(x, persist)).ToArray();
        }
        internal static Line[][] Wrap(ILineEntity[][] hosts, bool persist = true)
        {
            return (from x in hosts
            select Wrap(x, persist)).ToArray();
        }
        internal static ILineEntity[][] Unwrap(Line[][] o)
        {
            return (from x in o
            select Unwrap(x)).ToArray();
        }
        internal static ILineEntity[] Unwrap(Line[] o)
        {
            return (from x in o
            select Unwrap(x)).ToArray();
        }
        internal static ILineEntity[] Unwrap(IEnumerable<Line> o)
        {
            return (from x in o
            select Unwrap(x)).ToArray();
        }
        internal static ILineEntity Unwrap(Line o)
        {
            return o.LineEntity;
        }
        public static Line ByStartPointEndPoint(Point startPoint, Point endPoint)
        {
            return Wrap(HostFactory.Factory.LineByStartPointEndPoint(Point.Unwrap(startPoint), Point.Unwrap(endPoint)), true);
        }
        public static Line ByBestFitThroughPoints(IEnumerable<Point> bestFitPoints)
        {
            return Wrap(HostFactory.Factory.LineByBestFitThroughPoints(Point.Unwrap(bestFitPoints)), true);
        }
        public static Line ByTangency(Curve curve, double parameter = 0)
        {
            return Wrap(HostFactory.Factory.LineByTangency(Curve.Unwrap(curve), parameter), true);
        }
        public static Line ByStartPointDirectionLength(Point startPoint, Vector direction, [Scaling()] double length = 1)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                length
            });
            length /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.LineByStartPointDirectionLength(Point.Unwrap(startPoint), Vector.Unwrap(direction), length), true);
        }
    }
}
            