private JToken GenerateType(TokenPoolType type) { switch (type) { case TokenPoolType.Quaternion: return(new JObject() { { "x", new JValue(0) }, { "y", new JValue(0) }, { "z", new JValue(0) }, { "w", new JValue(0) } }); case TokenPoolType.Vector3: return(new JObject() { { "x", new JValue(0) }, { "y", new JValue(0) }, { "z", new JValue(0) } }); case TokenPoolType.Value: return(new JValue(0)); default: throw new System.NotSupportedException("Cannot allocate token of unknown type"); } }
public JToken Lease(TokenPoolType type) { var pool = TokenPool[type]; return(pool.Count > 0 ? pool.Pop() : GenerateType(type)); }