Example #1
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            EnumerableWrapper <T> wrapper;

            try
            {
                if (typeof(T) != typeof(AvailabilityAddressSpace))
                {
                    throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
                }
                if (string.IsNullOrEmpty(base.RawIdentity))
                {
                    throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
                }
                wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

                if (!wrapper.HasElements())
                {
                    notFoundReason = null;
                    wrapper        = EnumerableWrapper <T> .GetWrapper(base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(AvailabilityAddressSpaceSchema.ForestName, base.RawIdentity), rootId, session, true, optionalData));
                }
            }
            finally
            {
                TaskLogger.LogExit();
            }
            return(wrapper);
        }
        // Token: 0x0600096A RID: 2410 RVA: 0x00020668 File Offset: 0x0001E868
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(Database).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            new List <T>();
            notFoundReason = null;
            if (rootId != null)
            {
                Server server = (Server)((IConfigDataProvider)session).Read <Server>(rootId);
                if (server != null)
                {
                    if (optionalData != null && optionalData.AdditionalFilter != null)
                    {
                        throw new NotSupportedException("Supplying Additional Filters and a RootId is not currently supported by this IdParameter.");
                    }
                    return(server.GetDatabases <T>(this.AllowInvalid));
                }
            }
            IEnumerable <T> objects    = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            IEnumerable <T> enumerable = from tmpDb in objects
                                         where tmpDb.IsValid || this.AllowInvalid
                                         select tmpDb;
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(enumerable);

            if (!wrapper.HasElements() && this.legacyParameter != null)
            {
                wrapper = EnumerableWrapper <T> .GetWrapper(this.legacyParameter.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            return(wrapper);
        }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(MobileDevice).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            notFoundReason = new LocalizedString?(Strings.WrongActiveSyncDeviceIdParameter(this.ToString()));
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetExactMatchObjects <T>(rootId, subTreeSession, optionalData));

            if (!wrapper.HasElements() && base.RawIdentity != null)
            {
                string[] array = base.RawIdentity.Split(new char[]
                {
                    '\\'
                });
                if (array.Length == 3)
                {
                    string text  = array[0];
                    string text2 = array[2];
                    if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
                    {
                        wrapper = EnumerableWrapper <T> .GetWrapper(this.GetObjectsInOrganization <T>(text2, rootId, session, optionalData), new MobileDeviceIdParameter.MobileDeviceUsernameFilter <T>(text));
                    }
                }
            }
            return(wrapper);
        }
Example #4
0
        internal virtual IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (subTreeSession == null)
            {
                throw new ArgumentNullException("subTreeSession");
            }
            notFoundReason = null;
            EnumerableWrapper <T> enumerableWrapper = null;

            if (string.IsNullOrEmpty(this.RawIdentity))
            {
                throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
            }
            enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetExactMatchObjects <T>(rootId, subTreeSession, optionalData));
            if (!enumerableWrapper.HasElements() && VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetMultitenancyObjects <T>(this.RawIdentity, rootId, session, optionalData, out notFoundReason));
            }
            if (!enumerableWrapper.HasElements())
            {
                enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsInOrganization <T>(this.RawIdentity, rootId, session, optionalData));
            }
            if (!enumerableWrapper.HasElements() && !string.IsNullOrEmpty(this.displayName) && this.displayName != this.RawIdentity)
            {
                enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsInOrganization <T>(this.displayName, rootId, session, optionalData));
            }
            return(enumerableWrapper);
        }
Example #5
0
        // Token: 0x06000AD6 RID: 2774 RVA: 0x000232D4 File Offset: 0x000214D4
        internal override IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjectsInOrganization <T>(identityString, rootId, session, optionalData));

            if (wrapper.HasElements())
            {
                return(wrapper);
            }
            int num = identityString.IndexOf('\\');

            if (0 < num && identityString.Length > num + 1)
            {
                string propertyValue       = identityString.Substring(num + 1);
                string unescapedCommonName = identityString.Substring(0, num);
                OptionalIdentityData optionalIdentityData = null;
                if (optionalData != null)
                {
                    optionalIdentityData = optionalData.Clone();
                    optionalIdentityData.ConfigurationContainerRdn = null;
                }
                ADObjectId  adobjectId = (rootId == null) ? MessageClassificationIdParameter.DefaultRoot((IConfigDataProvider)session) : rootId;
                ADObjectId  childId    = adobjectId.Parent.GetChildId(unescapedCommonName);
                QueryFilter filter     = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, propertyValue);
                return(base.PerformPrimarySearch <T>(filter, childId, session, false, optionalIdentityData));
            }
            return(new T[0]);
        }
Example #6
0
        internal IEnumerable <T> PerformPrimarySearch <T>(QueryFilter filter, ADObjectId rootId, IDirectorySession session, bool deepSearch, OptionalIdentityData optionalData) where T : IConfigurable, new()
        {
            if (rootId != null && rootId.IsRelativeDn)
            {
                throw new ArgumentException("RootId cannot be a relative DN", "rootId");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (optionalData == null)
            {
                optionalData = new OptionalIdentityData();
            }
            if (session.ConfigScope == ConfigScopes.TenantLocal && rootId == null && !this.IsNullScopedSession(session))
            {
                if (optionalData.ConfigurationContainerRdn != null)
                {
                    rootId = this.CreateContainerRootId(session, optionalData.ConfigurationContainerRdn);
                }
                else if (optionalData.RootOrgDomainContainerId != null && this.IsForestWideScopedSession(session))
                {
                    rootId = optionalData.RootOrgDomainContainerId;
                }
            }
            QueryFilter filter2 = QueryFilter.AndTogether(new QueryFilter[]
            {
                filter,
                this.AdditionalQueryFilter,
                optionalData.AdditionalFilter
            });
            IEnumerable <T> enumerable = this.PerformSearch <T>(filter2, rootId, session, deepSearch);

            return(EnumerableWrapper <T> .GetWrapper(enumerable, this.GetEnumerableFilter <T>()));
        }
        // Token: 0x0600083D RID: 2109 RVA: 0x0001DF7C File Offset: 0x0001C17C
        internal virtual IEnumerable <T> GetObjects <T>(ObjectId rootId, IConfigDataProvider session, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            TaskLogger.LogEnter();
            notFoundReason = null;
            IEnumerable <AddressBookBase> enumerable = new List <AddressBookBase>();

            try
            {
                if (typeof(T) != typeof(AddressBookBase))
                {
                    throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
                }
                if (session == null)
                {
                    throw new ArgumentNullException("session");
                }
                IList <IEnumerable <AddressBookBase> > list = new List <IEnumerable <AddressBookBase> >();
                if (this.addressListIdParameter != null)
                {
                    list.Add(this.addressListIdParameter.GetObjects <AddressBookBase>(rootId, session));
                }
                if (this.globalAddressListIdParameter != null)
                {
                    list.Add(this.globalAddressListIdParameter.GetObjects <AddressBookBase>(rootId, session));
                }
                enumerable = EnumerableWrapper <AddressBookBase> .GetWrapper(list);
            }
            finally
            {
                TaskLogger.LogExit();
            }
            return((IEnumerable <T>)enumerable);
        }
Example #8
0
        // Token: 0x06000E58 RID: 3672 RVA: 0x0002AA78 File Offset: 0x00028C78
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T>       objects = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(objects);

            if (!wrapper.HasElements())
            {
                LocalizedString value;
                if (((IConfigDataProvider)session).Source != null)
                {
                    value = Strings.ErrorManagementObjectNotFoundWithSource(this.ToString(), ((IConfigDataProvider)session).Source);
                }
                else
                {
                    value = Strings.ErrorManagementObjectNotFound(this.ToString());
                }
                if (notFoundReason != null)
                {
                    string          notFound        = value;
                    LocalizedString?localizedString = notFoundReason;
                    value = Strings.ErrorNotFoundWithReason(notFound, (localizedString != null) ? localizedString.GetValueOrDefault() : null);
                }
                notFoundReason = new LocalizedString?(Strings.ErrorRoleAssignmentNotFound(value));
            }
            return(objects);
        }
        // Token: 0x06000DED RID: 3565 RVA: 0x00029C98 File Offset: 0x00027E98
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            notFoundReason = new LocalizedString?(LocalizedString.Empty);
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .Empty;
            SecurityIdentifier    sid     = SecurityPrincipalIdParameter.TryParseToSID(base.RawIdentity);
            string userAccountNameFromSid = SecurityPrincipalIdParameter.GetUserAccountNameFromSid(sid, this.ToString(), null);

            if (!string.IsNullOrEmpty(userAccountNameFromSid))
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjectsByAccountName <T>(userAccountNameFromSid, rootId, (IRecipientSession)session, optionalData));
                if (enumerableWrapper.HasElements())
                {
                    return(enumerableWrapper);
                }
            }
            enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            if (enumerableWrapper.HasElements())
            {
                return(enumerableWrapper);
            }
            sid = SecurityPrincipalIdParameter.GetUserSidAsSAMAccount(this, null, null);
            userAccountNameFromSid = SecurityPrincipalIdParameter.GetUserAccountNameFromSid(sid, this.ToString(), null);
            if (!string.IsNullOrEmpty(userAccountNameFromSid))
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(EnumerableWrapper <T> .Empty, base.GetObjectsByAccountName <T>(userAccountNameFromSid, rootId, (IRecipientSession)session, optionalData));
            }
            return(enumerableWrapper);
        }
Example #10
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (typeof(T) != typeof(ADSchemaClassObject) && typeof(T) != typeof(ADSchemaAttributeObject))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            IEnumerable <T>       enumerable = base.GetObjects <T>(session.GetSchemaNamingContext(), session, subTreeSession, optionalData, out notFoundReason);
            EnumerableWrapper <T> wrapper    = EnumerableWrapper <T> .GetWrapper(enumerable);

            if (!wrapper.HasElements() && base.InternalADObjectId != null && base.InternalADObjectId.ObjectGuid != Guid.Empty)
            {
                QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADSchemaObjectSchema.SchemaIDGuid, base.InternalADObjectId.ObjectGuid);
                enumerable = base.PerformPrimarySearch <T>(filter, ADSession.GetSchemaNamingContextForLocalForest(), session, true, optionalData);
                wrapper    = EnumerableWrapper <T> .GetWrapper(enumerable);
            }
            if (!wrapper.HasElements() && !string.IsNullOrEmpty(base.RawIdentity))
            {
                QueryFilter filter2 = new ComparisonFilter(ComparisonOperator.Equal, ADSchemaObjectSchema.DisplayName, base.RawIdentity);
                enumerable = base.PerformPrimarySearch <T>(filter2, ADSession.GetSchemaNamingContextForLocalForest(), session, true, optionalData);
                wrapper    = EnumerableWrapper <T> .GetWrapper(enumerable);
            }
            return(wrapper);
        }
Example #11
0
        public Template(Data.GameObjects.ITemplate source)
            : base(source)
        {
            _source = source;

            SuggestedAdvantages    = new EnumerableWrapper <IAdvantage, Data.GameObjects.IAdvantage>(_source.SuggestedAdvantages, a => a.CreatePresenter() as IAdvantage);
            SuggestedDisadvantages = new EnumerableWrapper <IDisadvantage, Data.GameObjects.IDisadvantage>(_source.SuggestedDisadvantages, d => d.CreatePresenter() as IDisadvantage);
            SuggestedDemeanors     = new EnumerableWrapper <IDemeanor, Data.GameObjects.IDemeanor>(_source.SuggestedDemeanors, d => d.CreatePresenter() as IDemeanor);
        }
        public ObjectMetadataGroup(ObjectType type, IEnumerable <IGameObjectMetadata> gameObjects)
        {
            Type = type;

            _gameObjects = new EnumerableWrapper <IGameObjectMetadata>(
                gameObjects,
                (o1, o2) => { return(o1.Name.CompareTo(o2.Name)); },
                o => o.Type == Type);
        }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (notFoundReason == null && !wrapper.HasElements() && ADRawEntryIdParameter.IsSingleOrDoubleAsterisks(base.RawIdentity))
            {
                notFoundReason = new LocalizedString?(Strings.ErrorNotSupportSingletonWildcard);
            }
            return(wrapper);
        }
        // Token: 0x06000AE0 RID: 2784 RVA: 0x000233F0 File Offset: 0x000215F0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements() && base.RawIdentity.StartsWith("\\") && base.RawIdentity.Length > 1)
            {
                string identityString = base.RawIdentity.Substring(1);
                wrapper = EnumerableWrapper <T> .GetWrapper(this.GetObjectsInOrganization <T>(identityString, rootId, session, optionalData));
            }
            return(wrapper);
        }
 void OnItemsSourceChanged(IEnumerable itemsSource)
 {
     items = new EnumerableWrapper(itemsSource);
     items.StartingItem        = DeselectedItem;
     items.IncludeStartingItem = SelectedItem != null;
     if (ListBox != null)
     {
         ListBox.ItemsSource  = items;
         ListBox.SelectedItem = SelectedItem;
     }
 }
Example #16
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);
        }
Example #17
0
        private IEnumerable <T> GetMultitenancyObjects <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            if (identityString == null)
            {
                throw new ArgumentNullException("rawIdentity");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            notFoundReason = null;
            string text;
            string identityString2;

            if (!this.IsMultitenancyEnabled() || !this.TryParseOrganizationName(out text, out identityString2))
            {
                return(EnumerableWrapper <T> .Empty);
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(session.DomainController, true, session.ConsistencyMode, session.NetworkCredential, session.SessionSettings, 1403, "GetMultitenancyObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs");

            tenantOrTopologyConfigurationSession.UseConfigNC          = true;
            tenantOrTopologyConfigurationSession.LinkResolutionServer = session.LinkResolutionServer;
            if (!string.IsNullOrEmpty(session.DomainController) && tenantOrTopologyConfigurationSession.SessionSettings.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId) && tenantOrTopologyConfigurationSession.SessionSettings.PartitionId.ForestFQDN != TopologyProvider.LocalForestFqdn)
            {
                return(EnumerableWrapper <T> .Empty);
            }
            if (this.IsWildcardDefined(text))
            {
                notFoundReason = new LocalizedString?(Strings.ErrorOrganizationWildcard);
                return(EnumerableWrapper <T> .Empty);
            }
            OrganizationId organizationId;

            if (this.orgIdResolved)
            {
                organizationId = this.resolvedOrganizationId;
            }
            else
            {
                organizationId = this.GetOrganizationId(session.SessionSettings.CurrentOrganizationId, text);
            }
            IDirectorySession directorySession = session;

            if (organizationId != null && !OrganizationId.ForestWideOrgId.Equals(organizationId) && session.SessionSettings != null && session.SessionSettings.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId))
            {
                directorySession = TaskHelper.UnderscopeSessionToOrganization(session, organizationId, true);
            }
            if (organizationId != null && !OrganizationId.ForestWideOrgId.Equals(organizationId) && organizationId.Equals(directorySession.SessionSettings.CurrentOrganizationId))
            {
                IEnumerable <T> objectsInOrganization = this.GetObjectsInOrganization <T>(identityString2, rootId, directorySession, optionalData);
                return(EnumerableWrapper <T> .GetWrapper(objectsInOrganization));
            }
            return(EnumerableWrapper <T> .Empty);
        }
Example #18
0
        // ******************************************************************
        public AvlTreeSet(IComparer <T> comparer)
        {
            if (comparer == null)
            {
                throw new ArgumentNullException($"{nameof(comparer)} can't be null");
            }

            _comparer                 = comparer;
            _enumerableWrapper        = new EnumerableWrapper <AvlNode <T> >(() => new AvlNodeEnumerator <T>(this));
            _enumerableWrapperReverse = new EnumerableWrapper <AvlNode <T> >(() => new AvlNodeEnumeratorReverse <T>(this));
        }
        // Token: 0x06000B8C RID: 2956 RVA: 0x00024868 File Offset: 0x00022A68
        internal static ADObject GetRawRoleAssignee(RoleAssigneeIdParameter user, IConfigurationSession configSession, IRecipientSession recipientSession)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            if (configSession == null)
            {
                throw new ArgumentNullException("configSession");
            }
            IEnumerable <ADObject>       enumerable = user.GetObjects <RoleAssignmentPolicy>(null, configSession).Cast <ADObject>();
            EnumerableWrapper <ADObject> wrapper    = EnumerableWrapper <ADObject> .GetWrapper(enumerable);

            if (!wrapper.HasElements())
            {
                SecurityIdentifier securityIdentifier = SecurityPrincipalIdParameter.TryParseToSID(user.RawIdentity);
                if (null != securityIdentifier)
                {
                    ADRecipient adrecipient = recipientSession.FindBySid(securityIdentifier);
                    if (adrecipient != null)
                    {
                        enumerable = new ADObject[]
                        {
                            adrecipient
                        };
                        wrapper = EnumerableWrapper <ADObject> .GetWrapper(enumerable);
                    }
                }
                else
                {
                    enumerable = user.GetObjects <ADRecipient>(null, recipientSession).Cast <ADObject>();
                    wrapper    = EnumerableWrapper <ADObject> .GetWrapper(enumerable);
                }
            }
            ADObject result = null;

            using (IEnumerator <ADObject> enumerator = wrapper.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    throw new ManagementObjectNotFoundException(Strings.ErrorPolicyUserOrSecurityGroupNotFound(user.ToString()));
                }
                result = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    throw new ManagementObjectAmbiguousException(Strings.ErrorPolicyUserOrSecurityGroupNotUnique(user.ToString()));
                }
            }
            return(result);
        }
        // Token: 0x06000DBB RID: 3515 RVA: 0x00028ED0 File Offset: 0x000270D0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (!typeof(RemovedMailbox).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (base.InternalADObjectId == null && string.IsNullOrEmpty(base.RawIdentity))
            {
                throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
            }
            notFoundReason = null;
            string     orgName    = null;
            string     text       = base.RawIdentity;
            ADObjectId adobjectId = base.InternalADObjectId ?? RemovedMailboxIdParameter.GetObjectIdFromCanonicalName(base.RawIdentity);

            if (adobjectId == null && !string.IsNullOrEmpty(base.RawIdentity))
            {
                int num = base.RawIdentity.IndexOf('\\');
                if (num > 0 && base.RawIdentity.Length > num + 1)
                {
                    orgName = base.RawIdentity.Substring(0, num);
                    text    = base.RawIdentity.Substring(num + 1);
                }
            }
            QueryFilter      queryFilter;
            bool             flag = this.TryGetOrganizationFilter(rootId, adobjectId, orgName, out queryFilter);
            ComparisonFilter databaseRetentionPeriodFilter = this.GetDatabaseRetentionPeriodFilter();
            QueryFilter      basicFilter = QueryFilter.AndTogether(new QueryFilter[]
            {
                queryFilter,
                new ExistsFilter(RemovedMailboxSchema.PreviousDatabase),
                databaseRetentionPeriodFilter
            });
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .Empty;

            if (adobjectId != null)
            {
                enumerableWrapper = this.SearchByObjectId <T>(adobjectId, session, optionalData, basicFilter);
            }
            if (flag && (enumerableWrapper == null || !enumerableWrapper.HasElements()) && !string.IsNullOrEmpty(text))
            {
                enumerableWrapper = this.SearchByObjectAttributes <T>(session, optionalData, text, basicFilter);
            }
            enumerableWrapper = EnumerableWrapper <T> .GetWrapper(enumerableWrapper);

            TaskLogger.LogExit();
            return(enumerableWrapper);
        }
        // Token: 0x06000A34 RID: 2612 RVA: 0x00021EB4 File Offset: 0x000200B4
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T>       enumerable        = null;
            EnumerableWrapper <T> enumerableWrapper = null;

            notFoundReason = null;
            if (string.IsNullOrEmpty(this.storageGroupName))
            {
                enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            if (!string.IsNullOrEmpty(base.CommonName) && (enumerableWrapper == null || !enumerableWrapper.HasElements()))
            {
                string            serverName        = this.storageGroupName;
                ServerIdParameter serverIdParameter = base.ServerId;
                if (string.IsNullOrEmpty(this.storageGroupName))
                {
                    serverName        = base.ServerName;
                    serverIdParameter = new ServerIdParameter();
                }
                ADObjectId[] matchingIdentities = serverIdParameter.GetMatchingIdentities((IConfigDataProvider)session);
                for (int i = 0; i < matchingIdentities.Length; i++)
                {
                    if (ServerIdParameter.HasRole(matchingIdentities[i], this.RoleRestriction, (IConfigDataProvider)session) || (base.AllowLegacy && !ServerIdParameter.HasRole(matchingIdentities[i], ServerRole.All, (IConfigDataProvider)session)))
                    {
                        if (string.IsNullOrEmpty(this.storageGroupName))
                        {
                            rootId     = matchingIdentities[i].GetChildId("InformationStore").GetChildId(serverName);
                            enumerable = base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, base.CommonName), rootId, session, true, optionalData);
                        }
                        else
                        {
                            List <T> list = new List <T>();
                            IEnumerable <StorageGroup> enumerable2 = base.PerformSearch <StorageGroup>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, this.storageGroupName), matchingIdentities[i], session, true);
                            foreach (StorageGroup storageGroup in enumerable2)
                            {
                                enumerable = base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, base.CommonName), storageGroup.Id, session, true, optionalData);
                                list.AddRange(enumerable);
                            }
                            enumerable = list;
                        }
                    }
                }
            }
            else
            {
                enumerable = enumerableWrapper;
            }
            if (enumerable == null)
            {
                enumerable = new List <T>();
            }
            return(enumerable);
        }
Example #22
0
        public Character(Data.GameObjects.ICharacter source)
            : base(source)
        {
            _source = source;

            Demeanor       = _source.Demeanor.CreatePresenter() as IDemeanor;
            Advantages     = new EnumerableWrapper <IAdvantage, Data.GameObjects.IAdvantage>(_source.Advantages, a => a.CreatePresenter() as IAdvantage);
            Disadvantages  = new EnumerableWrapper <IDisadvantage, Data.GameObjects.IDisadvantage>(_source.Disadvantages, d => d.CreatePresenter() as IDisadvantage);
            FavoredWeapons = new EnumerableWrapper <IGear, Data.GameObjects.IGear>(_source.FavoredWeapons, w => w.CreatePresenter() as IGear);
            EquippedGear   = new EnumerableWrapper <IGear, Data.GameObjects.IGear>(_source.EquippedGear, e => e.CreatePresenter() as IGear);
            OtherGear      = new EnumerableWrapper <IGear, Data.GameObjects.IGear>(_source.OtherGear, o => o.CreatePresenter() as IGear);
            Abilities      = new EnumerableWrapper <IAbility, Data.GameObjects.IAbility>(_source.Abilities, a => a.CreatePresenter() as IAbility);
        }
        // Token: 0x060007E9 RID: 2025 RVA: 0x0001D104 File Offset: 0x0001B304
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (subTreeSession == null)
            {
                throw new ArgumentNullException("subTreeSession");
            }
            EnumerableWrapper <T> enumerableWrapper = null;

            enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            if (enumerableWrapper.HasElements())
            {
                return(enumerableWrapper);
            }
            if (!typeof(T).IsAssignableFrom(typeof(AccountPartition)))
            {
                return(enumerableWrapper);
            }
            if (this.fqdn != null)
            {
                ADObjectId adobjectId = ADSession.GetDomainNamingContextForLocalForest();
                adobjectId = adobjectId.GetChildId("System").GetChildId(this.fqdn.ToString());
                ADPagedReader <T> collection = session.FindPaged <T>(rootId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, AccountPartitionSchema.TrustedDomainLink, adobjectId.DistinguishedName), null, 0, null);
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, collection);
                if (enumerableWrapper.HasElements())
                {
                    return(enumerableWrapper);
                }
                Guid g;
                Guid.TryParse(this.fqdn, out g);
                if (TopologyProvider.LocalForestFqdn.Equals(this.fqdn.ToString(), StringComparison.OrdinalIgnoreCase) || ADObjectId.ResourcePartitionGuid.Equals(g))
                {
                    collection        = session.FindPaged <T>(rootId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, AccountPartitionSchema.IsLocalForest, true), null, 0, null);
                    enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, collection);
                }
                if (enumerableWrapper.HasElements())
                {
                    return(enumerableWrapper);
                }
                PartitionId partitionId;
                if (ADAccountPartitionLocator.IsSingleForestTopology(out partitionId) && this.fqdn.ToString().Equals(partitionId.ForestFQDN, StringComparison.OrdinalIgnoreCase) && partitionId.PartitionObjectId != null)
                {
                    base.UpdateInternalADObjectId(new ADObjectId(partitionId.PartitionObjectId.Value));
                    enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetExactMatchObjects <T>(rootId, session, optionalData));
                }
            }
            return(enumerableWrapper);
        }
Example #24
0
        public void TestFindIndex()
        {
            List <int> data        = new List <int>(Enumerable.Range(0, 100));
            var        arrayData   = data.ToArray();
            var        enumWrapper = new EnumerableWrapper <int>(data);

            for (int i = -1; i < 100; i++)
            {
                int expected = data.FindIndex(v => v == i);
                Assert.AreEqual(expected, (data as IEnumerable <int>).FindIndex(v => v == i));
                Assert.AreEqual(expected, (arrayData as IEnumerable <int>).FindIndex(v => v == i));
                Assert.AreEqual(expected, enumWrapper.FindIndex(v => v == i));
            }
        }
Example #25
0
            public void ShouldBeAbleToEnumerateOverEnumerable_Typed()
            {
                // Arrange
                var data       = new[] { 1, 2, 3 };
                var firstLayer = new MyEnumerable <int>(data);
                var sut        = new EnumerableWrapper <int>(firstLayer);

                // Act
                Expect(sut.IsValid).To.Be.True();
                var result = sut.ToList();

                // Assert
                Expect(result).To.Equal(data);
            }
Example #26
0
        internal virtual IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData) where T : IConfigurable, new()
        {
            if (string.IsNullOrEmpty(identityString))
            {
                throw new ArgumentException("IdentityString must contain a non-empty value", "identityString");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(this.PerformPrimarySearch <T>(this.GetNameMatchingFilter(identityString, false), rootId, session, true, optionalData));

            if (!wrapper.HasElements() && this.IsWildcardDefined(identityString))
            {
                wrapper = EnumerableWrapper <T> .GetWrapper(this.PerformPrimarySearch <T>(this.GetNameMatchingFilter(identityString, true), rootId, session, true, optionalData));
            }
            return(wrapper);
        }
        /// <summary>
        /// Converts an IEnumerable or IEnumerator to a DynValue
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="obj">The object.</param>
        public static DynValue EnumerationToDynValue(Script script, object obj)
        {
            if (obj is IEnumerable ie)
            {
                return(EnumerableWrapper.ConvertIterator(script, ie.GetEnumerator()));
            }

            if (obj is IEnumerator ienum)
            {
                return(EnumerableWrapper.ConvertIterator(script, ienum));
            }

            return(null);
        }
Example #28
0
        private void InitializeSourceList(IEnumerable sourceCollection)
        {
            IList sourceAsList = sourceCollection as IList;

            if (sourceAsList == null)
            {
                this._listWrapper        = new EnumerableWrapper(sourceCollection, this);
                this._isUsingListWrapper = true;
            }
            else
            {
                this._listWrapper        = null;
                this._isUsingListWrapper = false;
            }
        }
Example #29
0
        /// <summary>
        /// Converts an IEnumerable or IEnumerator to a DynValue
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="obj">The object.</param>
        /// <returns></returns>
        public static DynValue EnumerationToDynValue(Script script, object obj)
        {
            if (obj is System.Collections.IEnumerable)
            {
                var enumer = (System.Collections.IEnumerable)obj;
                return(EnumerableWrapper.ConvertIterator(script, enumer.GetEnumerator()));
            }

            if (obj is System.Collections.IEnumerator)
            {
                var enumer = (System.Collections.IEnumerator)obj;
                return(EnumerableWrapper.ConvertIterator(script, enumer));
            }

            return(null);
        }
Example #30
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(Container).IsAssignableFrom(typeof(T)) && !typeof(ADContainer).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements())
            {
                notFoundReason = null;
                QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, base.RawIdentity);
                wrapper = EnumerableWrapper <T> .GetWrapper(base.PerformPrimarySearch <T>(filter, ((IConfigurationSession)session).GetOrgContainerId(), session, false, optionalData));
            }
            return(wrapper);
        }
Example #31
0
            /// <summary>
            /// Initiates enumeration of the watch directories.
            /// </summary>
            /// <param name="directory">The directory to be enumerated.</param>
            public void Enumerate(string directory)
            {
                CancellationToken cancellationToken;

                lock (m_cancellationTokens)
                {
                    if (m_cancellationTokens.TryGetValue(directory, out cancellationToken))
                        cancellationToken.Cancel();

                    cancellationToken = new CancellationToken();
                    m_cancellationTokens[directory] = cancellationToken;
                }

                switch (m_fileProcessor.EnumerationStrategy)
                {
                    // Sequential enumeration strategy kicks
                    // off all its processing on a single thread
                    case FileEnumerationStrategy.Sequential:
                        m_sequentialEnumerationThread.Push(() =>
                        {
                            // Create the enumerable wrappers for file and directory enumeration
                            EnumerableWrapper fileWrapper = new EnumerableWrapper(Directory.EnumerateFiles(directory), cancellationToken);
                            EnumerableWrapper directoryWrapper = new EnumerableWrapper(Directory.EnumerateDirectories(directory), cancellationToken);

                            if (m_isActive.Value)
                            {
                                // If the thread is already active,
                                // push processing into the directory queue
                                m_directoryQueue.Value.Enqueue(() =>
                                {
                                    m_wrapperStack.Value.Push(() => EnumerateNextFile(fileWrapper));
                                    EnumerateNextDirectory(directoryWrapper);
                                });
                            }
                            else
                            {
                                // If the thread is inactive, mark it as active
                                // and then begin processing the directory wrapper
                                ActivateThread();
                                m_wrapperStack.Value.Push(() => EnumerateNextFile(fileWrapper));
                                EnumerateNextDirectory(directoryWrapper);
                            }
                        });
                        break;

                    // Parallel processing kicks off new
                    // enumerations on their own thread
                    case FileEnumerationStrategy.ParallelWatchDirectories:
                    case FileEnumerationStrategy.ParallelSubdirectories:
                        m_fileProcessor.m_threadScheduler.CreateThread().Push(() =>
                        {
                            EnumerableWrapper fileWrapper = new EnumerableWrapper(Directory.EnumerateFiles(directory), cancellationToken);
                            EnumerableWrapper directoryWrapper = new EnumerableWrapper(Directory.EnumerateDirectories(directory), cancellationToken);
                            m_wrapperStack.Value.Push(() => EnumerateNextFile(fileWrapper));
                            LogicalThread.CurrentThread.Push(() => EnumerateNextDirectory(directoryWrapper));
                            ActivateThread();
                        });
                        break;
                }

                // Initiate the process to clean up the files
                // in the collection of processed files
                m_cleanProcessedFilesOperation.RunOnceAsync();
            }
Example #32
0
            // Handle the next directory in the enumeration.
            private void EnumerateNextDirectory(EnumerableWrapper wrapper)
            {
                EnumerableWrapper fileWrapper;
                EnumerableWrapper directoryWrapper;
                string directory;

                try
                {
                    // Advance directory enumeration
                    if (!wrapper.MoveNext())
                    {
                        // No more directories, so dispose
                        // and then move to the next wrapper
                        wrapper.Dispose();
                        EnumerateNextWrapper();
                        return;
                    }

                    // Initialize the fileWrapper
                    // and directoryWrapper
                    directory = wrapper.Current;
                    fileWrapper = null;
                    directoryWrapper = null;
                }
                catch
                {
                    // If an error occurs, dispose of the
                    // wrapper and then move to the next wrapper
                    wrapper.Dispose();
                    EnumerateNextWrapper();
                    throw;
                }

                try
                {
                    switch (m_fileProcessor.EnumerationStrategy)
                    {
                        // Sequential and ParallelWatchDirectories strategies
                        // place subdirectories on the current thread
                        case FileEnumerationStrategy.Sequential:
                        case FileEnumerationStrategy.ParallelWatchDirectories:
                            // Create the fileWrapper and directoryWrapper objects
                            fileWrapper = new EnumerableWrapper(Directory.EnumerateFiles(directory), wrapper.CancellationToken);
                            directoryWrapper = new EnumerableWrapper(Directory.EnumerateDirectories(directory), wrapper.CancellationToken);

                            // Push the current directory wrapper onto the stack
                            m_wrapperStack.Value.Push(() => EnumerateNextDirectory(wrapper));

                            // Push the subdirectory's file wrapper onto the stack
                            m_wrapperStack.Value.Push(() => EnumerateNextFile(fileWrapper));

                            // Continue enumeration with the directory wrapper for the subdirectory
                            LogicalThread.CurrentThread.Push(() => EnumerateNextDirectory(directoryWrapper));
                            break;

                        // ParallelSubdirectories strategy spawns new threads for subdirectories
                        case FileEnumerationStrategy.ParallelSubdirectories:
                            // Create the fileWrapper and directoryWrapper objects
                            fileWrapper = new EnumerableWrapper(Directory.EnumerateFiles(directory), wrapper.CancellationToken);
                            directoryWrapper = new EnumerableWrapper(Directory.EnumerateDirectories(directory), wrapper.CancellationToken);

                            // Create a new thread, push the file wrapper onto the new thread's
                            // stack, then enumerate the directory wrapper on the new thread
                            m_fileProcessor.m_threadScheduler.CreateThread().Push(() =>
                            {
                                ActivateThread();
                                m_wrapperStack.Value.Push(() => EnumerateNextFile(fileWrapper));
                                EnumerateNextDirectory(directoryWrapper);
                            });

                            // Continue enumeration on this thread with the current directory wrapper
                            LogicalThread.CurrentThread.Push(() => EnumerateNextDirectory(wrapper));
                            break;

                        // The only other file enumeration
                        // strategy is no strategy at all
                        default:
                            // Clear out the stack and queue,
                            // then dispose of the wrapper
                            m_wrapperStack.Value.Clear();
                            m_directoryQueue.Value.Clear();
                            wrapper.Dispose();
                            DeactivateThread();
                            break;
                    }
                }
                catch
                {
                    // If an exception occurs, dispose of the file
                    // wrapper and directory wrapper, then continue
                    // enumeration with the current directory wrapper
                    if ((object)fileWrapper != null)
                        fileWrapper.Dispose();

                    if ((object)directoryWrapper != null)
                        directoryWrapper.Dispose();

                    LogicalThread.CurrentThread.Push(() => EnumerateNextDirectory(wrapper));

                    throw;
                }
            }
Example #33
0
            // Handle the next file in the enumeration.
            private void EnumerateNextFile(EnumerableWrapper wrapper)
            {
                LogicalThread enumerationThread;
                Action enumerateNextFile;
                string file;

                try
                {
                    while (true)
                    {
                        // Advance enumeration until the
                        // next file that matches the filter
                        if (!wrapper.MoveNext())
                            return;

                        if (m_fileProcessor.MatchesFilter(wrapper.Current))
                            break;

                        Interlocked.Increment(ref m_fileProcessor.m_skippedFileCount);
                    }

                    // Prepare the callback to return execution to this thread
                    enumerationThread = LogicalThread.CurrentThread;
                    enumerateNextFile = () => EnumerateNextFile(wrapper);
                    file = wrapper.Current;

                    // Kick off the operation to process the current file,
                    // but don't enumerate to the next file until processing
                    // for the current file has begun
                    m_fileProcessor.m_processingThread.Push(1, () =>
                    {
                        // Check the state of cancellation for the
                        // enumeration thread on the processing
                        // thread as well to speed up cancellation
                        if (wrapper.CancellationToken.IsCancelled)
                        {
                            enumerationThread.Push(DeactivateThread);
                            return;
                        }

                        enumerationThread.Push(enumerateNextFile);
                        m_fileProcessor.TouchLockAndProcess(file);
                    });
                }
                catch
                {
                    // If an exception occurs,
                    // dispose of the enumerable wrapper
                    wrapper.Dispose();
                    throw;
                }
                finally
                {
                    // If there are no more files to enumerate,
                    // dispose of the wrapper and move to the next wrapper
                    if (!wrapper.LastMove)
                    {
                        wrapper.Dispose();
                        EnumerateNextWrapper();
                    }
                }
            }