public void SetDefaultCasing()
 {
     if (Line1 != null)
     {
         Line1 = Line1.ToInvariantTitleCase();
     }
     if (Line2 != null)
     {
         Line2 = Line2.ToInvariantTitleCase();
     }
     if (StateOrProvince != null)
     {
         StateOrProvince = StateOrProvince.ToInvariantTitleCase();
     }
     if (PostalCode != null)
     {
         PostalCode = PostalCode.ToUpper();
     }
     if (City != null)
     {
         City = City.ToInvariantTitleCase();
     }
     if (CountryCode != null)
     {
         CountryCode = CountryCode.ToUpper();
     }
 }
Exemple #2
0
    void OnSceneGUI()
    {
        Line1 line = target as Line1;

        Handles.color = Color.green;
        Handles.DrawDottedLine(Vector3.zero, line.n, 6);
        Handles.DrawLine(Vector3.zero, line.p0);
        Vector3 np = line.n.normalized * Vector3.Dot(line.p0, line.n.normalized);

        Handles.DrawWireDisc(np, line.n, (line.p0 - np).magnitude);

        Handles.color = Color.yellow;
        Vector3 vp = line.v - line.p1;

        Handles.DrawLine(line.v, line.p1);

        Handles.color = Color.cyan;
        Vector3 pp = line.p1 - line.p0;

        Handles.DrawDottedLine(line.p1, line.p0, 6);

        line.normalCheck      = 0 != Vector3.Dot(np, vp);                               //無限平面に対する線分の衝突判定
        line.planeInLineCheck = 0 == Vector3.Dot(line.n, pp);                           //無限平面上に線分が存在する時の衝突判定

        line.lineV  = Vector3.Dot(line.n, line.v - np);
        line.lineP1 = Vector3.Dot(line.n, line.p1 - np);
        line.penetrationLineCheck = 0 >= (line.lineV * line.lineP1);                            //線分が平面を貫通しているかチェック

        line.hitCheck = line.normalCheck | line.planeInLineCheck && line.penetrationLineCheck;
    }
Exemple #3
0
        public Day3Input Parse(string[] values)
        {
            Line1 = values.First().Split(',').Select(c => new Instruction
            {
                Direction = c.First(),
                Count     = int.Parse(c.Substring(1))
            }).ToList();
            Line2 = values.ElementAt(1).Split(',').Select(c => new Instruction
            {
                Direction = c.First(),
                Count     = int.Parse(c.Substring(1))
            }).ToList();

            MaxLeft  = Line1.Where(c => c.Direction == 'L').Sum(c => c.Count);
            MaxRight = Line1.Where(c => c.Direction == 'R').Sum(c => c.Count);
            MaxUp    = Line1.Where(c => c.Direction == 'U').Sum(c => c.Count);
            MaxDown  = Line1.Where(c => c.Direction == 'D').Sum(c => c.Count);

            MaxLeft  = Math.Max(MaxLeft, Line2.Where(c => c.Direction == 'L').Sum(c => c.Count));
            MaxRight = Math.Max(MaxRight, Line2.Where(c => c.Direction == 'R').Sum(c => c.Count));
            MaxUp    = Math.Max(MaxUp, Line2.Where(c => c.Direction == 'U').Sum(c => c.Count));
            MaxDown  = Math.Max(MaxDown, Line2.Where(c => c.Direction == 'D').Sum(c => c.Count));

            return(this);
        }
Exemple #4
0
        public static void DrawDemo()
        {
            DrawingObject[] dObj = new DrawingObject[5];

            dObj[0] = new Line1();
            dObj[1] = new Line2();
            dObj[2] = new Circle();
            dObj[3] = new Square();
            dObj[4] = new DrawingObject();

            foreach (DrawingObject drawObj in dObj)
            {
                drawObj.Draw();
            }

            var line1 = new Line1(); // if modifier isn`t be like in base e.g. class method as "protected void Draw()"  CLR calling base class method Draw

            line1.Draw();
            var line2 = new Line2(); // but if modifier declared as protected internal CLR calling derived class method Draw

            line2.Draw();
            var circle = new Circle();

            circle.Draw();
        }
 protected override bool CheckEquality(Address other)
 {
     return(CareOf == other.CareOf &&
            Line1.AreEqualDespiteCase(other.Line1) &&
            City.AreEqualDespiteCase(other.City) &&
            Country.AreEqualDespiteCase(other.Country));
 }
Exemple #6
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         return((Line1.GetHashCode() * 397) ^ Line2.GetHashCode());
     }
 }
Exemple #7
0
        private void GetIntersectionPoints()
        {
            IntersectionResultArray iresArray1;
            SetComparisonResult     result1 = Line1.Intersect(Line3, out iresArray1);
            IntersectionResult      ires1   = iresArray1.get_Item(0);

            Point1 = ires1.XYZPoint;

            IntersectionResultArray iresArray2;
            SetComparisonResult     result2 = Line1.Intersect(Line4, out iresArray2);
            IntersectionResult      ires2   = iresArray2.get_Item(0);

            Point2 = ires2.XYZPoint;

            IntersectionResultArray iresArray3;
            SetComparisonResult     result3 = Line2.Intersect(Line3, out iresArray3);
            IntersectionResult      ires3   = iresArray3.get_Item(0);

            Point3 = ires3.XYZPoint;

            IntersectionResultArray iresArray4;
            SetComparisonResult     result4 = Line2.Intersect(Line4, out iresArray4);
            IntersectionResult      ires4   = iresArray4.get_Item(0);

            Point4 = ires4.XYZPoint;
        }
Exemple #8
0
 /**
  * Move a rectangle
  *
  * @param deltaX            The delta x-location by which the rectangle should be moved -- must be a valid double
  * @param deltaY            The delta y-location by which the rectangle should be moved -- must be a valid double
  * @throws ShapeException   Exception throw if any parameter is invalid
  * @throws ShapeException   When a rectangle is moved to have a length of zero
  */
 public void Move(double deltaX, double deltaY)
 {
     Line1.Move(deltaX, deltaY);
     Line2.Move(deltaX, deltaY);
     Line3.Move(deltaX, deltaY);
     Line4.Move(deltaX, deltaY);
 }
Exemple #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Line1.Length != 0)
            {
                hash ^= Line1.GetHashCode();
            }
            if (HasLine2)
            {
                hash ^= Line2.GetHashCode();
            }
            if (HasCity)
            {
                hash ^= City.GetHashCode();
            }
            if (Zipcode != 0L)
            {
                hash ^= Zipcode.GetHashCode();
            }
            if (State.Length != 0)
            {
                hash ^= State.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public void SimpleInlineValidatorStopsAfterValidationFailureAndOverridesPropertyNameAndApplyErrorTransformations()
        {
            // Arrange:
            var line1Validator = new InlineValidator <Line1>();

            line1Validator.Setup(x => x.Street)
            .SetPropertyDisplayName("StreetName")
            .AddRule(x => x != null, "cannot be null", "NOT_NULL")
            .WithMessage("not null")
            .WithCode("MUST_NOT_BE_NULL")
            .StopValidationAfterFailure()
            .AddRule(x => char.IsUpper(x[0]), "must start with uppercase", "STARTS_WITH_UPPER");
            var toValidate = new Line1
            {
                Street = null
            };

            // Act:
            var validationErrors = line1Validator.Validate(toValidate);

            // Assert:
            validationErrors.Count.Should().Be(1);
            validationErrors[0].ErrorMessage.Should().Be("not null");
            validationErrors[0].ErrorCode.Should().Be("MUST_NOT_BE_NULL");
            validationErrors[0].PropertyPath.ToString().Should().Be("StreetName");
            validationErrors[0].ProvidedValue.Should().Be(null);
        }
 /// <summary>
 /// Creates chart data using the specified data set.
 /// </summary>
 /// <param name="dataSet">The data set.</param>
 protected override void OnCreateChartData(int dataSet)
 {
     Bar1.CreateChartData(dataSet);
     Line1.CreateChartData(dataSet);
     Line2.CreateChartData(Line2.DataSetCount - 1);
     Pie1.CreateChartData(2);
 }
Exemple #12
0
        public override void SetLine(int line, string message)
        {
            LogDebug("(IDisplay) ImonLcd.SetLine() called");
            if (message == null)
            {
                LogDebug("(IDisplay) ImonLcd.SetDefaults(): empty message, return");
                return;
            }

            int lineToCheckFirst, lineToCheckSecond;

            if (g_Player.Player != null && g_Player.Player.Playing)
            {
                LogDebug("(IDisplay) ImonLcd.SetLine(): determing line to display during playback");
                if (_preferLine1Playback)
                {
                    lineToCheckFirst  = 0;
                    lineToCheckSecond = 1;
                }
                else
                {
                    lineToCheckFirst  = 1;
                    lineToCheckSecond = 0;
                }
            }
            else
            {
                LogDebug("(IDisplay) ImonLcd.SetLine(): determine line to display during general use");
                if (_preferLine1General)
                {
                    lineToCheckFirst  = 0;
                    lineToCheckSecond = 1;
                }
                else
                {
                    lineToCheckFirst  = 1;
                    lineToCheckSecond = 0;
                }
            }
            LogDebug("(IDisplay) ImonLcd.SetLine(): preferred 0-based line: " + lineToCheckFirst);

            if (line == lineToCheckFirst)
            {
                Line1 = message;
                IDW_SetLcdText(Line1);
                LogDebug("(IDisplay) ImonLcd.SetLine(): displaying 0-based line (first choice): " + line + ", message: " + Line1);
            }
            else if (line == lineToCheckSecond)
            {
                if (Line1.Trim().Length == 0 && message.Length > 0)
                {
                    Line1 = message;
                    IDW_SetLcdText(Line1);
                    LogDebug("(IDisplay) ImonLcd.SetLine(): displaying 0-based line (second choice): " + line + ", message: " + Line1);
                }
            }
            LogDebug("(IDisplay) ImonLcd.SetDefaults() completed");
        }
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (Line1 != null ? Line1.GetHashCode() : 0);
         result = (result * 397) ^ (Town != null ? Town.GetHashCode() : 0);
         result = (result * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0);
         return(result);
     }
 }
Exemple #14
0
        /*
         * ValidateSquare ensures that all vertecies have an angle of 90
         */
        public void ValidateSquare()
        {
            var LineAC = new Line(Line1.Point1, Line2.Point2);

            if (
                (Math.Acos((Math.Pow(Line1.ComputeLength(), 2) + Math.Pow(Line4.ComputeLength(), 2) - Math.Pow(LineAC.ComputeLength(), 2) / (2 * Line1.ComputeLength() * Line4.ComputeLength())))) != 90
                )
            {
                throw new ShapeException("Invalid rectangle");
            }
        }
Exemple #15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var result = Id.GetHashCode();
         result = (result * 397) ^ (Line1 != null ? Line1.GetHashCode() : 0);
         result = (result * 397) ^ (Line2 != null ? Line2.GetHashCode() : 0);
         result = (result * 397) ^ (Location != null ? Location.GetHashCode() : 0);
         return(result);
     }
 }
Exemple #16
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Line1 != null ? Line1.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Line2 != null ? Line2.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Zip != null ? Zip.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #17
0
        public override int GetHashCode()
        {
            var hashCode = Name.GetHashCode();

            hashCode = hashCode * 37 ^ Line1.GetHashCode();
            hashCode = hashCode * 37 ^ Line2.GetHashCode();
            hashCode = hashCode * 37 ^ City.GetHashCode();
            hashCode = hashCode * 37 ^ State.GetHashCode();
            hashCode = hashCode * 37 ^ ZipCode.GetHashCode();
            hashCode = hashCode * 37 ^ Country.GetHashCode();

            return(hashCode);
        }
Exemple #18
0
 public override int GetHashCode()
 {
     unchecked
     {
         var result = Line1.GetHashCode();
         result = (result * 397) ^ (Line2 != null ?
                                    Line2.GetHashCode() : 0);
         result = (result * 397) ^ ZipCode.GetHashCode();
         result = (result * 397) ^ City.GetHashCode();
         result = (result * 397) ^ State.GetHashCode();
         return(result);
     }
 }
 public override string ToString()
 {
     return(string.Join(", ",
                        new string[]
     {
         Line1.RemoveFromEnd(",").ToSentenceCase(),
         Line2.RemoveFromEnd(",").ToSentenceCase(),
         Town.RemoveFromEnd(",").ToSentenceCase(),
         County.RemoveFromEnd(",").ToSentenceCase(),
         Postcode.ToUpper()
     }
                        .Where(x => !string.IsNullOrWhiteSpace(x))
                        .Select(x => x)));
 }
            public void WhenLinesHaveCr_ThenReturnTwoLines()
            {
                var text = CsvHeader + "\r" + Line1 + "\r" + Line2;

                var fileInfo = FileTestBuilder.InFileSystem
                               .WithFilePath(Path.Combine(WorkingDir, "Test1.csv"))
                               .WithText(text)
                               .Build();

                var result = Act(fileInfo.FullName);

                Assert.That(result.First().Values, Is.EquivalentTo(Line1.Split(',')));
                Assert.That(result.Second().Values, Is.EquivalentTo(Line2.Split(',')));
            }
Exemple #21
0
        public bool IsPOBox()
        {
            bool result = false;

            string check = Line1.Trim().ToLower();

            if (check.Contains("p.o. box"))
            {
                return(true);
            }
            if (check.Contains("po box"))
            {
                return(true);
            }
            if (check.Contains("p o box"))
            {
                return(true);
            }
            if (check.Contains("p.o.box"))
            {
                return(true);
            }
            if (check.Contains("p.o box"))
            {
                return(true);
            }
            if (check.Contains("po. box"))
            {
                return(true);
            }
            if (check.Contains("p-o box"))
            {
                return(true);
            }
            if (check.Contains("pobox"))
            {
                return(true);
            }
            if (check.Contains(" po "))
            {
                return(true);
            }
            if (check.Contains(" box "))
            {
                return(true);
            }

            return(result);
        }
Exemple #22
0
 /*
  * Validator will check to ensure:
  * 1. The length of any edge does not exceed the sum of the other two
  * 2. The points that make up the line must not reside on the same line
  */
 public void ValidateTriangle()
 {
     if ((Line1.ComputeLength() > Line2.ComputeLength() + Line3.ComputeLength()) ||
         (Line2.ComputeLength() > Line1.ComputeLength() + Line3.ComputeLength()) ||
         (Line3.ComputeLength() > Line1.ComputeLength() + Line2.ComputeLength()))
     {
         throw new ShapeException("Invalid triangle");
     }
     if (Line1.ComputeSlope() == Line2.ComputeSlope() ||
         Line2.ComputeSlope() == Line3.ComputeSlope() ||
         Line3.ComputeSlope() == Line1.ComputeSlope())
     {
         throw new ShapeException("Invalid Triangle");
     }
 }
Exemple #23
0
 public CMAngle(int id, CMPoint start, CMPoint end1, CMPoint end2, int?angle = null) : base(start.Owner, id)
 {
     Point      = start;
     Line1      = start.GetCommonLine(end1);
     Line2      = start.GetCommonLine(end2);
     this.angle = angle;
     if (Line1.DetectDir(start, end1) > 1)
     {
         Dir = (Line2.DetectDir(start, end2) > 1 ? AngleDir.FrontFront : AngleDir.FrontBack);
     }
     else
     {
         Dir = (Line2.DetectDir(start, end2) > 1 ? AngleDir.BackFront : AngleDir.BackBack);
     }
 }
        }         // FillFromOneLine

        private void FillFromTwoLines(CustomerAddressModel filled)
        {
            filled.HouseNumber = Regex.Match(Line1, "\\d*").Value;

            if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
            {
                var line1 = Line1.Split(' ');
                filled.HouseNumber = line1[0];
                filled.Address1    = string.Join(" ", line1.Skip(1));
                filled.Address2    = Line2;
                return;
            }             // if

            string uLine1 = Line1.ToUpper();

            if (uLine1.StartsWith("APARTMENT") || uLine1.StartsWith("FLAT"))
            {
                filled.FlatOrApartmentNumber = Line1;
                filled.HouseNumber           = Regex.Match(Line2, "\\d*").Value;

                if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
                {
                    var line2 = Line2.Split(' ');
                    filled.HouseNumber = line2[0];
                    filled.Address1    = string.Join(" ", line2.Skip(1));
                }
                else
                {
                    filled.Address1 = Line2;
                }
            }
            else
            {
                filled.HouseNumber = Regex.Match(Line2, "\\d*").Value;
                filled.HouseName   = Line1;

                if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
                {
                    var line2 = Line2.Split(' ');
                    filled.HouseNumber = line2[0];
                    filled.Address1    = string.Join(" ", line2.Skip(1));
                }
                else
                {
                    filled.Address1 = Line2;
                }
            }     // if
        }         // FillFromTwoLines
            public void WhenTrimIsEnabled_ThenReturnTrimmedValues()
            {
                var text = CsvHeader + "\n" + Line1WithWhitespace + "\n" + Line2WithWhitespace;

                var fileInfo = FileTestBuilder.InFileSystem
                               .WithFilePath(Path.Combine(WorkingDir, "Test1.csv"))
                               .WithText(text)
                               .Build();

                var result = Act(fileInfo.FullName, new CsvFileReaderOptions {
                    EnableTrimValues = true
                });

                Assert.That(result.First().Values, Is.EquivalentTo(Line1.Split(',')));
                Assert.That(result.Second().Values, Is.EquivalentTo(Line2.Split(',')));
            }
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = Line1 != null?Line1.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (Line2 != null ? Line2.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Line3 != null ? Line3.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Line4 != null ? Line4.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0);
                return(hashCode);
            }
        }
Exemple #27
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="Line1">A Line&lt;T&gt;.</param>
        /// <param name="Line2">Another Line&lt;T&gt;.</param>
        /// <returns>true|false</returns>
        public static Boolean operator ==(Line2D <T> Line1, Line2D <T> Line2)
        {
            // If both are null, or both are same instance, return true.
            if (Object.ReferenceEquals(Line1, Line2))
            {
                return(true);
            }

            // If one is null, but not both, return false.
            if (((Object)Line1 == null) || ((Object)Line2 == null))
            {
                return(false);
            }

            return(Line1.Equals(Line2));
        }
Exemple #28
0
        public override bool Equals(object obj)
        {
            if (!(obj is Address))
            {
                throw new ArgumentException("Object is not of the correct Type", nameof(obj));
            }

            Address updated = obj as Address;

            return(Description.Trim() == updated.Description.Trim() &&
                   (Line1?.Trim() ?? "") == (updated.Line1?.Trim() ?? "") &&
                   (Line2?.Trim() ?? "") == (updated.Line2?.Trim() ?? "") &&
                   (City?.Trim() ?? "") == (updated.City?.Trim() ?? "") &&
                   (State?.Trim() ?? "") == (updated.State?.Trim() ?? "") &&
                   (ZipCode?.Trim() ?? "") == (updated.ZipCode?.Trim() ?? ""));
        }
        public void SimpleInlineValidatorThrowsExceptionBecauseOfInvalidValidationRule()
        {
            // Arrange:
            var line1Validator = new InlineValidator <Line1>();

            line1Validator.Setup(x => x.Street)
            .AddRule(x => x != null, "cannot be null", "NOT_NULL")
            .AddRule(x => char.IsUpper(x[0]), "must start with uppercase", "STARTS_WITH_UPPER");
            var toValidate = new Line1
            {
                Street = null
            };

            // Act & Assert:
            Assert.Throws <NullReferenceException>(() => line1Validator.Validate(toValidate));
        }
Exemple #30
0
        public override bool Equals(object obj)
        {
            bool isSame     = false;
            var  newAddress = obj as Address;

            if (Line1.Equals(newAddress.Line1, StringComparison.OrdinalIgnoreCase) &&
                (Line2 ?? "").Equals((newAddress.Line2 ?? ""), StringComparison.OrdinalIgnoreCase) &&
                (Line3 ?? "").Equals((newAddress.Line3 ?? ""), StringComparison.OrdinalIgnoreCase) &&
                City.Equals(newAddress.City, StringComparison.OrdinalIgnoreCase) &&
                State.Equals(newAddress.State, StringComparison.OrdinalIgnoreCase) &&
                Country.Equals(newAddress.Country, StringComparison.OrdinalIgnoreCase) &&
                PostalCode.Equals(newAddress.PostalCode, StringComparison.OrdinalIgnoreCase))
            {
                isSame = true;
            }
            return(isSame);
        }