示例#1
0
        internal EnumerableWrapper <T> GetEnumerableWrapper <T>(EnumerableWrapper <T> noElementsValue, IEnumerable <T> collection) where T : IConfigurable, new()
        {
            EnumerableWrapper <T> result  = noElementsValue ?? EnumerableWrapper <T> .Empty;
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(collection, this.GetEnumerableFilter <T>());

            if (wrapper.HasUnfilteredElements())
            {
                result = wrapper;
            }
            return(result);
        }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (!typeof(ADRecipient).IsAssignableFrom(typeof(T)) && !typeof(ReducedRecipient).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (Globals.IsConsumerOrganization(session.SessionSettings.CurrentOrganizationId) && ADSessionFactory.UseAggregateSession(session.SessionSettings))
            {
                return(ConsumerMailboxIdParameter.Parse(base.RawIdentity).GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!enumerableWrapper.HasElements() && session is IRecipientSession)
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsByAccountName <T>(base.RawIdentity, rootId, (IRecipientSession)session, optionalData));
            }
            if (enumerableWrapper.HasUnfilteredElements() && !enumerableWrapper.HasElements())
            {
                notFoundReason = new LocalizedString?(this.GetErrorMessageForWrongType(this.ToString()));
            }
            TaskLogger.LogExit();
            return(enumerableWrapper);
        }