public override async Task <IList <TElement> > ExecuteQueryAsync <TElement>(QueryString queryString, Action <TElement> onElementCreated) { IList <TElement> elements = new List <TElement>(); var propertiesDesc = new PropertyDescriptions(typeof(TElement).GetPropertyDescriptions()); using (var command = Client.CreateCommand(queryString.Value)) { using (DbDataReader reader = await command.ExecuteReaderAsync()) { string[] fields = reader.GetFields().ToArray(); while (await reader.ReadAsync()) { var element = new TElement(); for (int index = 0; index < fields.Length; index++) { if (reader.IsDBNull(index)) { continue; } propertiesDesc.SetValue(fields[index], reader.GetValue(index), element); } onElementCreated(element); elements.Add(element); } } } return(elements); }
public Sword(int level) { mAttack = Random.Range(15, 20) * (level + 1); PropertyDescriptions.Add("==Sword=="); PropertyDescriptions.Add($"Attack +{mAttack}"); }
public TypeDescription(Type type) { Type = type; Items = new ItemDescriptions(); Properties = new PropertyDescriptions(); Methods = new MethodDescriptions(); }
public ChainmailBikini(int level) { mArmor = 20 * (level + 1); PropertyDescriptions.Add("==Chainmail bikini=="); PropertyDescriptions.Add($"Armor +{mArmor}"); }
/// <summary> /// Procedure call with list of elements as result (Asynchronous) /// </summary> /// <param name="procedureName">Name of the Procedure Call</param> /// <param name="input">Input for the procedure call</param> /// <returns>List of Elements</returns> public async Task <List <TModel> > ExecuteProcedureSegmentAsync <TModel>(string procedureName, object input = null) where TModel : class, new() { List <TModel> results = new List <TModel>(); IEnumerable <PropertyDescription> propertieList = typeof(TModel).GetPropertyDescriptions(); var propertiesDesc = new PropertyDescriptions(propertieList); using (DbCommand cmd = impl.CreateProcedureCall(procedureName)) { IEnumerable <DbParameter> parameters = GetInputParams(input) .Concat(GetOutParams(propertieList)); foreach (DbParameter paramter in parameters) { cmd.Parameters.Add(paramter); } using (DbDataReader reader = await cmd.ExecuteReaderAsync()) { string[] fields = reader.GetFields().ToArray(); while (await reader.ReadAsync()) { var model = new TModel(); for (int index = 0; index < fields.Length; index++) { if (reader.IsDBNull(index)) { continue; } propertiesDesc.SetValue(fields[index], reader.GetValue(index), model); } results.Add(model); } } } return(results); }
public Staff(int level) { mSpellDamage = Random.Range(0.2f, 0.4f) * (level + 1) + 1; PropertyDescriptions.Add("==Staff=="); PropertyDescriptions.Add($"Skill damage x{mSpellDamage:#.00}"); }
public Spear(int level) { mAttack = Random.Range(3, 7) * (level + 1); mRange = 0.5f; PropertyDescriptions.Add("==Spear=="); PropertyDescriptions.Add($"Attack +{mAttack}"); PropertyDescriptions.Add($"Attack range +{mRange}"); }
public Robe(int level) { mMaxMana = Random.Range(10, 20) * (level + 1); mManaRegen = Random.Range(0.5f, 0.7f) * (level + 1); PropertyDescriptions.Add("==Robe=="); PropertyDescriptions.Add($"Max mana +{mMaxMana}"); PropertyDescriptions.Add($"Mana regen +{mManaRegen}"); }
public Chainmail(int level) { mMaxHp = Random.Range(10, 20) * (level + 1); mArmor = Random.Range(1, 3) * (level + 1); PropertyDescriptions.Add("==Chainmail=="); PropertyDescriptions.Add($"Max health +{mMaxHp}"); PropertyDescriptions.Add($"Armor +{mArmor}"); }
protected override void AddRangeEditors() { foreach (string propertyName in PropertyDescriptions.Keys) { PropertyDescription propertyDescription; PropertyDescriptions.TryGetValue(propertyName, out propertyDescription); Editors.Add(new RangeEditorViewModel(propertyName, propertyDescription, this)); } }
public static void ReflectProperties( Type targetType, PropertyDescriptions propertyDescriptions, ItemDescriptions itemDescriptions, WoopsaConverters customValueTypeConverters = null) { PropertyInfo[] properties; if (!targetType.IsInterface) { properties = targetType.GetProperties(BindingFlags.Public | BindingFlags.Instance); } else { properties = (new Type[] { targetType }).Concat(targetType.GetInterfaces()).SelectMany(i => i.GetProperties()).ToArray(); } foreach (var propertyInfo in properties) { WoopsaValueTypeAttribute attribute = GetCustomAttribute <WoopsaValueTypeAttribute>(propertyInfo); bool isValidWoopsaProperty = false; isValidWoopsaProperty = InferWoopsaType(customValueTypeConverters, propertyInfo.PropertyType, out WoopsaValueType woopsaPropertyType, out WoopsaConverter converter); if (attribute != null) { woopsaPropertyType = attribute.ValueType; isValidWoopsaProperty = true; } if (isValidWoopsaProperty) { //This property is a C# property of a valid basic Woopsa Type, it can be published as a Woopsa property PropertyDescription newPropertyDescription = new PropertyDescription( woopsaPropertyType, propertyInfo, !propertyInfo.CanWrite || propertyInfo.GetSetMethod(false) == null, converter); propertyDescriptions.Add(newPropertyDescription); } else if (!propertyInfo.PropertyType.IsValueType) { // This property is not of a WoopsaType, if it is a reference type, assume it is an inner item ItemDescription newItem = new ItemDescription(propertyInfo); itemDescriptions.Add(newItem); } } }