public void SetTypedValue <T>(T value) { EventValueTypes ttype = this.ValueTypeFromType <T>(); switch (ttype) { case EventValueTypes.ObjectList: this.ObjectValues.Add(value); break; case EventValueTypes.StringList: this.StringValues.Add(value.ToString()); break; case EventValueTypes.Object: this.ObjectValue = value; break; case EventValueTypes.String: this.StringValue = value.ToString(); break; case EventValueTypes.Bool: bool btemp = false; Boolean.TryParse(value.ToString(), out btemp); this.BoolValue = btemp; break; case EventValueTypes.Int: int itemp = 0; int.TryParse(value.ToString(), out itemp); this.IntValue = itemp; break; case EventValueTypes.Long: long ltemp = 0; long.TryParse(value.ToString(), out ltemp); this.LongValue = ltemp; break; } }
public dynamic GetTypedValue <T>() { dynamic ret = default(T); EventValueTypes ttype = this.ValueTypeFromType <T>(); switch (ttype) { case EventValueTypes.ObjectList: ret = this.ObjectValues; break; case EventValueTypes.StringList: ret = this.StringValues; break; case EventValueTypes.Object: ret = this.ObjectValue; break; case EventValueTypes.String: ret = this.StringValue; break; case EventValueTypes.Bool: ret = this.BoolValue; break; case EventValueTypes.Int: ret = this.IntValue; break; case EventValueTypes.Long: ret = this.LongValue; break; } return(ret); }