Esempio n. 1
0
 internal static List <Guid> GetOrderedGuids <T>()
 {
     return(EnumHelpers.GetAttributesForValues <T, RelativityObjectAttribute>()
            .OrderBy(x => x.Key)
            .Select(x => x.Value.ObjectTypeGuid)
            .ToList());
 }
Esempio n. 2
0
        private Dictionary <int, T> GetEnumDictionary <T>()
        {
            // each type needs its own dictionary, obviously
            // but each instance does too, since they could point to, e.g. different workspaces, and thus have different IDs.

            var cacheKey = $"{CacheInstanceId}_{typeof(T).GUID}";

            if (Cache.Get(cacheKey) is Dictionary <int, T> cacheItem)
            {
                return(cacheItem);
            }

            var set        = EnumHelpers.GetAttributesForValues <T, RelativityObjectAttribute>().Where(x => x.Value != null).ToList();
            var rdosToRead = set.Select(x => new RDO(x.Value.ObjectTypeGuid)
            {
                ArtifactTypeID = (int)ArtifactType.Code
            }).ToList();
            var choices = rsapiProvider.Read(rdosToRead).GetResultData();

            var newCacheItem = Enumerable.Range(0, set.Count).ToDictionary(
                i => choices[i].ArtifactID,
                i => set[i].Key
                );

            Cache.Add(cacheKey, newCacheItem, CachePolicy);
            return(newCacheItem);
        }