/// <summary> /// Inserts given Property in propertyDict. /// </summary> /// <typeparam name="T">The type of the inserted Property.</typeparam> /// <param name="propertyName">The Property name is in this case a PropertyEnum. It is used /// for quicker access to specific Property.</param> /// <param name="property">The inserting Property.</param> public void AddProperty <T>(PropertyEnum propertyName, Property <T> property) { if (!propertyDict.ContainsKey(propertyName)) { propertyDict.Add(propertyName, property); } }
public string GetPropertyFromConfigFile(PropertyEnum propertyEnum) { try { var eleName = PropertyEnumMap.GetPropertyEnumText(propertyEnum); if (null == rootElement) { throw new Exception("getPropertyFromConfigFile: root Element is NULL"); } if (null == rootElementCommon) { throw new Exception("getPropertyFromCommonFile: root Element is NULL"); } var pElement = rootElement.Element(eleName); if (null == pElement) { pElement = rootElementCommon.Element(eleName); } if (null == pElement) { return(null); } return(pElement.Value); } catch (Exception ex) { log.Error(ex.Message); throw ex; } }
public Control Get(PropertyEnum property) { Control result; switch (property) { case PropertyEnum.Panel: result = gridFieldPanel; break; case PropertyEnum.Trackbar: result = zoomTrackbar; break; case PropertyEnum.AlgorithmComboBox: result = algorithmComboBox; break; case PropertyEnum.Legend: result = legend; break; case PropertyEnum.List: result = productList; break; default: result = null; break; } return(result); }
/** * this method can be invoked by UI/Autostub (encapsulated this method in LAL) or invoked by LAL, * when invoked by UI/AutoStub, EX. properties updated on UI, set properties to LAL properties; * when invoked by LAL, EX. LAL read properties from configuration file during initialize, LAL set properties to UI via sprite HashMap * */ public void SetProperty(PropertyEnum key, string value) { if (_properties.ContainsKey(key)) { _properties[key] = value; } }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Property = ((PropertyEnum)(binaryReader.ReadInt16())); this.fieldpad = binaryReader.ReadBytes(2); this.ParameterName = binaryReader.ReadStringID(); return(pointerQueue); }
/// <summary> /// Removes the Property from propertyDict (if it contains). /// </summary> /// <param name="propertyName">The PropertyEnum member with a name of the removing Property.</param> public void RemoveProperty(PropertyEnum propertyName) { if (propertyDict.ContainsKey(propertyName) && (int)propertyName > 10) { propertyDict.Remove(propertyName); return; } }
public static string GetPropertyEnumText(PropertyEnum propertyEnum) { if (_map.ContainsKey(propertyEnum)) { return(_map[propertyEnum]); } throw new Exception("Not Found!"); }
public PropertyNode GetProperty(PropertyEnum propertyType) { PropertyNode property; propertyDict.TryGetValue(propertyType, out property); System.Diagnostics.Debug.Assert(property == null, string.Format("error: {0} property not initialized.", propertyType.ToString())); return(property); }
/// <summary> /// Returns Property by the given name (from propertyDict). If propertyDict doesn't contains /// the Property so the exception is thrown. /// </summary> /// <typeparam name="T">The typeof the Property.</typeparam> /// <param name="propertyName">The name of the Property from Enum (base properties).</param> /// <returns> /// Returns founded Property. /// </returns> /// <exception cref="PropertyMissingException">Thrown when the object does not have the property.</exception> public Property <T> GetProperty <T>(PropertyEnum propertyName) { if (!propertyDict.ContainsKey(propertyName)) { throw new PropertyMissingException("Object " + Name + " doesn't have property " + propertyName + "."); } var prop = (Property <T>)propertyDict[propertyName]; return(prop); }
/** * get properties from Hash table properties, which is invoked by LAL * */ public string GetProperty(PropertyEnum propertyEnum) { var val = _properties[propertyEnum]; if (string.IsNullOrWhiteSpace(val)) { return(string.Empty); } return(val); }
/// <summary> /// Returns Property by given name if exists (if not - returns null). /// </summary> /// <typeparam name="T">The type of the Property.</typeparam> /// <param name="propertyName">The name of the Property.</param> /// <returns>Returns Property by given name with given type.</returns> public Property <T> GetProperty <T>(PropertyEnum propertyName) { if (!propertyDict.ContainsKey(propertyName)) { return(null); } var prop = (Property <T>)propertyDict[propertyName]; return(prop); }
public PropertyNode CreateProperty(PropertyEnum propertyType, float valueBase, Action <float> onValueChanged = null) { PropertyNode property; if (!propertyDict.TryGetValue(propertyType, out property)) { property = new PropertyNode(); property.Init(valueBase, onValueChanged); propertyDict.Add(propertyType, property); } property.ResetValueBase(valueBase); return(property); }
/// <summary> /// Edits or sets given Property to the propertyDict (base Property). /// Also checks if the given object is really Property (if not the exception is thrown). /// </summary> /// <param name="name">The name of the inserting Property (PropertyEnum).</param> /// <param name="prop">The inserting Property</param> /// <exception cref="System.ArgumentException">Thrown when the parameter prop is not the Property</exception> protected void SetProperty(PropertyEnum name, object prop) { if (!(prop.GetType().GetGenericTypeDefinition() == typeof(Property <>))) { throw new ArgumentException("Given object is not Property<T>, it is " + prop.GetType()); } if (propertyDict.ContainsKey(name)) { propertyDict[name] = prop; } else { propertyDict.Add(name, prop); } }
/// <summary> /// Returns Property value from propertyBonusDict summed with group bonus. If object does't contains queried property, /// returs new property with default value. /// </summary> /// <typeparam name="T">The type of the queried property.</typeparam> /// <param name="name">The name of the property. (PropertyEnum)</param> /// <returns>Returns founded property or new property with default value.</returns> protected T GetPropertyValue <T>(PropertyEnum name) { Property <T> bonus; // Group bonus if (!propertyBonusDict.ContainsKey(name.ToString())) { bonus = new Property <T>(default(T)); } else { bonus = ((Property <T>)propertyBonusDict[name.ToString()]); } // Object property Property <T> property = GetProperty <T>(name); var op = Property <T> .Operator.Plus; return(bonus.SimpleMath(op, property).Value); }
/// <summary> /// Does nothing, the sun never removes any property. /// </summary> /// <param name="name">The name of removing Property.</param> public void RemoveProperty(PropertyEnum name) { }
public BaseClass GetPropertyByEnum(PropertyEnum enumValue) { PropertyInfo pi = typeof(RootClass).GetProperty(enumValue.ToString()); return(pi.GetValue(instance, null) as BaseClass); }
public MovementWithProperty(PropertyEnum property, float value) { Property = property; Value = value; }
public static ErrorNumberEnum SetProperty(PropertyEnum key, string value) { return((ErrorNumberEnum)WrapperInterface.addProperty((int)key, value)); }
public void DoIt() { var f = new PropertyEnum <LogLevel>(); var value = f.Parse(null); // non-nullable! }
public Source Load() { Debug.WriteLine("Loading " + tsvFile); string[] text = File.ReadAllLines(tsvFile); if (text.Length < 1) { throw new ArgumentException("TSV does not have any data. Check format of spreadsheet."); } // Build a map of the incoming data string headerRow = text[0]; string[] columns = headerRow.Split('\t').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); int numberOfHeaders = columns.Length; PropertyEnum[] resolved = new PropertyEnum[numberOfHeaders]; for (int i = 0; i < numberOfHeaders; ++i) { string header = columns[i].ToLowerInvariant() .Replace("your ", "") .Replace(" ", "") .Replace("_", "") .Replace(":", "") .Replace("-", "") .Replace("'s", "") .Replace("teamcaptain", "captain") .Replace("teammember", "player") ; if (string.IsNullOrWhiteSpace(header)) { Console.WriteLine($"Warning: Unable to resolve header, it is blank after processing: \"{header}\", (was \"{columns[i]}\")"); resolved[i] = PropertyEnum.UNKNOWN; } // Quick case else if (propertyValueStringMap.ContainsKey(header)) { resolved[i] = propertyValueStringMap[header]; } else { // Need to do some searching int playerNum = 0; if (header.Contains("captain")) { playerNum = 1; header = header.Replace("captain", ""); } else { for (playerNum = 10; playerNum > 0; --playerNum) { if (header.Contains(playerNum.ToString())) { header = header.Replace(playerNum.ToString(), ""); break; } } } var matchedKey = propertyValueStringMap.Keys.FirstOrDefault(key => header.StartsWith(key)); if (matchedKey != null) { // For player num = 0 (not found), this will just return the appropriate header. resolved[i] = (playerNum * (int)PropertyEnum.PlayerN_Offset) + propertyValueStringMap[matchedKey]; } else if (playerNum == 0) { resolved[i] = PropertyEnum.UNKNOWN; Console.WriteLine("Warning: Unable to resolve header: " + header); } else { resolved[i] = PropertyEnum.UNKNOWN; Console.WriteLine("Warning: Unable to resolve header for player " + playerNum + ": " + header); } } } // Now read the data... // Most tsv files will be team sheets, but for draft cups and verif they could be player records instead. // Each row therefore might be a single team with players, or a single player entry. List <Team> teams = new List <Team>(); List <Player> players = new List <Player>(); // From 1 as [0] is header row for (int lineIndex = 1; lineIndex < text.Length; ++lineIndex) { string line = text[lineIndex]; if (!line.Contains('\t')) { continue; } string[] cells = line.Split('\t').ToArray(); // Warn if the values exceeds the number of defined headers (but don't bother if we're only one over and it's empty -- trailing tab) if (numberOfHeaders < cells.Length && (numberOfHeaders != cells.Length - 1 || !string.IsNullOrWhiteSpace(cells[cells.Length - 1]))) { Console.WriteLine($"Warning: Line {lineIndex} contains more cells in this row {cells.Length} than headers {numberOfHeaders}."); Debug.WriteLine(line); } SortedDictionary <int, Player> rowPlayers = new SortedDictionary <int, Player>(); Team t = new Team(); for (int i = 0; i < cells.Length && i < numberOfHeaders; ++i) { int playerNum = 0; PropertyEnum resolvedProperty = resolved[i]; if (resolvedProperty > PropertyEnum.PlayerN_Offset) { playerNum = (int)resolved[i] / (int)PropertyEnum.PlayerN_Offset; resolvedProperty = (PropertyEnum)((int)resolved[i] % (int)PropertyEnum.PlayerN_Offset); } string value = cells[i]; if (string.IsNullOrWhiteSpace(value)) { continue; } switch (resolvedProperty) { case PropertyEnum.UNKNOWN: { continue; } case PropertyEnum.Country: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); p.Country = value; break; } case PropertyEnum.DiscordId: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); if (value.Length >= 14 && value.Length < 21) { // First, test is decimal (of length 17+) bool isDecimal = value.Length >= 17 && value.All("0123456789".Contains); if (isDecimal) { p.AddDiscordId(value, source); } // Otherwise test if we can get from a hex string (of length 14+ to give the correct 17 digit decimal) else if (ulong.TryParse(value, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out ulong parsedId)) { p.AddDiscordId(value, source); } else { Console.WriteLine($"Warning: DiscordId was specified ({lineIndex},{i}), but the value could not be parsed from a decimal or hex string. {value}."); Debug.WriteLine(line); } } else { Console.WriteLine($"Warning: DiscordId was specified ({lineIndex},{i}), but the value length does not fit into a discord id. {value}."); Debug.WriteLine(line); } break; } case PropertyEnum.DiscordName: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); if (Discord.DISCORD_NAME_REGEX.IsMatch(value)) { p.AddDiscordUsername(value, source); } else if (FriendCode.TryParse(value, out FriendCode friendCode)) { p.AddFCs(friendCode, source); Console.WriteLine($"Warning: This value was declared as a Discord name but looks like a friend code. Bad data formatting? {value} on ({lineIndex},{i})."); } else { Console.WriteLine($"Warning: DiscordName was specified ({lineIndex},{i}), but the value was not in a Discord format of name#0000. {value}."); Debug.WriteLine(line); } break; } case PropertyEnum.FC: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); if (FriendCode.TryParse(value, out FriendCode friendCode)) { p.AddFCs(friendCode, source); } else { Console.WriteLine($"Warning: FC was specified ({lineIndex},{i}), but the value was not in an FC format of 0000-0000-0000 or 0000 0000 0000. {value}."); Debug.WriteLine(line); } break; } case PropertyEnum.Div: { t.AddDivision(new Division(value, divType, season), source); if (divType == DivType.Unknown) { Console.WriteLine($"Warning: Div was specified ({lineIndex},{i}), but I don't know what type of division this file represents."); } break; } case PropertyEnum.LUTIDiv: { t.AddDivision(new Division(value, DivType.LUTI, season), source); break; } case PropertyEnum.EBTVDiv: { t.AddDivision(new Division(value, DivType.EBTV, season), source); break; } case PropertyEnum.DSBDiv: { t.AddDivision(new Division(value, DivType.DSB, season), source); break; } case PropertyEnum.Timestamp: { // TODO - not supported right now. In future we could customise the source timestamp for this entry. break; } case PropertyEnum.Name: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); var playerName = value.Trim(); playerName = t.Tag?.StripFromPlayer(playerName) ?? playerName; p.AddName(playerName, source); if (FriendCode.TryParse(value, out FriendCode friendCode)) { p.AddFCs(friendCode, source); Console.WriteLine($"Warning: This value was declared as a name but looks like a friend code. Bad data formatting? {value} on ({lineIndex},{i})."); Debug.WriteLine(line); } break; } case PropertyEnum.Role: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); p.AddWeapons(value.Split(',').Select(s => s.Trim()).Where(s => !string.IsNullOrWhiteSpace(s))); break; } case PropertyEnum.Pronouns: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); p.PronounInformation.SetPronoun(value, source); break; } case PropertyEnum.Tag: { t.AddClanTag(value, source); break; } case PropertyEnum.TeamName: { t.AddName(value, source); break; } case PropertyEnum.Twitter: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); p.AddTwitter(value, source); break; } case PropertyEnum.Twitch: { var p = GetCurrentPlayer(ref rowPlayers, playerNum, tsvFile); p.AddTwitch(value, source); break; } case PropertyEnum.Team_Offset: case PropertyEnum.UnspecifiedPlayer_Offset: case PropertyEnum.PlayerN_Offset: default: { Console.WriteLine($"Warning: Unhandled header {resolvedProperty}. {value}. Line {lineIndex}:"); Debug.WriteLine(line); break; } } } // End of the row, add the data. foreach (var pair in rowPlayers) { // Don't add empty players Player p = pair.Value; if (p.Name.Equals(Builtins.UnknownPlayerName)) { continue; } // Don't add the team to the player if it's not complete (e.g. single player record) if (!t.Name.Equals(Builtins.UnknownTeamName)) { p.TeamInformation.Add(t.Id, source); } players.Add(p); } // Don't bother adding the team if it has no players if (players.Count > 0) { // Don't register a team if that information doesn't exist. if (!t.Name.Equals(Builtins.UnknownTeamName)) { // Recalculate the ClanTag layout if (t.Tag != null) { t.Tag.CalculateTagOption(players[0].Name.Value); } else { ClanTag?newTag = ClanTag.CalculateTagFromNames(players.Select(p => p.Name.Value).ToArray(), source); if (newTag != null) { t.AddClanTag(newTag); } } teams.Add(t); } } } source.Players = players.ToArray(); source.Teams = teams.ToArray(); return(source); }
public MovementWithProperty(MovementEnum name, PropertyEnum property, float value) : this(property, value) { Name = name; }
public int EnumProperties(enum_DEBUGPROP_INFO_FLAGS dwFields, uint nRadix, ref Guid guidFilter, uint dwTimeout, out uint pcelt, out IEnumDebugPropertyInfo2 ppEnum) { DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.EnumProperties"); var list = new List<DebugProperty>(); if (guidFilter == AD7Guids.guidFilterLocalsPlusArgs || guidFilter == AD7Guids.guidFilterAllLocalsPlusArgs || guidFilter == AD7Guids.guidFilterAllLocals) { AddLocalProperties(list); AddParameterProperties(list); } else if (guidFilter == AD7Guids.guidFilterLocals) { AddLocalProperties(list); } else if (guidFilter == AD7Guids.guidFilterArgs) { AddParameterProperties(list); } else { pcelt = 0; ppEnum = null; return VSConstants.E_NOTIMPL; } pcelt = (uint) list.Count; ppEnum = new PropertyEnum(list.Select(x => x.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD))); return VSConstants.S_OK; }
public PropertyNode GetProperty(PropertyEnum propertyType) { return(propertyPool.GetProperty(propertyType)); }