/// <summary>
 /// Makes a request to a remote media server to import the binary file from a URI to 
 /// a resource that is part of the server's content hierarchy.
 /// </summary>
 /// <param name="sourceUri">the URI where binary should be pulled</param>
 /// <param name="importHere">the <see cref="ICpResource"/> object that represents the
 /// destination of the imported binary
 /// </param>
 /// <param name="Tag">
 /// Miscellaneous, user-provided object for tracking this 
 /// asynchronous call. Can be used as a means to pass a 
 /// user-defined "state object" at invoke-time so that 
 /// the executed callback during results-processing can be
 /// aware of the component's state at the time of the call.
 /// </param>
 /// <param name="callback">the callback to execute when results become available</param>
 /// <exception cref="Error_ResourceNotOnServer">
 /// Thrown when attempting to delete a resource object that
 /// is not part of the server's content hierarchy.
 /// </exception>
 /// <exception cref="NullReferenceException">
 /// Thrown when attempting a remove a resource that has
 /// a null/empty value for its contentUri.
 /// </exception>
 /// <exception cref="Error_CannotGetParent">
 /// Thrown if the parent of this object is null.
 /// </exception>
 /// <exception cref="InvalidCastException">
 /// Thrown if the parent of this object is not a <see cref="CpMediaContainer"/>.
 /// </exception>
 public void RequestImportResource(System.Uri sourceUri, ICpResource importHere, object Tag, CpMediaDelegates.Delegate_ResultImportResource callback)
 {
     // calls parent's implementation of method
     CpMediaContainer parent = (CpMediaContainer) this.Parent;
     parent.RequestImportResource(sourceUri, importHere, Tag, callback);
 }
        /// <summary>
        /// Allows a programmer to request a remote mediaserver to change the metadata 
        /// for this item.
        /// </summary>
        /// <param name="useThisMetadata">
        /// Media object that represents what the new metadata should be for the object.
        /// </param>
        /// <param name="Tag">
        /// Miscellaneous, user-provided object for tracking this 
        /// asynchronous call. Can be used as a means to pass a 
        /// user-defined "state object" at invoke-time so that 
        /// the executed callback during results-processing can be
        /// aware of the component's state at the time of the call.
        /// </param>
        /// <param name="callback">
        /// Delegate executes when the results for the method are available.
        /// </param>
        /// <exception cref="Error_CannotGetParent">
        /// Thrown if the parent of this object is null.
        /// </exception>
        /// <exception cref="InvalidCastException">
        /// Thrown if this object's parent is not a 
        /// <see cref="CpMediaContainer"/> object.
        /// </exception>
        public void RequestUpdateObject(IUPnPMedia useThisMetadata, object Tag, CpMediaDelegates.Delegate_ResultUpdateObject callback)
        {
            CpMediaContainer p = (CpMediaContainer) this.Parent;

            if (p != null)
            {
                p.RequestUpdateObject(this, useThisMetadata, Tag, callback);
            }
            else
            {
                throw new Error_CannotGetParent(this);
            }
        }
        /// <summary>
        /// Makes a request on the remote media server to delete this
        /// object from its parent.
        /// </summary>
        /// <param name="Tag">
        /// Miscellaneous, user-provided object for tracking this 
        /// asynchronous call. Can be used as a means to pass a 
        /// user-defined "state object" at invoke-time so that 
        /// the executed callback during results-processing can be
        /// aware of the component's state at the time of the call.
        /// </param>
        /// <param name="callback">
        /// Delegate executes when the results for the method are available.
        /// </param>
        /// <exception cref="Error_CannotGetParent">
        /// Thrown if the parent of this object is null.
        /// </exception>
        /// <exception cref="InvalidCastException">
        /// Thrown if this object's parent is not a 
        /// <see cref="CpMediaContainer"/> object.
        /// </exception>
        public void RequestDestroyObject(object Tag, CpMediaDelegates.Delegate_ResultDestroyObject callback)
        {
            CpMediaContainer p = (CpMediaContainer) this.Parent;

            if (p != null)
            {
                p.RequestDestroyObject(this, Tag, callback);
            }
            else
            {
                throw new Error_CannotGetParent(this);
            }
        }
 /// <summary>
 /// Makes a request to a remote media server to export one of its binary files
 /// to another location.
 /// </summary>
 /// <param name="exportThis">
 /// The resource (of this media object) that should be exported.
 /// </param>
 /// <param name="sendHere">
 /// The uri where the binary should be sent.
 /// </param>
 /// <param name="Tag">
 /// Miscellaneous, user-provided object for tracking this 
 /// asynchronous call. Can be used as a means to pass a 
 /// user-defined "state object" at invoke-time so that 
 /// the executed callback during results-processing can be
 /// aware of the component's state at the time of the call.
 /// </param>
 /// <param name="callback">the callback to execute when results become available</param>
 /// <exception cref="Error_CannotGetParent">
 /// Thrown if the parent of this object is null.
 /// </exception>
 public void RequestExportResource(ICpResource exportThis, System.Uri sendHere, object Tag, CpMediaDelegates.Delegate_ResultExportResource callback)
 {
     // calls parent's implementation of method
     CpMediaContainer parent = (CpMediaContainer) this.Parent;
     parent.RequestExportResource(exportThis, sendHere, Tag, callback);
 }
        /// <summary>
        /// This method will invoke a CDS browse request and provide the results
        /// directly the application-caller.
        /// <para>
        /// Implementation simply calls the parent owner's implementation of 
        /// <see cref="CpMediaContainer.RequestBrowse "/>(ICpMedia, CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag, string, uint, uint, string).
        /// </para>
        /// </summary>
        /// <param name="BrowseFlag">browse metadata or direct children</param>
        /// <param name="Filter">
        /// Comma-separated value list of metadata names to include
        /// in the response. For all metadata, use * character.
        /// </param>
        /// <param name="StartingIndex">
        /// If obtaining children, the start index of the results.
        /// Otherwise set to zero.
        /// </param>
        /// <param name="RequestedCount">
        /// If obtaining children the max number of child objects
        /// to retrieve. Otherwise use zero.
        /// </param>
        /// <param name="SortCriteria">
        /// Comma-separated value list of metadata names to use for
        /// sorting, such that preceding each metadata name (but after
        /// the comma) a + or - character is present to indicate
        /// ascending or descending sort order for that property.
        /// </param>
        /// <param name="Tag">
        /// Miscellaneous, user-provided object for tracking this 
        /// asynchronous call. Can be used as a means to pass a 
        /// user-defined "state object" at invoke-time so that 
        /// the executed callback during results-processing can be
        /// aware of the component's state at the time of the call.
        /// </param>
        /// <param name="callback">the callback to execute when results become available</param>
        /// <exception cref="ApplicationException">
        /// Thrown if the BrowseFlag value is BrowseDirectChildren because only the
        /// object's metadata can be obtained use browse.
        /// </exception>
        public void RequestBrowse(CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, string Filter, uint StartingIndex, uint RequestedCount, string SortCriteria, object Tag, CpMediaDelegates.Delegate_ResultBrowse callback)
        {
            if (BrowseFlag == CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag.BROWSEDIRECTCHILDREN)
            {
                throw new ApplicationException("BrowseFlag cannot be BROWSEDIRECTCHILDREN");
            }

            CpMediaContainer parent = (CpMediaContainer) this.Parent;

            parent.RequestBrowse(this, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, Tag, callback);
        }
 /// <summary>
 /// Requests a remote media server to delete a resource from its local file system.
 /// </summary>
 /// <param name="deleteThisResource">the resource to request for deletion</param>
 /// <param name="Tag">
 /// Miscellaneous, user-provided object for tracking this 
 /// asynchronous call. Can be used as a means to pass a 
 /// user-defined "state object" at invoke-time so that 
 /// the executed callback during results-processing can be
 /// aware of the component's state at the time of the call.
 /// </param>
 /// <param name="callback">callback to execute when results have been obtained</param>
 /// <exception cref="Error_ResourceNotOnServer">
 /// Thrown when attempting to delete a resource object that
 /// is not part of the server's content hierarchy.
 /// </exception>
 /// <exception cref="NullReferenceException">
 /// Thrown when attempting a remove a resource that has
 /// a null/empty value for its contentUri.
 /// </exception>
 /// <exception cref="Error_CannotGetParent">
 /// Thrown if the parent of this object is null.
 /// </exception>
 /// <exception cref="InvalidCastException">
 /// Thrown if the parent of this object is not a <see cref="CpMediaContainer"/>.
 /// </exception>
 public void RequestDeleteResource(ICpResource deleteThisResource, object Tag, CpMediaDelegates.Delegate_ResultDeleteResource callback)
 {
     // calls parent's implementation of method
     CpMediaContainer parent = (CpMediaContainer) this.Parent;
     parent.RequestDeleteResource(deleteThisResource, Tag, callback);
 }
 public override void RequestUpdateObject(IUPnPMedia useThisMetadata, object Tag, CpMediaDelegates.Delegate_ResultUpdateObject callback)
 {
 }
 public override void RequestDestroyObject(object Tag, CpMediaDelegates.Delegate_ResultDestroyObject callback)
 {
 }
        /// <summary>
        /// Allows the programmer to request that a transfer stop.
        /// </summary>
        /// <param name="Tag">
        /// Miscellaneous, user-provided object for tracking this 
        /// asynchronous call. Can be used as a means to pass a 
        /// user-defined "state object" at invoke-time so that 
        /// the executed callback during results-processing can be
        /// aware of the component's state at the time of the call.
        /// </param>
        /// <param name="callback">the callback to execute when results become available</param>
        /// <exception cref="ApplicationException">
        /// Thrown if the resource object associated with thsi transfer is null. 
        /// Such an exception would indicate that the system has improperly instantiated the transfer object.
        /// </exception>
        /// <exception cref="NullReferenceException">
        /// Thrown if the transfer object cannot find its media server.
        /// </exception>
        public void RequestStopTransferResource(object Tag, CpMediaDelegates.Delegate_ResultStopTransferResource callback)
        {
            if (this.m_Resource == null)
            {
                throw new ApplicationException("Bad Evil. The resource associated with this transfer object is null.");
            }

            CpMediaServer server = (CpMediaServer) this.mwr_Server.Target;
            if(this.mwr_Server.IsAlive == false)
            {
                throw new NullReferenceException("The media server object is null. Media server may have disappeared from UPnP network.");
            }

            StopTransferResourceRequestTag rtag = new StopTransferResourceRequestTag();
            rtag.Tag = Tag;
            rtag.Callback = callback;

            server.RequestStopTransferResource (this.m_TransferID, rtag, new CpContentDirectory.Delegate_OnResult_StopTransferResource(this.SinkResult_StopTransferResource));
        }
 /// <summary>
 /// Makes a request to a remote media server to import the binary file from a URI to 
 /// the resource URI represented by this object.
 /// </summary>
 /// <param name="sourceUri">the URI where binary should be pulled</param>
 /// <param name="Tag">
 /// Miscellaneous, user-provided object for tracking this 
 /// asynchronous call. Can be used as a means to pass a 
 /// user-defined "state object" at invoke-time so that 
 /// the executed callback during results-processing can be
 /// aware of the component's state at the time of the call.
 /// </param>
 /// <param name="callback">the callback to execute when results become available</param>
 /// <exception cref="InvalidCastException">
 /// Thrown if the owner of this object is not an <see cref="ICpMedia"/> instance.
 /// </exception>
 public void RequestImportResource(System.Uri sourceUri, object Tag, CpMediaDelegates.Delegate_ResultImportResource callback)
 {
     // simpy calls the owner object's implementation of the method by the same name
     ICpMedia owner = (ICpMedia) this.Owner;
     owner.RequestImportResource(sourceUri, this, Tag, callback);
 }
 /// <summary>
 /// Makes a request to a remote media server to delete the resource from its local file system.
 /// </summary>
 /// <param name="Tag">
 /// Miscellaneous, user-provided object for tracking this 
 /// asynchronous call. Can be used as a means to pass a 
 /// user-defined "state object" at invoke-time so that 
 /// the executed callback during results-processing can be
 /// aware of the component's state at the time of the call.
 /// </param>
 /// <param name="callback">the callback to execute when results become available</param>
 /// <exception cref="InvalidCastException">
 /// Thrown if the owner of this object is not an <see cref="ICpMedia"/> instance.
 /// </exception>
 public void RequestDeleteResource(object Tag, CpMediaDelegates.Delegate_ResultDeleteResource callback)
 {
     // simpy calls the owner object's implementation of the method by the same name
     ICpMedia owner = (ICpMedia) this.Owner;
     owner.RequestDeleteResource(this, Tag, callback);
 }