예제 #1
0
 public void SetConnectionMeteringContentHandles(ConnectionMeteringContentHandles handles, LocalStorageAPI localStorage)
 {
     if (((handles == null) || !handles.IsInitialized) || (handles.ContentHandleCount == 0))
     {
         this.m_cmLogSource.LogWarning("Invalid connection metering content handle received.");
     }
     else
     {
         if (handles.ContentHandleCount != 1)
         {
             this.m_cmLogSource.LogWarning("More than 1 connection metering content handle specified!");
         }
         bnet.protocol.ContentHandle contentHandle = handles.ContentHandle[0];
         if ((contentHandle == null) || !contentHandle.IsInitialized)
         {
             this.m_cmLogSource.LogWarning("The content handle received is not valid!");
         }
         else
         {
             this.m_cmLogSource.LogDebug("Received request to enable connection metering.");
             ContentHandle ch   = ContentHandle.FromProtocol(contentHandle);
             object[]      args = new object[] { ch };
             this.m_cmLogSource.LogDebug("Requesting file from local storage. ContentHandle={0}", args);
             localStorage.GetFile(ch, new LocalStorageAPI.DownloadCompletedCallback(this.DownloadCompletedCallback));
         }
     }
 }
예제 #2
0
        public void SetConnectionMeteringContentHandles(ConnectionMeteringContentHandles handles, LocalStorageAPI localStorage)
        {
            if (handles == null || !handles.IsInitialized || handles.ContentHandleCount == 0)
            {
                this.m_cmLogSource.LogWarning("Invalid connection metering content handle received.");
                return;
            }
            if (handles.ContentHandleCount != 1)
            {
                this.m_cmLogSource.LogWarning("More than 1 connection metering content handle specified!");
            }
            bnet.protocol.ContentHandle contentHandle = handles.ContentHandle.get_Item(0);
            if (contentHandle == null || !contentHandle.IsInitialized)
            {
                this.m_cmLogSource.LogWarning("The content handle received is not valid!");
                return;
            }
            this.m_cmLogSource.LogDebug("Received request to enable connection metering.");
            ContentHandle contentHandle2 = ContentHandle.FromProtocol(contentHandle);

            this.m_cmLogSource.LogDebug("Requesting file from local storage. ContentHandle={0}", new object[]
            {
                contentHandle2
            });
            localStorage.GetFile(contentHandle2, new LocalStorageAPI.DownloadCompletedCallback(this.DownloadCompletedCallback), null);
        }