示例#1
0
        private void AddIdNameCacheByCrossType(CrossReferenceType type)
        {
            Func <IEnumerable <Tuple <long, string> > > dataGetter;

            switch (type)
            {
            case CrossReferenceType.VisualDictionary:
                dataGetter = () => {
                    List <RepresentationForUser> areas = _representationsQuery.GetVisibleWithoutAreas();
                    return(areas.Select(e => new Tuple <long, string>(e.Id, e.Title)));
                };
                break;

            case CrossReferenceType.GroupWord:
                dataGetter = () => GetGroupsByType(GroupType.ByWord);
                break;

            case CrossReferenceType.GroupSentence:
                dataGetter = () => GetGroupsByType(GroupType.BySentence);
                break;

            default:
                throw new ArgumentException("Неизвестный тип " + type);
            }

            var idNameCache = new IdNameCache(dataGetter);

            _cachesByCrossReferenceTypes.Add(type, idNameCache);
        }
示例#2
0
        private string GetNameById(long id, CrossReferenceType type)
        {
            IdNameCache idNameCache = GetCacheByCrossType(type);

            return(idNameCache != null?idNameCache.GetName(id) : null);
        }
示例#3
0
        private long GetIdByName(string name, CrossReferenceType type)
        {
            IdNameCache idNameCache = GetCacheByCrossType(type);

            return(idNameCache != null?idNameCache.GetId(name) : IdValidator.INVALID_ID);
        }