public bool Equals(BreakHours obj) { if (object.ReferenceEquals(obj, null)) { return(false); } return(BreakHours.Equals(this, obj)); }
public static bool Equals(BreakHours obj1, BreakHours obj2) { if (object.ReferenceEquals(obj1, null) && object.ReferenceEquals(obj2, null)) { return(true); } if (object.ReferenceEquals(obj1, null) || object.ReferenceEquals(obj2, null)) { return(false); } return(obj1.From == obj2.From && obj1.To == obj2.To); }
public void AddNewBreak(BreakHours breakHours) { if (breakHours == null) { throw new ArgumentNullException("breakHours"); } if (this.breaks == null) { this.breaks = new List <BreakHours>(); } if (this.WorkingTime != WorkingTime.WorkHours && this.WorkingTime != WorkingTime.RoundTheClock) { throw new InvalidOperationException(string.Format(WeekModel.cultureInfo, Resources.E_BreakCanNotBeAddedForTypeWithParam, this.WorkingTime.ToString())); } this.breaks.Add(breakHours); }
/// <summary> /// Generates an object from its XML representation /// </summary> /// <param name="reader">The System.Xml.XmlReader stream from which the object is deserialized</param> public void ReadXml(System.Xml.XmlReader reader) { if (reader.IsEmptyElement) { throw new InvalidOperationException(string.Format(WeekModel.cultureInfo, Resources.E_ElementCanNotBeEmptyWithParam, reader.Name)); } string startNodeName = reader.Name; while (reader.Read()) { if (!reader.IsStartElement()) { if (startNodeName == reader.Name) { reader.Read(); //Set pointer to the next node return; } else { continue; } } switch (reader.Name) { case "closed": if (this.WorkingTime != WorkingTime.None) { throw new InvalidOperationException(string.Format(WeekModel.cultureInfo, Resources.E_WorkingTimeMustBeNoneWithParams2, this.WorkingTime.ToString(), startNodeName)); } this.WorkingTime = WorkingTime.Closed; break; case "round_the_clock": if (this.WorkingTime != WorkingTime.None) { throw new InvalidOperationException(string.Format(WeekModel.cultureInfo, Resources.E_WorkingTimeMustBeNoneWithParams2, this.WorkingTime.ToString(), startNodeName)); } this.WorkingTime = WorkingTime.RoundTheClock; break; case "work_hours": if (this.WorkingTime != WorkingTime.None) { throw new InvalidOperationException(string.Format(WeekModel.cultureInfo, Resources.E_WorkingTimeMustBeNoneWithParams2, this.WorkingTime.ToString(), startNodeName)); } this.WorkHours = new WorkHours(); this.WorkHours.ReadXml(reader); break; case "break": BreakHours breakHours = new BreakHours(); breakHours.ReadXml(reader); this.AddNewBreak(breakHours); break; default: throw new InvalidOperationException(string.Format(WeekModel.cultureInfo, Resources.E_UnexpectedXmlElementWithParam, reader.Name)); } } }
public static bool operator ==(BreakHours obj1, BreakHours obj2) { return(BreakHours.Equals(obj1, obj2)); }