public string ToString(AM am) { StringBuilder builder = ObjectPool<StringBuilder>.GetObject(); builder.AppendFormat("{0}: {1}", EmotionType, am.RecallEvent(CauseId).EventName); if (this.Direction != null) builder.AppendFormat(" {0}", Direction); var result = builder.ToString(); builder.Length = 0; ObjectPool<StringBuilder>.Recycle(builder); return result; }
public IBaseEvent GetCause(AM am) { return am.RecallEvent(CauseId); }
public EmotionDTO ToDto(AM am) { return new EmotionDTO { Type = this.EmotionType, Intensity = this.Intensity, CauseEventId = this.CauseId, CauseEventName = am.RecallEvent(this.CauseId).EventName.ToString(), }; }
/// <summary> /// unique hash string calculation function /// </summary> /// <param name="emotion"></param> private static string calculateHashString(IEmotion emotion, AM am) { StringBuilder builder = ObjectPool<StringBuilder>.GetObject(); try { builder.Append(emotion.GetCause(am).EventName.ToString().ToUpper()); using (var it = emotion.AppraisalVariables.GetEnumerator()) { while (it.MoveNext()) { builder.Append("-"); builder.Append(it.Current); } } return builder.ToString(); } finally { builder.Length = 0; ObjectPool<StringBuilder>.Recycle(builder); } }