/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ObservationType != null) { hashCode = hashCode * 59 + ObservationType.GetHashCode(); } if (ThingId != null) { hashCode = hashCode * 59 + ThingId.GetHashCode(); } if (StartTime != null) { hashCode = hashCode * 59 + StartTime.GetHashCode(); } if (EndTime != null) { hashCode = hashCode * 59 + EndTime.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Thing instances are equal /// </summary> /// <param name="other">Instance of Thing to be compared</param> /// <returns>Boolean</returns> public bool Equals(ExportCsv other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ObservationType == other.ObservationType || ObservationType != null && ObservationType.Equals(other.ObservationType) ) && ( ThingId == other.ThingId || ThingId != null && ThingId.Equals(other.ThingId) ) && ( EndTime == other.EndTime || EndTime != null && EndTime.Equals(other.EndTime) ) && ( StartTime == other.StartTime || StartTime != null && StartTime.Equals(other.StartTime) )); }
/// <summary> /// Returns true if Wearable instances are equal /// </summary> /// <param name="other">Instance of Wearable to be compared</param> /// <returns>Boolean</returns> public bool Equals(Wearable other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( PersonId == other.PersonId || PersonId != null && PersonId.Equals(other.PersonId) ) && ( ThingId == other.ThingId || ThingId != null && ThingId.Equals(other.ThingId) ) && ( Timestamp == other.Timestamp || Timestamp != null && Timestamp.Equals(other.Timestamp) )); }
public void Parse_InvalidIdString_ThrowsException() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; Assert.Throws <FormatException>(() => ThingId.Parse($"{driver}:{gateway}:{thing}:1")); }
public HomeMaticThingChannelHandler(ThingId thingId, string name, string channelAddress, string valueKey, IHomeMaticXmlRpcApi xmlRpcApi, IMediator mediator) : base(thingId, name) { _channelAddress = channelAddress; _valueKey = valueKey; _mediator = mediator; _ccuValue = new CcuValueIo(xmlRpcApi, channelAddress, valueKey); }
public ThingChannel(IThingChannelHandler thingChannelHandler, ThingId thingId, IMessageHub messageHub) { _thingChannelHandler = thingChannelHandler; _messageHub = messageHub; Id = new ThingChannelId(thingId, Name); _state = new SynchronizedValue <ThingState>(); }
/// <summary> /// Determines whether specified instance of <see cref="ResultInfo" /> is equal to caller /// object. /// </summary> /// <param name="other">Other object to compare.</param> /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns> private bool IsEqual(ResultInfo other) { const double tolerance = 1e-6; return(ThingId.Equals(other.ThingId) && Math.Abs(RatingValue - other.RatingValue) < tolerance && RatingId.Equals(other.RatingId)); }
/// <summary> /// Determines whether specified instance of <see cref="BasicInfo" /> is equal to caller /// object. /// </summary> /// <param name="other">Other object to compare.</param> /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns> protected bool IsEqual(BasicInfo other) { const double eps = 1e-6; return(ThingId.Equals(other.ThingId) && string.Equals(Title, other.Title, StringComparison.Ordinal) && VoteCount.Equals(other.VoteCount) && Math.Abs(VoteAverage - other.VoteAverage) < eps); }
public void Equals_NullId_ReturnsFalse() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.False(thingId.Equals((IdBase)null)); }
public void Equals_SameIdString_ReturnsTrue() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.True(thingId.Equals($"{driver}:{gateway}:{thing}")); }
public void GetHashCode_ThingId_EqualsIdStringHashCode() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.Equal(thingId.ToString().GetHashCode(), thingId.GetHashCode()); }
public void TryParse_InvalidIdString_ReturnsFalseAndThingIdNull() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var parseOk = ThingId.TryParse($"{driver}:{gateway}:{thing}:1", out var thingId); Assert.False(parseOk); Assert.Null(thingId); }
public void Equals_OtherIdWithSameValue_ReturnsTrue() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); var thingId2 = new ThingId(new GatewayId(driver, gateway), thing); Assert.True(thingId.Equals(thingId2)); }
public void Equals_SameIdObject_ReturnsTrue() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); object id = thingId; Assert.True(thingId.Equals(id)); }
public Thing(string thingName, GatewayId gatewayId, IThingTemplate thingTemplate, IThingChannelBuilder thingChannelBuilder, IMessageHub messageHub) { _thingTemplate = thingTemplate; _thingChannelBuilder = thingChannelBuilder; _messageHub = messageHub; Name = thingName; Id = new ThingId(gatewayId, thingName); _channels = new ConcurrentList <IThingChannel>(); _state = new SynchronizedValue <ThingState>(); }
public void Parse_ValidIdString_ReturnsThingId() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var thingId = ThingId.Parse($"{driver}:{gateway}:{thing}"); Assert.Equal(driver, thingId.Driver); Assert.Equal(gateway, thingId.Gateway); Assert.Equal(thing, thingId.Thing); }
public void TryParse_ValidIdString_ReturnsTrueAndOutThingId() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; var parseOk = ThingId.TryParse($"{driver}:{gateway}:{thing}", out var thingId); Assert.True(parseOk); Assert.Equal(driver, thingId.Driver); Assert.Equal(gateway, thingId.Gateway); Assert.Equal(thing, thingId.Thing); }
public void Equals_NotSameIdStringObject_ReturnsFalse() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string driver2 = "Driver2"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); object id = $"{driver2}:{gateway}:{thing}"; Assert.False(thingId.Equals(id)); }
public void Driver_CreateId_GetValueOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string driver2 = "Driver2"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.Equal(driver, thingId.Driver); thingId.Driver = driver2; Assert.Equal(driver2, thingId.Driver); }
public void Gateway_CreateId_GetValueOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string gateway2 = "Gateway2"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.Equal(gateway, thingId.Gateway); thingId.Gateway = gateway2; Assert.Equal(gateway2, thingId.Gateway); }
public void Thing_CreateId_GetValueOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string thing2 = "Thing2"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.Equal(thing, thingId.Thing); thingId.Thing = thing2; Assert.Equal(thing2, thingId.Thing); }
/// <summary> /// Returns true if Observation instances are equal /// </summary> /// <param name="other">Instance of Observation to be compared</param> /// <returns>Boolean</returns> public bool Equals(Observation other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ThingId == other.ThingId || ThingId != null && ThingId.Equals(other.ThingId) ) && ( DatastreamId == other.DatastreamId || DatastreamId != null && DatastreamId.Equals(other.DatastreamId) ) && ( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( Personid == other.Personid || Personid != null && Personid.Equals(other.Personid) ) && ( Zoneid == other.Zoneid || Zoneid != null && Zoneid.Equals(other.Zoneid) ) && ( PhenomenTime == other.PhenomenTime || PhenomenTime != null && PhenomenTime.Equals(other.PhenomenTime) ) && ( ObservationResult == other.ObservationResult || ObservationResult != null && ObservationResult.Equals(other.ObservationResult) )); }
public void ToString_CreateId_ResultOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string driver2 = "Driver2"; const string gateway2 = "Gateway2"; const string thing2 = "Thing2"; var thingId = new ThingId(new GatewayId(driver, gateway), thing); Assert.Equal($"{driver}:{gateway}:{thing}", thingId.ToString()); thingId.Driver = driver2; thingId.Gateway = gateway2; thingId.Thing = thing2; Assert.Equal($"{driver2}:{gateway2}:{thing2}", thingId.ToString()); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (PersonId != null) { hashCode = hashCode * 59 + PersonId.GetHashCode(); } if (ThingId != null) { hashCode = hashCode * 59 + ThingId.GetHashCode(); } if (Timestamp != null) { hashCode = hashCode * 59 + Timestamp.GetHashCode(); } return(hashCode); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ThingId != null) { hashCode = hashCode * 59 + ThingId.GetHashCode(); } if (DatastreamId != null) { hashCode = hashCode * 59 + DatastreamId.GetHashCode(); } if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Personid != null) { hashCode = hashCode * 59 + Personid.GetHashCode(); } if (Zoneid != null) { hashCode = hashCode * 59 + Zoneid.GetHashCode(); } if (PhenomenTime != null) { hashCode = hashCode * 59 + PhenomenTime.GetHashCode(); } if (ObservationResult != null) { hashCode = hashCode * 59 + ObservationResult.GetHashCode(); } return(hashCode); } }
public SimpleThingChannelHandler(ThingId thingId, string name, Func <T, bool> setValue) : base(thingId, name) { _setValue = setValue; }
public SimpleThingChannelHandler(ThingId thingId, string name) : this(thingId, name, _ => true) { }
/// <inheritdoc /> public override int GetHashCode() { return(ThingId.GetHashCode()); }
public DummyThingChannelHandler(ThingId thingId, string name) : base(thingId, name) { }
protected ThingChannelHandlerBase(ThingId thingId, string name) { Name = name; ChannelId = new ThingChannelId(thingId, name); }