Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/25/15 15:02:26 (10 years ago)
Author:
pfleck
Message:

#2025

  • Added some helper for parsing the raw category string.
  • Fixed handling of creatable items with old category descriptions (without ordering).
  • Unified naming of variables added some comments.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Attributes/CreatableAttribute.cs

    r12506 r12512  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325
    2426namespace HeuristicLab.Core {
     
    4951      public const string Scripts = "5" + OrderToken + "Scripts";
    5052
     53      public static string GetFullName(string rawName) {
     54        return string.Join(SplitToken, GetTokens(rawName));
     55      }
     56      public static string GetName(string rawName) {
     57        return GetTokens(rawName).Last();
     58      }
     59      public static IEnumerable<string> GetParentRawNames(string rawName) {
     60        var tokens = GetTokensWithOrdering(rawName).ToList();
     61        return tokens.Take(tokens.Count - 1);
     62      }
    5163
     64      private static IEnumerable<string> GetTokensWithOrdering(string rawName) {
     65        return rawName.Split(new[] { SplitToken }, StringSplitOptions.RemoveEmptyEntries);
     66      }
     67      private static IEnumerable<string> GetTokens(string rawName) {
     68        return GetTokensWithOrdering(rawName)
     69          .Select(t => t.Split(new[] { OrderToken }, StringSplitOptions.RemoveEmptyEntries).Last());
     70      }
    5271    }
    5372    #endregion
Note: See TracChangeset for help on using the changeset viewer.