public int GetKey(DataField dataField) { var key = dataField.GetHashCode(); if (flyweights.ContainsKey(key)) { return(key); } else { flyweights.Add(key, dataField); return(key); } }
public void GetHashcodeTest() { DataField dataField1 = new DataField(); dataField1.FieldName = "test-fieldName"; dataField1.Value = "test-value"; dataField1.FieldGroup = "test-fieldGroup"; DataField dataField2 = new DataField(); dataField2.FieldName = "test-fieldName"; dataField2.Value = "test-value"; dataField2.FieldGroup = "test-fieldGroup"; Assert.Equal(dataField1.GetHashCode(), dataField2.GetHashCode()); }
public override int GetHashCode() { return(field != null?field.GetHashCode() : strongField.GetHashCode()); }