private Server GetServer(ServerIdParameter server) { if (server == null) { throw new ArgumentNullException("server"); } IEnumerable <Server> objects = server.GetObjects <Server>(null, base.GlobalConfigSession); using (IEnumerator <Server> enumerator = objects.GetEnumerator()) { if (enumerator.MoveNext()) { return(enumerator.Current); } } throw new ServerNotFoundException("server not found", server.ToString()); }
protected override void WriteResult(IConfigurable dataObject) { PublicFolderDatabase publicFolderDatabase = (PublicFolderDatabase)dataObject; if (!publicFolderDatabase.IsReadOnly) { Server server = publicFolderDatabase.GetServer(); if (server == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(publicFolderDatabase.Identity.ToString())), ErrorCategory.InvalidOperation, publicFolderDatabase.Identity); } publicFolderDatabase.UseCustomReferralServerList = server.UseCustomReferralServerList; foreach (ServerCostPair serverCostPair in server.CustomReferralServerList) { ServerIdParameter serverIdParameter = new ServerIdParameter(new ADObjectId(null, serverCostPair.ServerGuid)); IEnumerable <Server> objects = serverIdParameter.GetObjects <Server>(null, base.DataSession); IEnumerator <Server> enumerator2 = objects.GetEnumerator(); Server server2 = null; if (enumerator2.MoveNext()) { server2 = enumerator2.Current; if (enumerator2.MoveNext()) { server2 = null; } } if (server2 == null) { publicFolderDatabase.CustomReferralServerList.Add(serverCostPair); } else { publicFolderDatabase.CustomReferralServerList.Add(new ServerCostPair(server2.Guid, server2.Name, serverCostPair.Cost)); } } publicFolderDatabase.ResetChangeTracking(); } base.WriteResult(dataObject); }