private bool DoesPassFilter(Contents contents, string filter) { // TODO: Handle filter properly var pattern = "\\((?<inv>!\\(){0,1}(?<key>[^&]+?)=(?<value>.+?)\\)"; var matches = Regex.Matches(filter, pattern); // TODO: think of "|" foreach (Match match in matches) { var key = match.Groups["key"].Value; var value = match.Groups["value"].Value; var inv = match.Groups["inv"].Value; if (!contents.ContainsKey(key)) { return(false); } if (value == "*") { continue; } if (!Enumerable.Contains(contents[key], value)) { if (inv != "!(") { return(false); } } } return(true); }
public override void OnItemRemoved(Item item) { base.OnItemRemoved(item); if (Items.Count == 0) { if (ItemID == 0x4141 && ItemID != 0x4142) { ItemID = 0x4142; } else if (ItemID == 0x4143 && ItemID != 0x4144) { ItemID = 0x4144; } } if (Contents != null && Contents.ContainsKey(item)) { Contents.Remove(item); if (Contents.Count == 0) { Contents = null; } } }
private void LoadItemTypes() { foreach (var i in RecordAddresses()) { var key = M.ReadStringU(M.Read <long>(i)); var baseItemType = new BaseItemType { Metadata = key, ClassName = M.ReadStringU(M.Read <long>(i + 0x10, 0)), Width = M.Read <int>(i + 0x18), Height = M.Read <int>(i + 0x1C), BaseName = M.ReadStringU(M.Read <long>(i + 0x20)), DropLevel = M.Read <int>(i + 0x30), Tags = new string[M.Read <long>(i + 0xA8)] }; var ta = M.Read <long>(i + 0xB0); for (var k = 0; k < baseItemType.Tags.Length; k++) { var ii = ta + 0x8 + 0x10 * k; baseItemType.Tags[k] = M.ReadStringU(M.Read <long>(ii, 0), 255); } var tmpTags = key.Split('/'); string tmpKey; if (tmpTags.Length > 3) { baseItemType.MoreTagsFromPath = new string[tmpTags.Length - 3]; for (var k = 2; k < tmpTags.Length - 1; k++) { // This Regex and if condition change Item Path Category e.g. TwoHandWeapons // To tag strings type e.g. two_hand_weapon tmpKey = Regex.Replace(tmpTags[k], @"(?<!_)([A-Z])", "_$1").ToLower().Remove(0, 1); if (tmpKey[tmpKey.Length - 1] == 's') { tmpKey = tmpKey.Remove(tmpKey.Length - 1); } baseItemType.MoreTagsFromPath[k - 2] = tmpKey; } } else { baseItemType.MoreTagsFromPath = new string[1]; baseItemType.MoreTagsFromPath[0] = ""; } ContentsAddr.Add(i, baseItemType); if (!Contents.ContainsKey(key)) { Contents.Add(key, baseItemType); } } }
public void Number(int num) { if (Contents.ContainsKey(num)) { Contents[num].picked = true; Picked++; LastPickedNumber = num; } }
/// <summary> /// Возвращает запись контента /// </summary> /// <param name="contentName">Название контента</param> /// <param name="id">Идентификтаор записи</param> /// <returns></returns> public DataRow GetContentRowById(string contentName, int id) { if (!Contents.ContainsKey(contentName)) { return(null); } return(Contents[contentName].Select("CONTENT_ITEM_ID = " + id).FirstOrDefault()); }
public override void GetChildProperties(ObjectPropertyList list, Item item) { base.GetChildProperties(list, item); if (Contents != null && Contents.ContainsKey(item)) { list.Add(1113938, Contents[item] != null ? Contents[item].Name : "Unknown"); } }
/// <summary> /// </summary> /// <param name="language"></param> /// <returns></returns> protected virtual Content GetContent(string language) { if (!Contents.ContainsKey(language)) { throw new ArgumentOutOfRangeException("language", "can't find language(" + language + ") defined."); } Content content = Contents[language]; return(content); }
public void AddReagents(Dictionary <string, float> Reagents, float TemperatureContainer) //Automatic overflow If you Don't want to lose check before adding { float HowMany = AmountOfReagents(Reagents); CurrentCapacity = AmountOfReagents(Contents); if (Reagents.Count > 1) { double DivideAmount = new double(); DivideAmount = 1; if ((CurrentCapacity + HowMany) > MaxCapacity) { DivideAmount = MaxCapacity / (CurrentCapacity + HowMany); Logger.Log("The container overflows spilling the excess"); } foreach (KeyValuePair <string, float> Chemical in Reagents) { float TheAmount = (float)(Chemical.Value * DivideAmount); if (Contents.ContainsKey(Chemical.Key)) { Contents [Chemical.Key] = Contents [Chemical.Key] + TheAmount; } else { Contents [Chemical.Key] = TheAmount; } } } else { foreach (KeyValuePair <string, float> Chemical in Reagents) { float TheAmount = Chemical.Value; if ((CurrentCapacity + HowMany) > MaxCapacity) { TheAmount += (MaxCapacity - (CurrentCapacity + HowMany)); Logger.Log("The container overflows spilling the excess"); } if (Contents.ContainsKey(Chemical.Key)) { Contents [Chemical.Key] = Contents [Chemical.Key] + TheAmount; } else { Contents [Chemical.Key] = TheAmount; } } } CheckForEmptys(); Contents = Calculations.Reactions(Contents, Temperature); HowMany = ((AmountOfReagents(Contents) - CurrentCapacity) * TemperatureContainer) + (CurrentCapacity * Temperature); CurrentCapacity = AmountOfReagents(Contents); Temperature = HowMany / CurrentCapacity; }
/// <summary> /// Aktualisiert einen bereits vorhandenen nummerischen Wert /// </summary> /// <param name="key">Der Schlüssel des zu aktualisierenden Wertes</param> /// <param name="newvalue">Der neue Wert</param> /// <returns></returns> public bool Update(string key, double newvalue) { bool res = false; if (Contents.ContainsKey(key)) { Contents[key] = DoubleToString(newvalue); res = true; } return(res); }
/// <summary> /// Aktualisiert einen bereits vorhandenen Wert /// </summary> /// <param name="key">Der Schlüssel des zu aktualisierenden Wertes</param> /// <param name="newvalue">Der neue Wert</param> /// <returns></returns> public bool Update(string key, string newvalue) { bool res = false; if (Contents.ContainsKey(key)) { Contents[key] = newvalue; res = true; } return(res); }
public bool Contains(PositiveResourceLedger other) { foreach (var(type, amount) in other.Contents) { if (!Contents.ContainsKey(type) || Contents[type] < amount) { return(false); } } return(true); }
/// <summary> /// Добавляет контент в результат /// </summary> /// <param name="contentName">Название контента</param> /// <param name="content">Содержимое контента</param> internal void AddContent(string contentName, DataTable content) { if (Contents == null) { Contents = new Dictionary <string, DataTable>(); } if (!Contents.ContainsKey(contentName)) { Contents.Add(contentName, content); } }
public void LoadContents(XElement node) { List <XElement> contents = (from el in node.Elements("contains-item") select el).ToList(); for (int i = 0; i < contents.Count; i++) { if (!Contents.ContainsKey(contents[i].Attribute("texture").Value)) { Contents.Add(contents[i].Attribute("texture").Value, 0); } Contents[contents[i].Attribute("texture").Value] = (int)contents[i].Attribute("units"); } }
public void AddContent(string category, ArrayList contents) { if (!Contents.ContainsKey(category)) { Contents.Add(category, new List <Hashtable>()); } var contentList = Contents[category]; foreach (var content in contents) { contentList.Add((Hashtable)content); } }
public virtual void Add(ResourceLedger other) { foreach (var(resource, amount) in other.Contents) { if (Contents.ContainsKey(resource)) { Contents[resource] += amount; } else { Contents.Add(resource, amount); } } }
public override void OnItemRemoved(Item item) { base.OnItemRemoved(item); CheckMailBox(); if (Contents != null && Contents.ContainsKey(item)) { Contents.Remove(item); if (Contents.Count == 0) { Contents = null; } } }
public TextBlockType Select(int id, short partId = 0) { if (Contents.ContainsKey(id) == true) { if (Contents.Storage[id].ContainsKey(partId) == true) { return(Contents.Storage[id][partId]); } } else { LogManager.Log("Could not find {0} id: {1}", ContentType, id); } return(GetNullContent()[0]); }
private Content Get(string lang) { if (Contents.ContainsKey(lang)) { return(GetContent(lang)); } if (lang.IndexOf("-", StringComparison.Ordinal) != -1) { lang = lang.Substring(2); if (Contents.ContainsKey(lang)) { return(GetContent(lang)); } } return(null); }
/// <summary> /// Возвращает контент по имени /// </summary> /// <param name="contentName"></param> /// <returns></returns> public DataTable GetContent(string contentName) { if (string.IsNullOrEmpty(contentName)) { throw new ArgumentNullException("contentName"); } if (Contents == null || Contents.Count == 0) { return(null); } if (Contents.ContainsKey(contentName)) { return(Contents[contentName]); } return(null); }
/// <summary> /// Fügt eine Eigenschaft hinzu /// </summary> /// <param name="key">Name der Eigenschaft</param> /// <param name="value">Wert der Eigenschaft</param> public void Add(string key, string value) { if (String.IsNullOrEmpty(key)) { throw new Exception("Schlüssel ist Null oder leer"); } if (Contents.ContainsKey(key)) { throw new Exception("Schlüssel bereits vorhanden!"); } foreach (char ch in key) { if (!AllowedCharactersForKey.Contains(ch)) { throw new Exception("Key contains not supported characters!"); } } Contents.Add(key, value); }
public override short Initialize(string path) { string tmpFullPath = string.Format("{0}\\{1}", path, "wcctext2.dat"); ContentType = ContentTypes.TextBlocks; if (File.Exists(tmpFullPath) == true) { LogManager.Log("Loading {0} from {1}", ContentType.ToString(), tmpFullPath); FileName = BtrieveUtility.ConvertFileName(tmpFullPath); TextBlockType RecordData = new TextBlockType(); RecordSize = Marshal.SizeOf(RecordData); Status = BTRCALL(BtrieveTypes.BtrieveActionType.BOPEN, PositionBlock, ref RecordData, ref RecordSize, FileName, 0, 0); Status = BTRCALL(BtrieveTypes.BtrieveActionType.BGETFIRST, PositionBlock, ref RecordData, ref RecordSize, FileName, 0, 0); if (Status == BtrieveTypes.BtrieveStatus.COMPLETE_SUCCESSFULLY) { if (Contents.ContainsKey(RecordData.Number) == false) { Contents.Add(RecordData.Number, new Dictionary <short, TextBlockType>()); } Contents.Storage[RecordData.Number].Add(RecordData.PartNum, RecordData); } else { Console.WriteLine("Error: {0}", Status); } while (Status != BtrieveTypes.BtrieveStatus.END_OF_FILE) { Status = BTRCALL(BtrieveTypes.BtrieveActionType.BGETNEXT, PositionBlock, ref RecordData, ref RecordSize, FileName, 0, 0); if (Status == BtrieveTypes.BtrieveStatus.END_OF_FILE) { Status = (short)BtrieveTypes.BtrieveStatus.COMPLETE_SUCCESSFULLY; break; } if (Status == BtrieveTypes.BtrieveStatus.COMPLETE_SUCCESSFULLY) { if (Contents.ContainsKey(RecordData.Number) == false) { Contents.Add(RecordData.Number, new Dictionary <short, TextBlockType>()); } Contents.Storage[RecordData.Number].Add(RecordData.PartNum, RecordData); } else { Console.WriteLine("Error: {0}", Status); } } } else { LogManager.Log("Could not find file {0}", tmpFullPath); } LogManager.Log("Number of {0} loaded: {1}. Status = {2}", ContentType.ToString(), Count, BtrieveTypes.BtrieveErrorCode(Status)); return(Status); }
/// <summary> /// Bestimmt, ob die Datei den angegebenen Schlüssel enthält /// </summary> /// <param name="key">Der zu suchende Schlüssel</param> /// <returns></returns> public bool ContainsKey(string key) { return(Contents.ContainsKey(key)); }