Exemple #1
0
        public static bool Update(ResourceCategory data)
        {
            int rs = DataProvider.Instance.ExecuteNonQuery("RecourceCategory_Update",
                                                           data.ID, data.Name, data.Description);

            return(rs > 0);
        }
Exemple #2
0
        public string GetMembershipResource(ResourceCategory category, ResourceFile type)
        {
            // For reasons of backwards compatibility, we first check to see if some joker decided to ember the resource inside web.config
            string resource = ConfigurationManager.AppSettings[$"{category}{type}"];

            if (!String.IsNullOrEmpty(resource))
            {
                return(resource);
            }

            if (HttpContext.Current == null)
            {
                throw new GOServerException <WebContextRequired>();
            }

            // Look for custom version of the resource first, fall back on default version if no custom found
            string path = HttpContext.Current.Request.MapPath($"~/Membership/Resources/{ResourceLanguage}/{category}/custom/{type}");

            if (!File.Exists(path))
            {
                path = HttpContext.Current.Request.MapPath($"~/Membership/Resources/{ResourceLanguage}/{category}/default/{type}");
            }

            if (!File.Exists(path))
            {
                throw new GOServerException <MembershipConfigurationError>();
            }

            return(File.ReadAllText(path));
        }
Exemple #3
0
        public ActionResult Create(int?resourceTypeId)
        {
            ResourceType resourceType = null;

            if (resourceTypeId.HasValue)
            {
                resourceType = CurrentDatabase.ResourceTypes.FirstOrDefault(x => x.ResourceTypeId == resourceTypeId);
            }

            if (resourceType == null)
            {
                resourceType = CurrentDatabase.ResourceTypes.FirstOrDefault();
            }

            if (resourceType == null)
            {
                Util.TempError = "You need to configure at least one Resource Type first.";
                return(Redirect("~/ResourceCategories"));
            }

            var ResourceCategory = new ResourceCategory {
                Name = "new resource category", ResourceTypeId = resourceType.ResourceTypeId
            };

            CurrentDatabase.ResourceCategories.InsertOnSubmit(ResourceCategory);
            CurrentDatabase.SubmitChanges();
            return(Redirect($"/ResourceCategories/#{ResourceCategory.ResourceCategoryId}"));
        }
Exemple #4
0
        private void CreateEmailContent(ResourceCategory category, GOUserDataObject user, string link, bool withToken, out string subject, out string content)
        {
            // Note the following throw exceptions if resource missing (so no need to check again here)
            subject = GetMembershipResource(category, ResourceFile.Subject);
            content = GetMembershipResource(category, ResourceFile.Content);

            if (withToken)
            {
                string token = Authentication.CreateToken(
                    new Claim[] {
                    new Claim(ClaimTypes.Email, user.EmailAddress),
                    new Claim(ClaimTypes.Role, "Subscriber"),
                },
                    DateTime.Now.AddMinutes(AppSettings.Get <int>(EmailTokenExpiry, 15))
                    );
                link = $"{link}?key={token}";
            }

            subject = ExpandTemplatePlaceholders(subject, user);
            content = ExpandTemplatePlaceholders(content, user);

            content = content.Replace("%LINK%", link);
            content = content.Replace("%EMAIL%", user.EmailAddress);

            content = AddEmailTemplate(content);
        }
Exemple #5
0
        private unsafe void DrawResourceMap(ResourceCategory category, uint ext, StdMap <uint, Pointer <ResourceHandle> > *map)
        {
            if (map == null)
            {
                return;
            }

            var label = GetNodeLabel(( uint )category, ext, map->Count);

            using var tree = ImRaii.TreeNode(label);
            if (!tree || map->Count == 0)
            {
                return;
            }

            using var table = ImRaii.Table("##table", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
            if (!table)
            {
                return;
            }

            ImGui.TableSetupColumn("Hash", ImGuiTableColumnFlags.WidthFixed, _hashColumnWidth);
            ImGui.TableSetupColumn("Ptr", ImGuiTableColumnFlags.WidthFixed, _hashColumnWidth);
            ImGui.TableSetupColumn("Path", ImGuiTableColumnFlags.WidthFixed, _pathColumnWidth);
            ImGui.TableSetupColumn("Refs", ImGuiTableColumnFlags.WidthFixed, _refsColumnWidth);
            ImGui.TableHeadersRow();

            ResourceLoader.IterateResourceMap(map, (hash, r) =>
            {
                // Filter unwanted names.
                if (_resourceManagerFilter.Length != 0 &&
                    !r->FileName.ToString().Contains(_resourceManagerFilter, StringComparison.InvariantCultureIgnoreCase))
                {
                    return;
                }

                var address = $"0x{( ulong )r:X}";
                ImGuiUtil.TextNextColumn($"0x{hash:X8}");
                ImGui.TableNextColumn();
                ImGuiUtil.CopyOnClickSelectable(address);

                var resource = (Interop.Structs.ResourceHandle *)r;
                ImGui.TableNextColumn();
                Text(resource);
                if (ImGui.IsItemClicked())
                {
                    var data = Interop.Structs.ResourceHandle.GetData(resource);
                    if (data != null)
                    {
                        var length = ( int )Interop.Structs.ResourceHandle.GetLength(resource);
                        ImGui.SetClipboardText(string.Join(" ",
                                                           new ReadOnlySpan <byte>(data, length).ToArray().Select(b => b.ToString("X2"))));
                    }
                }

                ImGuiUtil.HoverTooltip("Click to copy byte-wise file data to clipboard, if any.");

                ImGuiUtil.TextNextColumn(r->RefCount.ToString());
            });
        }
        public static ResourceCategory CreateResourceCategory(string dataAreaId,
                                                              string roleId,
                                                              global::Microsoft.Dynamics.DataEntities.ProjectEmplForecast projectEmplForecast,
                                                              global::Microsoft.Dynamics.DataEntities.ProjectExpenseForecast projectExpenseForecast,
                                                              global::Microsoft.Dynamics.DataEntities.ProjectFeeForecast projectFeeForecast,
                                                              global::Microsoft.Dynamics.DataEntities.JournalTrans journalTrans)
        {
            ResourceCategory resourceCategory = new ResourceCategory();

            resourceCategory.dataAreaId = dataAreaId;
            resourceCategory.RoleId     = roleId;
            if ((projectEmplForecast == null))
            {
                throw new global::System.ArgumentNullException("projectEmplForecast");
            }
            resourceCategory.ProjectEmplForecast = projectEmplForecast;
            if ((projectExpenseForecast == null))
            {
                throw new global::System.ArgumentNullException("projectExpenseForecast");
            }
            resourceCategory.ProjectExpenseForecast = projectExpenseForecast;
            if ((projectFeeForecast == null))
            {
                throw new global::System.ArgumentNullException("projectFeeForecast");
            }
            resourceCategory.ProjectFeeForecast = projectFeeForecast;
            if ((journalTrans == null))
            {
                throw new global::System.ArgumentNullException("journalTrans");
            }
            resourceCategory.JournalTrans = journalTrans;
            return(resourceCategory);
        }
Exemple #7
0
        private static void FlattenCategoriesHelper(ResourceCategory cat, ResourceCategory destCat, HashSet <Tag> tagSet)
        {
            if (cat.Depth > 1)
            {
                var tag = new Tag
                {
                    Name = cat.CategoryName,
                };
                if (!tagSet.Contains(tag))
                {
                    tag.ResourceTags = new List <ResourceTag>();
                    tagSet.Add(tag);
                }

                //TODO: get the tag from the collection if already exists.

                foreach (var resource in cat.Resources.ToList())
                {
                    cat.Resources.Remove(resource);
                    resource.Category = destCat;
                    destCat.Resources.Add(resource);
                    tag.ResourceTags.Add(new ResourceTag
                    {
                        Resource = resource,
                        Tag      = tag
                    });
                }
            }

            // TODO: convert current resource category to tags
            foreach (var subCat in cat.ChildrenCategories)
            {
                FlattenCategoriesHelper(subCat, destCat, tagSet);
            }
        }
Exemple #8
0
 public ResourceInfo(RareResourceID resourceID, ResourceCategory category, string imageFilename, AtlasID atlasID, string description) {
     ResourceID = resourceID;
     Category = category;
     ImageFilename = imageFilename;
     AtlasID = atlasID;
     Description = description;
 }
 public ResourceLoaderAttribute(ResourceType type, ResourceCategory category, string propertyName = null, string resourceName = null)
 {
     Type         = type;
     Category     = category;
     PropertyName = propertyName;
     ResourceName = resourceName;
 }
Exemple #10
0
        public IActionResult DeleteCategory(int categoryId)
        {
            ResourceCategory categoryToDel = repository.Categories.First(c => c.ID == categoryId);

            try
            {
                repository.DeleteCategory(categoryId);
            }
            catch (DbUpdateException ex)
            {
                var innerException = ex.InnerException.InnerException as MySql.Data.MySqlClient.MySqlException;
                if (innerException != null && innerException.Number == 1451)
                {
                    TempData["Error"] = $"Не удалось удалить категорию <strong>{categoryToDel.Name}</strong>: на неё есть ссылки в других объектах.";
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    throw;
                }
            }
            catch
            {
                throw;
            }
            TempData["Success"] = $"Категория <strong>{categoryToDel.Name}</strong> успешно удалена.";
            return(RedirectToAction(nameof(Index)));
        }
Exemple #11
0
        public ActionResult AddCat(ResourceCategory cat)
        {
            cat.CategoryID = ResourceCatRepo.GetCollections().Select(c => c.CategoryID).Max() + 1;

            ResourceCatRepo.Add(cat);
            return(RedirectToAction("ExpCatMgr"));
        }
Exemple #12
0
        public JsonNetResult CreateCategory(List <TranslatedCategory> transdesc, Guid?parentID)
        {
            try
            {
                //2015-09-08
                //Ivan S.
                //66
                //Sets the initial order for the new category to the maximum number for all the categories
                var lastCategory      = Exigo.GetResourceCategories(new GetResourceCategoriesRequest()).OrderByDescending(rc => rc.CategoryOrder).FirstOrDefault();
                int?lastCategoryOrder = InitialOrderValue - 1;
                if (lastCategory != null)
                {
                    lastCategoryOrder = lastCategory.CategoryOrder;
                }
                var NewOrder   = ++lastCategoryOrder;
                var CategoryID = Guid.NewGuid();
                if (parentID == null)
                {
                    parentID = Guid.Empty;
                }
                foreach (var description in transdesc)
                {
                    //English is the Default Language and will be used as the Description on the Categories Table
                    if (description.Language == "English")
                    {
                        ResourceCategory Category = new ResourceCategory()
                        {
                            CategoryID          = CategoryID,
                            CategoryDescription = description.TranslatedCategoryDescription,
                            CategoryOrder       = NewOrder,
                            ParentID            = (Guid)parentID
                        };
                        Exigo.AddResourceCategory(Category);
                    }
                    //Adds an entry for each language translation provided in the TranslatedCategoryItems table
                    ResourceTranslatedCategoryItem TCategory = new ResourceTranslatedCategoryItem()
                    {
                        TranslatedCategoryID          = Guid.NewGuid(),
                        CategoryID                    = CategoryID,
                        Language                      = description.Language,
                        TranslatedCategoryDescription = description.TranslatedCategoryDescription
                    };
                    Exigo.AddCategoryTranslation(TCategory);
                }

                return(new JsonNetResult(new
                {
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
Exemple #13
0
 public ResourceCategoryViewModel(ResourceCategory category)
 {
     Id            = category.ResourceCategoryId;
     Name          = category.ResourceCategoryName;
     ResourceTypes = category.ResourceTypes != null
         ? category.ResourceTypes.Select(x => new ResourceTypeViewModel(x)).ToList()
         : new List <ResourceTypeViewModel>();
 }
 public OnlineResource(string title, decimal unitCost, ResourceCategory resourceCategory)
 {
     ResourceID   = Guid.NewGuid().GetHashCode();
     QuantitySold = 0;
     Title        = title;
     UnitCost     = unitCost;
     ResourceType = resourceCategory;
 }
Exemple #15
0
        public IActionResult MoveCategory(int categoryId, int newParentId)
        {
            ResourceCategory cat = repository.Categories.FirstOrDefault(c => c.ID == categoryId);

            cat.ParentCategoryID = newParentId;
            repository.SaveCategory(cat);
            TempData["Success"] = $"Категория <strong>{cat.Name}</strong> перемещена.";
            return(RedirectToAction(nameof(Index), new { categoryId = cat.ID }));
        }
Exemple #16
0
        public static int Add(ResourceCategory data)
        {
            object rs =
                DataProvider.Instance.ExecuteNonQueryWithOutput("@ID", "RecourceCategory_Insert",
                                                                data.ID, data.Name, data.Description);
            int identity = rs != null?Convert.ToInt32(rs) : 0;

            return(identity);
        }
Exemple #17
0
        public static void BFSTranversal(ResourceCategory self, int depth, ResourceCategory[] allCategories)
        {
            self.Depth = depth;
            var children = from category in allCategories where category.ParentCategoryID == self.ID select category;

            foreach (var child in children)
            {
                BFSTranversal(child, depth + 1, allCategories);
            }
        }
        public int DeleteResourceAssort(Guid versionCode, string strCategoryCode)
        {
            ResourceCategory singleResourceCategory = new ResourceCategory();

            singleResourceCategory = this.GetSingleResourceCategory(versionCode, strCategoryCode);
            string str  = "";
            string str2 = str + " begin ";
            string str3 = str2 + " update EPM_Res_Category set IsValid=0,VersionTime=getdate() where (VersionCode='" + versionCode.ToString() + "')and(CategoryCode='" + strCategoryCode + "') ";

            return(publicDbOpClass.ExecSqlString((str3 + " update EPM_Res_Category set ChildNumber = (select count(1) from EPM_Res_Category where (VersionCode='" + versionCode.ToString() + "')and(CategoryParentCode = '" + singleResourceCategory.CategoryParentCode + "')and(IsValid =1)),VersionTime = getdate() where (VersionCode='" + versionCode.ToString() + "')and(CategoryCode = '" + singleResourceCategory.CategoryParentCode + "')") + " end "));
        }
        public int AddResourceAssort(ResourceCategory objResource)
        {
            string str  = "";
            string str2 = str + " begin ";
            string str3 = str2 + " if exists(select 1 from EPM_Res_Category where VersionCode = '" + objResource.VersionCode.ToString() + "' and CategoryCode='" + objResource.CategoryCode + "' and IsValid = 0) ";
            string str4 = str3 + "update EPM_Res_Category set CategoryParentCode='" + objResource.CategoryParentCode + "',CategoryName = '" + objResource.CategoryName + "',";
            object obj2 = (((((((str4 + "ResourceType=" + objResource.ResourceType.ToString() + ",ChildNumber=0,IsValid = 1,VersionTime = getdate() where (CategoryCode='" + objResource.CategoryCode + "') and (VersionCode = '" + objResource.VersionCode.ToString() + "') and (IsValid = 0)") + " else ") + " insert into EPM_Res_Category(VersionCode,CategoryCode,CategoryParentCode,CategoryName,ResourceStyle,ResourceType,ChildNumber,IsValid,Owner,VersionTime) " + " values( ") + " '" + objResource.VersionCode.ToString() + "', ") + " '" + objResource.CategoryCode + "', ") + " '" + objResource.CategoryParentCode + "', ") + " '" + objResource.CategoryName + "', ") + " " + Convert.ToInt32(objResource.ResourceStyle).ToString() + ", ";
            string str5 = (string.Concat(new object[] { obj2, " '", objResource.ResourceType, "', " }) + " 0,") + " '" + Convert.ToInt32(objResource.IsValid).ToString() + "','000000',getdate()) ";

            return(publicDbOpClass.ExecSqlString((str5 + " update EPM_Res_Category set ChildNumber = (select count(1) from EPM_Res_Category where (VersionCode ='" + objResource.VersionCode.ToString() + "') and (CategoryParentCode = '" + objResource.CategoryParentCode + "') and (IsValid =1)),VersionTime = getdate() where (VersionCode='" + objResource.VersionCode.ToString() + "') and (CategoryCode = '" + objResource.CategoryParentCode + "') ") + " end "));
        }
        public int AddCategory(string category)
        {
            ResourceCategory resourceCategory = new ResourceCategory()
            {
                Name = category
            };

            _applicationDbContext.ResourceCategories.Add(resourceCategory);
            _applicationDbContext.SaveChanges();

            return(resourceCategory.Id);
        }
        public static UnityEngine.Object Load(ResourceType type, ResourceCategory category, string name, Type returnType)
        {
            string resourcePath = string.Format("{0}/{1}/{2}", type.ToString(), category.ToString(), name);

            UnityEngine.Object resource = Resources.Load(resourcePath, returnType);
            if (resource == null)
            {
                GameLogger.FatalError("ResourceLoader could not find resource {0}", resourcePath);
            }

            return(resource);
        }
Exemple #22
0
        public IActionResult AddCategory(string categoryName, string parentCategoryId)
        {
            ResourceCategory newCat = new ResourceCategory()
            {
                Name             = categoryName,
                ParentCategoryID = int.Parse(parentCategoryId)
            };

            repository.SaveCategory(newCat);
            TempData["Success"] = $"Категория <strong>{newCat.Name}</strong> добавлена.";
            return(RedirectToAction(nameof(Index), new { categoryId = newCat.ID }));
        }
        public int UpdResourceAssort(ResourceCategory objResource, string oldCategoryCode)
        {
            object obj2 = (("" + " begin " + " update EPM_Res_Category set ") + " CategoryCode='" + objResource.CategoryCode + "',") + " CategoryName='" + objResource.CategoryName + "', ";
            string str2 = (string.Concat(new object[] { obj2, " ResourceType='", objResource.ResourceType, "', " }) + " IsValid='" + Convert.ToInt32(objResource.IsValid).ToString() + "',") + " VersionTime = getdate() ";
            string str  = str2 + " where (VersionCode = '" + objResource.VersionCode.ToString() + "') and (CategoryCode='" + oldCategoryCode + "') ";

            if (!objResource.IsValid)
            {
                string str3 = str;
                str = str3 + " update EPM_Res_Category set ChildNum = (select count(1) from EPM_Res_Category where (VersioinCode ='" + objResource.VersionCode.ToString() + "') and (CategoryParentCode = '" + objResource.CategoryParentCode + "') and (IsValid =1)),VersionTime = getdate() where (VersionCode='" + objResource.VersionCode.ToString() + "') CategoryCode = '" + objResource.CategoryParentCode + "' ";
            }
            return(publicDbOpClass.ExecSqlString(str + " end "));
        }
        public ResourceCategory QueryFirstCategory(Guid versionCode, ResourceStyle rStyle)
        {
            ResourceCategory category = new ResourceCategory();

            using (DataTable table = publicDbOpClass.DataTableQuary(string.Concat(new object[] { "select * from EPM_Res_Category where (VersionCode='", versionCode.ToString(), "')and(ResourceStyle=", Convert.ToInt32(rStyle), ")and(CategoryParentCode = '')" })))
            {
                if (table.Rows.Count == 1)
                {
                    category = this.DataRowToResourceCategoryInfo(table.Rows[0]);
                }
            }
            return(category);
        }
        /// <summary>
        /// khoi tao gia tri cho model bang cach lay gia tri cua resources va resourcesCategory tu db
        /// </summary>
        /// <returns></returns>
        List <ResourcesCatalog> InitModel()
        {
            List <ResourcesCatalog> rs        = new List <ResourcesCatalog>();
            List <Resources>        resources = ResourcesDAO.GetAll();

            //voi moi phan tu rescource, lay category va add vao list ket qua
            foreach (Resources res in resources)
            {
                ResourceCategory resourcesCategory = ResourceCategoryDAO.Single(res.CategoryID.ToString());
                rs.Add(new ResourcesCatalog(res, resourcesCategory));
            }
            return(rs);
        }
        public ResourceCategory GetSingleResourceCategory(Guid versionCode, string strCategoryCode)
        {
            ResourceCategory category = new ResourceCategory();
            string           str2     = "";

            using (DataTable table = publicDbOpClass.DataTableQuary(str2 + "select * from EPM_Res_Category where (VersionCode='" + versionCode.ToString() + "')and(CategoryCode='" + strCategoryCode + "')and(IsValid=1)"))
            {
                if (table.Rows.Count > 0)
                {
                    category = this.DataRowToResourceCategoryInfo(table.Rows[0]);
                }
            }
            return(category);
        }
Exemple #27
0
        /*
         * Finds amount of resources of category in StockPile
         */
        public int AmountOfCategory(ResourceCategory category)
        {
            var amount = 0;

            foreach (var pair in Contents)
            {
                if (pair.Key.Category == category)
                {
                    amount += pair.Value;
                }
            }

            return(amount);
        }
Exemple #28
0
        public static string FindResourceName(int id, ResourceCategory category = ResourceCategory.Id)
        {
            if (resourceClassType == null)
            {
                return(null);
            }
            var categoryClassType = resourceClassType.GetNestedType(category.ToString()); // MQC TODO: Check if optimize perf by caching type for each category is needed?

            if (categoryClassType == null)
            {
                return(null);
            }
            return(Enum.GetName(categoryClassType, id));
        }
Exemple #29
0
        /// <summary>
        /// Adds a new record; don't forget to save the asset after the modification.
        /// </summary>
        public void AddRecord(string categoryId, string pathPrefix, string name, string guid)
        {
            var resource = new EditorResource(name, pathPrefix, guid);
            var category = resourceCategories.Find(c => c.Id == categoryId);

            if (category is null)
            {
                category = new ResourceCategory {
                    Id = categoryId, Resources = new List <EditorResource>()
                };
                resourceCategories.Add(category);
            }
            category.Resources.Add(resource);
        }
Exemple #30
0
        internal ResourceType(XElement element)
        {
            Id          = element.MandatoryAttribute("id", "A resource type without id is defined.").Value;
            Name        = element.MandatoryElement("name", "The resource type (" + Id + ") has no name.").Value;
            Probability = new DynamicValue <IScriptLandProvinceForResourcesGeneration>(element.Element("probability"));
            ResourceCategory category            = ResourceCategory.Default;
            bool             conversionSucceeded = element.Element("category") != null;

            if (conversionSucceeded)
            {
                conversionSucceeded = ResourceCategory.TryParse(element.Element("category").Value, true, out category);
            }
            Category = conversionSucceeded ? category : ResourceCategory.Default;
        }
Exemple #31
0
        // Draw a full category for the resource manager.
        private unsafe void DrawCategoryContainer(ResourceCategory category,
                                                  StdMap <uint, Pointer <StdMap <uint, Pointer <ResourceHandle> > > > *map)
        {
            if (map == null)
            {
                return;
            }

            using var tree = ImRaii.TreeNode($"({( uint )category:D2}) {category} - {map->Count}###{( uint )category}");
            if (tree)
            {
                SetTableWidths();
                ResourceLoader.IterateExtMap(map, (ext, m) => DrawResourceMap(category, ext, m));
            }
        }
    private ResourceYield CreateRandomResourceYield(ResourceCategory resCategory, SystemDesirability desirability) {
        float minYield;
        float maxYield;
        int minNumberOfResources;
        switch (resCategory) {
            case ResourceCategory.Common:
                switch (desirability) {
                    case SystemDesirability.Desirable:
                        minNumberOfResources = 2;
                        minYield = 1F;
                        maxYield = 5F;
                        break;
                    case SystemDesirability.Normal:
                        minNumberOfResources = 1;
                        minYield = 1F;
                        maxYield = 4F;
                        break;
                    case SystemDesirability.Challenged:
                        minNumberOfResources = 1;
                        minYield = 0F;
                        maxYield = 3F;
                        break;
                    case SystemDesirability.None:
                    default:
                        throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
                }
                break;
            case ResourceCategory.Strategic:
                switch (desirability) {
                    case SystemDesirability.Desirable:
                        minNumberOfResources = 1;
                        minYield = 1F;
                        maxYield = 3F;
                        break;
                    case SystemDesirability.Normal:
                        minNumberOfResources = 0;
                        minYield = 1F;
                        maxYield = 2F;
                        break;
                    case SystemDesirability.Challenged:
                        minNumberOfResources = 0;
                        minYield = 0F;
                        maxYield = 2F;
                        break;
                    case SystemDesirability.None:
                    default:
                        throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
                }
                break;
            case ResourceCategory.Luxury:   // No Luxury Resources yet
            case ResourceCategory.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(resCategory));
        }

        var categoryResources = Enums<ResourceID>.GetValues(excludeDefault: true).Where(res => res.GetResourceCategory() == resCategory);
        int categoryResourceCount = categoryResources.Count();
        D.Assert(categoryResourceCount > minNumberOfResources);
        int numberOfResourcesToCreate = RandomExtended.Range(minNumberOfResources, categoryResourceCount);

        IList<ResourceYield.ResourceValuePair> resValuePairs = new List<ResourceYield.ResourceValuePair>(numberOfResourcesToCreate);
        var resourcesChosen = categoryResources.Shuffle().Take(numberOfResourcesToCreate);
        resourcesChosen.ForAll(resID => {
            var rvp = new ResourceYield.ResourceValuePair(resID, UnityEngine.Random.Range(minYield, maxYield));
            resValuePairs.Add(rvp);
        });
        return new ResourceYield(resValuePairs.ToArray());
    }
    private ResourceYield CreateRandomResourceYield(ResourceCategory resCategory) {
        float maxYield = Constants.OneF;
        int minNumberOfResources = Constants.Zero;
        switch (resCategory) {
            case ResourceCategory.Common:
                minNumberOfResources = Constants.One;
                maxYield = 5F;
                break;
            case ResourceCategory.Strategic:
                maxYield = 2F;
                break;
            case ResourceCategory.Luxury:   // No Luxury Resources yet
            case ResourceCategory.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(resCategory));
        }

        var categoryResources = Enums<ResourceID>.GetValues(excludeDefault: true).Where(res => res.GetResourceCategory() == resCategory);
        int categoryResourceCount = categoryResources.Count();
        int numberOfResourcesToCreate = RandomExtended.Range(minNumberOfResources, categoryResourceCount);

        IList<ResourceYield.ResourceValuePair> resValuePairs = new List<ResourceYield.ResourceValuePair>(numberOfResourcesToCreate);
        var resourcesChosen = categoryResources.Shuffle().Take(numberOfResourcesToCreate);
        resourcesChosen.ForAll(resID => {
            var rvp = new ResourceYield.ResourceValuePair(resID, UnityEngine.Random.Range(Constants.ZeroF, maxYield));
            resValuePairs.Add(rvp);
        });
        return new ResourceYield(resValuePairs.ToArray());
    }