PointUnit[] LoadUnits(TwitchChannel channel) { TwitchChannelPointScale[] points = factory.GetChannelPointScale(channel); if (points != null && points.Length > 0) { PointUnit[] units = new PointUnit[points.Length]; for (int i = 0; i < points.Length; i++) { units[i] = new PointUnit(points[i].unitNameSingular, points[i].unitNamePlural, points[i].unitValue); } return(units); } return(null); }
static PointUnit[] LoadUnits(SqlTwitchChannel channel) { SqlTwitchChannelPointScale[] points = SqlTwitchChannelPointScale.ForChannel(channel); if(points != null && points.Length > 0) { PointUnit[] units = new PointUnit[points.Length]; for(int i = 0; i < points.Length; i++) { units[i] = new PointUnit(points[i].unitName, points[i].unitValue); } return units; } return null; }
PointUnit[] LoadUnits(TwitchChannel channel) { TwitchChannelPointScale[] points = factory.GetChannelPointScale(channel); if(points != null && points.Length > 0) { PointUnit[] units = new PointUnit[points.Length]; for(int i = 0; i < points.Length; i++) { units[i] = new PointUnit(points[i].unitNameSingular, points[i].unitNamePlural, points[i].unitValue); } return units; } return null; }
public ulong GetPointsFromString(string message) { message = message?.Trim(); ulong pointsValue = 0; if (message != null) { if (message.StartsWith("all", StringComparison.CurrentCultureIgnoreCase)) { return(ulong.MaxValue); } else { do { double numberValue; string numberString = message.GetBefore(" ")?.Trim(); if (numberString == null) { numberString = message; } if (!double.TryParse(numberString, out numberValue)) { numberValue = (ulong)(pointsValue == 0 ? 1 : 0); } else { message = message.GetAfter(" ")?.Trim(); } string numberUnit = message.GetBefore(" ")?.Trim(); if (numberUnit == null) { numberUnit = message; message = null; } else { message = message.GetAfter(" ")?.Trim(); } PointUnit unit = units[0]; if (numberUnit != null) { for (uint i = 0; i < units.Length; i++) { if (numberUnit.Equals(units[i].nameSingular, StringComparison.CurrentCultureIgnoreCase) || numberUnit.Equals(units[i].namePlural, StringComparison.CurrentCultureIgnoreCase)) { unit = units[i]; if (numberValue == 0) { numberValue = 1; } break; } } } pointsValue += (ulong)(numberValue * unit.value); } while(message != null); return(pointsValue); } } else { return(1); } }