public static IHtmlString Get(this LocalizationHelper helper, string key, params object[] replaceValues)
        {
            var parsedResource = ResourceParser.Parse(key);
            var resourceValue  = helper.HtmlHelper.ViewContext.HttpContext.GetGlobalResourceObject(parsedResource.ResourceSet, parsedResource.ResourceKey).ToString();

            return(helper.HtmlHelper.Raw(ResourceFormatter.Format(resourceValue, replaceValues)));
        }
Пример #2
0
    void UpdateGoldCost(Dictionary <string, Resource> resources)
    {
        GoldResource gold = (GoldResource)resources[ResourceType.GOLD];

        Text goldCost = GameObject.Find(UIConstants.UPGRADE_ARMY_COST)
                        .GetComponent <Text>();

        goldCost.text = ResourceFormatter.Format(gold.upgradeCost) + " " +
                        UIConstants.ARMY_SYMBOL;
    }
Пример #3
0
    void UpdateArmyCost(Dictionary <string, Resource> resources)
    {
        ArmyResource army = (ArmyResource)resources[ResourceType.ARMY];

        Text armyCost = GameObject.Find(UIConstants.UPGRADE_GOLD_COST)
                        .GetComponent <Text>();

        armyCost.text = ResourceFormatter.Format(army.upgradeCost) + " " +
                        UIConstants.GOLD_SYMBOL;
    }
Пример #4
0
    void UpdateResource(Dictionary <string, Resource> resources,
                        string textKey,
                        string resourceKey)
    {
        Text resourceText = GameObject.Find(textKey)
                            .GetComponent <Text>();
        Resource resource = resources[resourceKey];

        resourceText.text = ResourceFormatter.Format(resource.currentAmount);
    }
Пример #5
0
        /// <summary>
        /// This builds a list of resource entries within the containing node.
        /// </summary>
        /// <param name="containerNode">The containing HTML node.</param>
        /// <param name="resourceItems">The resources.</param>
        private static void RenderTargetApplicationResources(HtmlNode containerNode, IList <TargetResourceTemplate> resourceItems)
        {
            // Return if no resources
            if (resourceItems == null || resourceItems.Count == 0)
            {
                return;
            }

            // Sort
            var resources = resourceItems.ToList();

            resources.Sort(Comparers.SortTargetResourceTemplatesByTypeAndName);

            // Create a header entry
            var sectionNode = HtmlNode.CreateNode(HtmlResources.SnippetEmptyDiv);

            sectionNode.InnerHtml = string.Format(CultureInfo.CurrentCulture, HtmlResources.ApplicationSubsectionHeading, HtmlResources.TargetResourceSectionResources, HtmlResources.TargetResourceSectionResources);
            containerNode.AppendChild(sectionNode);

            // Iterate through the resource definitions
            foreach (var resource in resources)
            {
                var snippet = HtmlResources.TargetResourceSnippet;
                var refId   = Guid.NewGuid().ToString();
                snippet = snippet.Replace("{icon}", ResourceFormatter.GetTargetResourceIconFromType(resource.ResourceType));
                snippet = snippet.Replace("{refId}", refId);
                snippet = snippet.Replace("{type}", ResourceFormatter.GetTargetResourceFriendlyName(resource.ResourceType));

                // Build the description rows.
                var descriptionBuilder = new StringBuilder();
                descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyResourceName, resource.ResourceName));
                descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyResourceType, resource.ResourceType));
                descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyTemplateType, resource.TemplateType));
                descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyTemplateKey, resource.TemplateKey));
                snippet = snippet.Replace("{description}", descriptionBuilder.ToString());

                var node = CreateNodeWithSnippetContent(snippet);
                containerNode.AppendChild(node);
            }
        }
Пример #6
0
 /// <summary>
 /// Writes the resources associated with the item.
 /// </summary>
 /// <param name="containerNode">The HTML container to render into.</param>
 /// <param name="messagingObject">The messaging object.</param>
 private static void RenderMessagingObjectResources(HtmlNode containerNode, MessagingObject messagingObject)
 {
     containerNode.AppendChild(CreateNodeWithSnippetContent(string.Format(CultureInfo.CurrentCulture, HtmlResources.AnalysisSnippetHeading, HtmlResources.AnalysisHeadingResources)));
     if (messagingObject.Resources == null || messagingObject.Resources.Count == 0)
     {
         // Add a placeholder if there are no relationships.
         containerNode.AppendChild(CreateNodeWithSnippetContent(string.Format(CultureInfo.CurrentCulture, HtmlResources.AnalysisSnippetInformationMessage, HtmlResources.AnalysisMessageNoResources)));
     }
     else
     {
         foreach (var resource in messagingObject.Resources)
         {
             containerNode.AppendChild(
                 CreateNodeWithSnippetContent(
                     string.Format(
                         CultureInfo.CurrentCulture,
                         HtmlResources.AnalysisSnippetTargetResource,
                         ResourceFormatter.GetTargetResourceIconFromType(resource.ResourceType),
                         ResourceFormatter.GetTargetResourceFriendlyName(resource.ResourceType),
                         resource.ResourceName)));
         }
     }
 }