protected override void InnerReplaceValues(Dictionary <Value, Value> originalReplace) { if (originalReplace.ContainsKey(resourceValue)) { resourceValue = (ResourceValue)originalReplace[resourceValue]; } }
private async Task <Attribute_> readAttribute() { int nsRef = buffer.getInt(); int nameRef = buffer.getInt(); Attribute_ attribute = new Attribute_(); if (nsRef > 0) { attribute.setNamespace(stringPool.get(nsRef)); } attribute.setName(stringPool.get(nameRef)); if (attribute.getName().Equals(string.Empty) && resourceMap != null && nameRef < resourceMap.Length) { // some processed apk file make the string pool value empty, if it is a xmlmap attr. attribute.setName(resourceMap[nameRef]); //TODO: how to get the namespace of attribute } int rawValueRef = buffer.getInt(); if (rawValueRef > 0) { attribute.setRawValue(stringPool.get(rawValueRef)); } ResourceValue resValue = await ParseUtils.readResValue(buffer, stringPool); attribute.setTypedValue(resValue); return(attribute); }
public static ListValue PartList(this IShipconstruct vessel, string partType, SharedObjects sharedObj) { var list = new ListValue(); var partList = vessel.Parts.ToList(); switch (partType.ToUpper()) { case "RESOURCES": list = ResourceValue.PartsToList(partList); break; case "PARTS": list = PartValue.PartsToList(partList, sharedObj); break; case "ENGINES": list = EngineValue.PartsToList(partList, sharedObj); break; case "SENSORS": list = SensorValue.PartsToList(partList, sharedObj); break; case "ELEMENTS": list = ElementValue.PartsToList(partList); break; case "DOCKINGPORTS": list = DockingPortValue.PartsToList(partList, sharedObj); break; } return(list); }
/// <inheritdoc /> public override void VisitResourceValue(ResourceValue value) { integerIndex = null; stringIndex = null; isNotConvertibleToInteger = true; isCompoundValue = false; }
protected void NewResource(string key, string value, params object[] args) { if (_session == null) { throw new FaraException("Before installing new resource key/value you should initialize session field."); } var resourceKey = new ResourceKey { Key = key }; var resourceValue = new ResourceValue(); if (args != null && args.Length > 0) { resourceValue.Value = string.Format(value, args); } else { resourceValue.Value = value; } resourceKey.Values.Add(resourceValue); _session.Insert(resourceKey); }
/// <summary> /// The entrypoint method delegates to helper methods for each of the types of tables /// found in the currency data. /// </summary> public override void Put(ResourceKey key, ResourceValue value, bool isRoot) { if (noRoot && isRoot) { // Don't consume the root bundle return; } switch (entrypointTable) { case EntrypointTable.TOP: ConsumeTopTable(key, value); break; case EntrypointTable.CURRENCIES: ConsumeCurrenciesEntry(key, value); break; case EntrypointTable.CURRENCY_PLURALS: ConsumeCurrencyPluralsEntry(key, value); break; case EntrypointTable.CURRENCY_NARROW: ConsumeCurrenciesNarrowEntry(key, value); break; case EntrypointTable.CURRENCY_SPACING: ConsumeCurrencySpacingTable(key, value); break; case EntrypointTable.CURRENCY_UNIT_PATTERNS: ConsumeCurrencyUnitPatternsTable(key, value); break; } }
/// <inheritdoc /> public override void VisitResourceValue(ResourceValue value) { // Every binary operation converts resource to another type, but conversion to another type // makes no sence expect boolean that is always true. Thou we do not need concrete resource. resourceVisitor.SetLeftOperand(OutSet.AnyResourceValue); visitor = resourceVisitor; }
public void SetData(string name, ResourceValue cost, int buildPtCost, Texture2D icon) { this.Name = name; this.cost = cost; this.buildPointCost = buildPtCost; this.Icon = icon; }
public List <ResourceValue> GetValues() { List <ResourceValue> consolidatedCosts = new List <ResourceValue>(); foreach (IResourceValue resourceCost in resourceValues) { List <ResourceValue> costs = resourceCost.GetValue(); foreach (ResourceValue cost in costs) { bool found = false; for (int i = 0; i < consolidatedCosts.Count; i++) { if (consolidatedCosts[i].resource == cost.resource) { consolidatedCosts[i] = new ResourceValue() { resource = cost.resource, value = consolidatedCosts[i].value + cost.value }; found = true; continue; } } if (!found) { consolidatedCosts.Add(cost); } } } return(consolidatedCosts); }
public override void Put(ResourceKey key, ResourceValue value, bool noFallback) { IResourceTable contextsTable = value.GetTable(); for (int i = 0; contextsTable.GetKeyAndValue(i, key, value); ++i) { if (!contextUsageTypeMap.TryGetValue(key.ToString(), out CapitalizationContextUsage usage)) { continue; } int[] intVector = value.GetInt32Vector(); if (intVector.Length < 2) { continue; } int titlecaseInt = (dataTableCultureDisplayNames.displayContextOptions.Capitalization == Capitalization.UIListOrMenu) ? intVector[0] : intVector[1]; if (titlecaseInt == 0) { continue; } dataTableCultureDisplayNames.capitalizationUsage[(int)usage] = true; hasCapitalizationUsage = true; } }
private static ResourceValue GetInstance() { if (instance == null) { instance = FindObjectOfType <ResourceValue>(); } return(instance); }
public ResourceKeyQuery WithValue(ResourceValue value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, CollectionOperator @operator = CollectionOperator.Equal, CollectionDirection direction = CollectionDirection.Any) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case CollectionOperator.Equal: switch (direction) { case CollectionDirection.Any: Entities = Entities.Where(rk => rk.Values.Any(rv => rv == value)); return(this); case CollectionDirection.All: Entities = Entities.Where(rk => rk.Values.All(rv => rv == value)); return(this); default: throw new NotSupportedEnumException(direction); } case CollectionOperator.NotEqual: switch (direction) { case CollectionDirection.Any: Entities = Entities.Where(rk => rk.Values.Any(rv => rv != value)); return(this); case CollectionDirection.All: Entities = Entities.Where(rk => rk.Values.All(rv => rv != value)); return(this); default: throw new NotSupportedEnumException(direction); } default: throw new NotSupportedEnumException(@operator); } }
public void Gather(ResourceType type, float amount) { ResourceValue resource = resolveType(type); if (resource.CanGather(amount)) { resource.Gather(amount); } }
/// <summary> /// Currencies%narrow{ /// AOA{"Kz"} /// ARS{"$"} /// ... /// } /// </summary> internal void ConsumeCurrenciesNarrowEntry(ResourceKey key, ResourceValue value) { Debug.Assert(narrowSymbol != null); // No extra structure to traverse. if (narrowSymbol.narrowSymbol == null) { narrowSymbol.narrowSymbol = value.GetString(); } }
public void SetData(string name, int shipCount, ResourceValue cost, int buildPtCost, string icon, Ship ship) { Name = name; ShipCount = shipCount; this.cost = cost; buildPointCost = buildPtCost; Icon = (Texture2D)Resources.Load(icon); isSelected = false; }
private ValueNode CreateValueNode(TreeNode parent, ResourceValue value) { ValueNode result = new ValueNode(value); result.ImageIndex = this.ImageList.Images.IndexOfKey(ResourceTreeView.BINARY_NODE); result.SelectedImageIndex = result.ImageIndex; parent.Nodes.Add(result); return(result); }
/** * read res value, convert from different types to string. */ public static async Task <ResourceValue> readResValue(ByteBuffer buffer, StringPool stringPool) { // ResValue resValue = new ResValue(); int size = await Buffers.readUShort(buffer); short res0 = Buffers.readUByte(buffer); short dataType = Buffers.readUByte(buffer); switch (dataType) { case ResValue.ResType.INT_DEC: return(ResourceValue.decimal_(buffer.getInt())); case ResValue.ResType.INT_HEX: return(ResourceValue.hexadecimal(buffer.getInt())); case ResValue.ResType.STRING: int strRef = buffer.getInt(); if (strRef >= 0) { return(ResourceValue.string_(strRef, stringPool)); } else { return(null); } case ResValue.ResType.REFERENCE: return(ResourceValue.reference(buffer.getInt())); case ResValue.ResType.INT_BOOLEAN: return(ResourceValue.bool_(buffer.getInt())); case ResValue.ResType.NULL: return(ResourceValue.nullValue()); case ResValue.ResType.INT_COLOR_RGB8: case ResValue.ResType.INT_COLOR_RGB4: return(ResourceValue.rgb(buffer.getInt(), 6)); case ResValue.ResType.INT_COLOR_ARGB8: case ResValue.ResType.INT_COLOR_ARGB4: return(ResourceValue.rgb(buffer.getInt(), 8)); case ResValue.ResType.DIMENSION: return(ResourceValue.dimension(buffer.getInt())); case ResValue.ResType.FRACTION: return(ResourceValue.fraction(buffer.getInt())); default: return(ResourceValue.raw(buffer.getInt(), dataType)); } }
/// <summary> /// Currencies%variant{ /// TRY{"TL"} /// } /// </summary> internal void ConsumeCurrenciesVariantTable(ResourceKey key, ResourceValue value) { // Note: This data is used for parsing but not formatting. Debug.Assert(parsingData != null); IResourceTable table = value.GetTable(); for (int i = 0; table.GetKeyAndValue(i, key, value); i++) { string isoCode = key.ToString(); parsingData.symbolToIsoCode[value.GetString()] = isoCode; } }
bool AddResourcePool(ResourceData resource, float amount) { if (resourcePoolsDict.ContainsKey(resource.key)) { return(false); } ResourceValue rv = new ResourceValue(resource, amount); m_resourcePoolsList.Add(rv); m_resourcePoolsDict.Add(resource.key, rv); return(true); }
bool AddResourceRateInternal(ResourceData resource, float rate) { if (resourceRatesDict.ContainsKey(resource.key)) { return(false); } ResourceValue rv = new ResourceValue(resource, rate); m_resourceRatesList.Add(rv); m_resourceRatesDict.Add(resource.key, rv); return(true); }
/// <summary> /// CurrencyUnitPatterns{ /// other{"{0} {1}"} /// ... /// } /// </summary> internal void ConsumeCurrencyUnitPatternsTable(ResourceKey key, ResourceValue value) { Debug.Assert(unitPatterns != null); IResourceTable table = value.GetTable(); for (int i = 0; table.GetKeyAndValue(i, key, value); i++) { string pluralKeyword = key.ToString(); if (!unitPatterns.TryGetValue(pluralKeyword, out string unitPattern) || unitPattern == null) { unitPatterns[pluralKeyword] = value.GetString(); } } }
void Start() { ResourceValue[] resources = FindObjectsOfType <ResourceValue>(); gas = Array.Find(resources, resource => resource.Type == ResourceType.Gas); minerals = Array.Find(resources, resource => resource.Type == ResourceType.Minerals); supplies = Array.Find(resources, resource => resource.Type == ResourceType.Supplies); definition = GetComponent <ObjectDefinition>(); supplies.AddCapacity(definition.SupplyCapacity); }
/// <summary> /// currencySpacing{ /// afterCurrency{ /// currencyMatch{"[:^S:]"} /// insertBetween{" "} /// surroundingMatch{"[:digit:]"} /// } /// beforeCurrency{ /// currencyMatch{"[:^S:]"} /// insertBetween{" "} /// surroundingMatch{"[:digit:]"} /// } /// } /// </summary> internal void ConsumeCurrencySpacingTable(ResourceKey key, ResourceValue value) { Debug.Assert(spacingInfo != null); IResourceTable spacingTypesTable = value.GetTable(); for (int i = 0; spacingTypesTable.GetKeyAndValue(i, key, value); ++i) { CurrencySpacingInfo.SpacingType type; if (key.ContentEquals("beforeCurrency")) { type = CurrencySpacingInfo.SpacingType.Before; spacingInfo.HasBeforeCurrency = true; } else if (key.ContentEquals("afterCurrency")) { type = CurrencySpacingInfo.SpacingType.After; spacingInfo.HasAfterCurrency = true; } else { continue; } IResourceTable patternsTable = value.GetTable(); for (int j = 0; patternsTable.GetKeyAndValue(j, key, value); ++j) { CurrencySpacingInfo.SpacingPattern pattern; if (key.ContentEquals("currencyMatch")) { pattern = CurrencySpacingInfo.SpacingPattern.CurrencyMatch; } else if (key.ContentEquals("surroundingMatch")) { pattern = CurrencySpacingInfo.SpacingPattern.SurroundingMatch; } else if (key.ContentEquals("insertBetween")) { pattern = CurrencySpacingInfo.SpacingPattern.InsertBetween; } else { continue; } spacingInfo.SetSymbolIfNull(type, pattern, value.GetString()); } } }
public override string ToString() { if (ResourceValue == null) { return("(Nothing/null)"); } string type = ResourceValue.GetType().FullName; string tmp = String.Empty; switch (type) { case "System.String": tmp = ResourceValue.ToString(); break; case "System.Byte[]": tmp = "[Size = " + ((byte[])ResourceValue).Length + "]"; break; case "System.Drawing.Bitmap": Bitmap bmp = ResourceValue as Bitmap; tmp = "[Width = " + bmp.Size.Width + ", Height = " + bmp.Size.Height + "]"; break; case "System.Drawing.Icon": Icon icon = ResourceValue as Icon; tmp = "[Width = " + icon.Size.Width + ", Height = " + icon.Size.Height + "]"; break; case "System.Windows.Forms.Cursor": Cursor c = ResourceValue as Cursor; tmp = "[Width = " + c.Size.Width + ", Height = " + c.Size.Height + "]"; break; case "System.Boolean": tmp = ResourceValue.ToString(); break; default: tmp = ResourceValue.ToString(); break; } return(tmp); }
internal void ConsumeCurrencyPluralsEntry(ResourceKey key, ResourceValue value) { Debug.Assert(pluralsData != null); IResourceTable pluralsTable = value.GetTable(); for (int j = 0; pluralsTable.GetKeyAndValue(j, key, value); j++) { StandardPlural?plural = StandardPluralUtil.OrNullFromString(key.ToString()); if (plural == null) { throw new ICUException("Could not make StandardPlural from keyword " + key); } if (pluralsData[1 + (int)plural] == null) { pluralsData[1 + (int)plural] = value.GetString(); } } }
private void ConsumeTopTable(ResourceKey key, ResourceValue value) { IResourceTable table = value.GetTable(); for (int i = 0; table.GetKeyAndValue(i, key, value); i++) { if (key.ContentEquals("Currencies")) { ConsumeCurrenciesTable(key, value); } else if (key.ContentEquals("Currencies%variant")) { ConsumeCurrenciesVariantTable(key, value); } else if (key.ContentEquals("CurrencyPlurals")) { ConsumeCurrencyPluralsTable(key, value); } } }
/// <inheritdoc /> public override void VisitResourceValue(ResourceValue value) { switch (operation) { case Operations.Plus: result = OutSet.AnyIntegerValue; break; case Operations.Minus: result = OutSet.AnyIntegerValue; break; case Operations.LogicNegation: result = OutSet.CreateBool(!TypeConversion.ToBoolean(value)); break; case Operations.BitNegation: // TODO: This must be fatal error SetWarning("Unsupported operand types: Bit negation of resource reference"); result = OutSet.AnyValue; break; case Operations.Int32Cast: result = OutSet.AnyIntegerValue; break; case Operations.FloatCast: case Operations.DoubleCast: result = OutSet.AnyFloatValue; break; default: if (PerformUsualOperation(value)) { break; } base.VisitResourceValue(value); break; } }
/// <summary> /// Currencies{ /// ... /// USD{ /// "US$", => symbol /// "US Dollar", => display name /// } /// ... /// ESP{ /// "₧", => symbol /// "pesseta espanyola", => display name /// { /// "¤ #,##0.00", => currency-specific pattern /// ",", => currency-specific grouping separator /// ".", => currency-specific decimal separator /// } /// } /// ... /// } /// </summary> internal void ConsumeCurrenciesTable(ResourceKey key, ResourceValue value) { // The full Currencies table is consumed for parsing only. Debug.Assert(parsingData != null); IResourceTable table = value.GetTable(); for (int i = 0; table.GetKeyAndValue(i, key, value); i++) { string isoCode = key.ToString(); if (value.Type != UResourceType.Array) { throw new ICUException("Unexpected data type in Currencies table for " + isoCode); } IResourceArray array = value.GetArray(); parsingData.symbolToIsoCode[isoCode] = isoCode; // Add the ISO code itself as a symbol array.GetValue(0, value); parsingData.symbolToIsoCode[value.GetString()] = isoCode; array.GetValue(1, value); parsingData.nameToIsoCode[value.GetString()] = isoCode; } }
/// <summary> /// CurrencyPlurals{ /// BYB{ /// one{"Belarusian new rouble (1994–1999)"} /// other{"Belarusian new roubles (1994–1999)"} /// } /// ... /// } /// </summary> internal void ConsumeCurrencyPluralsTable(ResourceKey key, ResourceValue value) { // The full CurrencyPlurals table is consumed for parsing only. Debug.Assert(parsingData != null); IResourceTable table = value.GetTable(); for (int i = 0; table.GetKeyAndValue(i, key, value); i++) { string isoCode = key.ToString(); IResourceTable pluralsTable = value.GetTable(); for (int j = 0; pluralsTable.GetKeyAndValue(j, key, value); j++) { StandardPlural?plural = StandardPluralUtil.OrNullFromString(key.ToString()); if (plural == null) { throw new ICUException("Could not make StandardPlural from keyword " + key); } parsingData.nameToIsoCode[value.GetString()] = isoCode; } } }
internal void ConsumeCurrenciesEntry(ResourceKey key, ResourceValue value) { Debug.Assert(formattingData != null); string isoCode = key.ToString(); if (value.Type != UResourceType.Array) { throw new ICUException("Unexpected data type in Currencies table for " + isoCode); } IResourceArray array = value.GetArray(); if (formattingData.symbol == null) { array.GetValue(0, value); formattingData.symbol = value.GetString(); } if (formattingData.displayName == null) { array.GetValue(1, value); formattingData.displayName = value.GetString(); } // If present, the third element is the currency format info. // TODO: Write unit test to ensure that this data is being used by number formatting. if (array.Length > 2 && formattingData.formatInfo == null) { array.GetValue(2, value); IResourceArray formatArray = value.GetArray(); formatArray.GetValue(0, value); string formatPattern = value.GetString(); formatArray.GetValue(1, value); string decimalSeparator = value.GetString(); formatArray.GetValue(2, value); string groupingSeparator = value.GetString(); formattingData.formatInfo = new CurrencyFormatInfo( isoCode, formatPattern, decimalSeparator, groupingSeparator); } }
public bool Buy(ResourceValue resourceValue) { return true; }
public void setTypedData(ResourceValue typedData) { this.typedData = typedData; }
public void setResValue(ResourceValue resValue) { this.resValue = resValue; }