private void FixParentChain(FolderRec sourceFolder)
 {
     this.syncContext.Logger.LogEvent(LogEventType.Warning, string.Format(CultureInfo.InvariantCulture, "PublicFolderHierarchyProxyPool is calling EnsureDestinationFolderHasParentChain for folder with missing parent. Folder {0}.", new object[]
     {
         sourceFolder
     }));
     this.syncExecutor.EnsureDestinationFolderHasParentChain(sourceFolder);
 }
 IFolderProxy IFxProxyPool.CreateFolder(FolderRec folder)
 {
     PublicFolderHierarchyProxyPool.< > c__DisplayClass7 CS$ < > 8__locals1 = new PublicFolderHierarchyProxyPool.< > c__DisplayClass7();
     CS$ < > 8__locals1.folder      = folder;
     CS$ < > 8__locals1.< > 4__this = this;
     if (CS$ < > 8__locals1.folder.FolderType == FolderType.Search)
     {
         return(null);
     }
     CS$ < > 8__locals1.folderProxy = null;
     this.transientExceptionHandler.ExecuteWithRetry(new TryDelegate(CS$ < > 8__locals1, (UIntPtr)ldftn(< Microsoft.Exchange.MailboxReplicationService.IFxProxyPool.CreateFolder > b__6)));
     return(CS$ < > 8__locals1.folderProxy);
 }
        public static byte[] GetDumpsterEntryIdFromFolderRec(FolderRec folderRec)
        {
            ArgumentValidator.ThrowIfNull("folderRec", folderRec);
            if (folderRec.AdditionalProps != null)
            {
                foreach (PropValueData data in folderRec.AdditionalProps)
                {
                    PropValue native = DataConverter <PropValueConverter, PropValue, PropValueData> .GetNative(data);

                    if (!native.IsNull() && !native.IsError() && native.PropTag == PropTag.IpmWasteBasketEntryId)
                    {
                        return(native.GetBytes());
                    }
                }
            }
            return(null);
        }
        private IFolderProxy CreateFolder(FolderRec folder)
        {
            IFolderProxy result = null;
            bool         flag;

            folder.EntryId  = this.syncContext.MapSourceToDestinationFolderId(folder.EntryId, out flag);
            folder.ParentId = this.syncContext.MapSourceToDestinationFolderId(folder.ParentId, out flag);
            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                IDestinationFolder folder2 = this.destinationMailbox.GetFolder(folder.EntryId);
                if (folder2 != null)
                {
                    disposeGuard.Add <IDestinationFolder>(folder2);
                    folder2.SetProps(CommonUtils.PropertiesToDelete);
                    FolderRec folderRec = folder2.GetFolderRec(null, GetFolderRecFlags.None);
                    if (!CommonUtils.IsSameEntryId(folderRec.ParentId, folder.ParentId))
                    {
                        try
                        {
                            this.destinationMailbox.MoveFolder(folderRec.EntryId, folderRec.ParentId, folder.ParentId);
                        }
                        catch (ObjectNotFoundException arg)
                        {
                            PublicFolderHierarchyProxyPool.Tracer.TraceWarning <FolderRec, FolderRec, ObjectNotFoundException>((long)this.GetHashCode(), "ObjectNotFoundException caught during MoveFolder. Calling to FixParentChain before reattempting the folder move. SourceFolder={0}. DestinationFolder={1}. Exception={2}", folder, folderRec, arg);
                            this.FixParentChain(folder);
                            this.destinationMailbox.MoveFolder(folderRec.EntryId, folderRec.ParentId, folder.ParentId);
                        }
                    }
                    result = base.WrappedObject.GetFolderProxy(folder.EntryId);
                    PublicFolderHierarchyProxyPool.Tracer.TraceDebug <FolderRec>((long)this.GetHashCode(), "Folder updated: {0}", folder);
                    this.syncContext.Logger.LogFolderUpdated(folder.EntryId);
                }
                else
                {
                    try
                    {
                        result = base.WrappedObject.CreateFolder(folder);
                    }
                    catch (ObjectNotFoundException arg2)
                    {
                        PublicFolderHierarchyProxyPool.Tracer.TraceWarning <FolderRec, ObjectNotFoundException>((long)this.GetHashCode(), "ObjectNotFoundException caught during CreateFolder. Calling to FixParentChain before reattempting the folder creation. Folder={0}. Exception={1}", folder, arg2);
                        this.FixParentChain(folder);
                        result = base.WrappedObject.CreateFolder(folder);
                    }
                    folder2 = this.destinationMailbox.GetFolder(folder.EntryId);
                    disposeGuard.Add <IDestinationFolder>(folder2);
                    PublicFolderHierarchyProxyPool.Tracer.TraceDebug <FolderRec>((long)this.GetHashCode(), "Folder created: {0}", folder);
                    this.syncContext.Logger.LogFolderCreated(folder.EntryId);
                }
                byte[] dumpsterEntryIdFromFolderRec = PublicFolderHierarchyProxyPool.GetDumpsterEntryIdFromFolderRec(folder);
                if (dumpsterEntryIdFromFolderRec != null)
                {
                    bool   flag2;
                    byte[] value = this.syncContext.MapSourceToDestinationFolderId(dumpsterEntryIdFromFolderRec, out flag2);
                    folder2.SetProps(new PropValueData[]
                    {
                        new PropValueData(PropTag.IpmWasteBasketEntryId, value)
                    });
                }
            }
            return(result);
        }