private void Handle_OnRequestAddBranch(MediaServerDevice sender, DvMediaContainer parentContainer, ref IDvMedia[] addTheseBranches) { Exception error = null; this.m_LockRoot.WaitOne(); try { if (parentContainer == this.mediaServer.Root) { throw new Error_RestrictedObject("Cannot create objects directly in the root container."); } else if (parentContainer.IsRestricted) { throw new Error_RestrictedObject("Cannot create objects in a restricted container."); } InnerMediaDirectory mediadir = (InnerMediaDirectory) parentContainer.Tag; bool allowNewLocalResources = true; if (mediadir != null) { allowNewLocalResources = Directory.Exists(mediadir.directory.FullName); } foreach (IDvMedia branch in addTheseBranches) { // Throw an exception if ANYTHING is bad. Add is always // atomic per request. // ValidateBranch(parentContainer, branch, allowNewLocalResources); } foreach (IDvMedia branch in addTheseBranches) { // No exceptions were thrown so go ahead and add new // files and directories to the local file system // for the new tree. // if (branch.IsReference == true) { parentContainer.AddBranch(branch); } else { ModifyLocalFileSystem(parentContainer, branch); } } } catch (Exception e) { error = e; } this.m_LockRoot.ReleaseMutex(); if (error != null) { throw new ApplicationException("Handle_OnRequestAddBranch()", error); } }