public void TestCreateVirtualFiles()
 {
     var basePath = IOUtil.GetRandomTempPath();
       DataMetaInfo meta = new DataMetaInfo() {
     DataUri = new Uri(Path.GetTempPath()),
     Files = new List<Uri>() {
       new Uri("/aaa/bbb", UriKind.Relative),
       new Uri("ccc/ddd", UriKind.Relative)
     }
       };
       //BitTorrentFilesysEventHandler.CreateVirtualFiles(new ShadowMetaFullPath(,basePath),
       //  XmlUtil.ToXml<DataMetaInfo>(meta));
 }
예제 #2
0
        public void Test()
        {
            DataMetaInfo info = new DataMetaInfo();
              info.DataUri = new Uri("file:///C:/aaa/bbb");
              info.Files = new List<Uri> {
            new Uri(@"ccc/ddd.txt", UriKind.Relative),
            new Uri(@"eee/ddd.txt", UriKind.Relative)
              };
              var xmlString = XmlUtil.ToXml<DataMetaInfo>(info);
              DataMetaInfo info1 = XmlUtil.FromXml<DataMetaInfo>(xmlString);

              Assert.AreEqual(info.DataUriString, info1.DataUriString);
              Assert.AreEqual(info.Files, info1.Files);
        }
예제 #3
0
 public void TestCreateVirtualFiles()
 {
     var          basePath = IOUtil.GetRandomTempPath();
     DataMetaInfo meta     = new DataMetaInfo()
     {
         DataUri = new Uri(Path.GetTempPath()),
         Files   = new List <Uri>()
         {
             new Uri("/aaa/bbb", UriKind.Relative),
             new Uri("ccc/ddd", UriKind.Relative)
         }
     };
     //BitTorrentFilesysEventHandler.CreateVirtualFiles(new ShadowMetaFullPath(,basePath),
     //  XmlUtil.ToXml<DataMetaInfo>(meta));
 }
예제 #4
0
        public void Test()
        {
            DataMetaInfo info = new DataMetaInfo();

            info.DataUri = new Uri("file:///C:/aaa/bbb");
            info.Files   = new List <Uri> {
                new Uri(@"ccc/ddd.txt", UriKind.Relative),
                new Uri(@"eee/ddd.txt", UriKind.Relative)
            };
            var          xmlString = XmlUtil.ToXml <DataMetaInfo>(info);
            DataMetaInfo info1     = XmlUtil.FromXml <DataMetaInfo>(xmlString);

            Assert.AreEqual(info.DataUriString, info1.DataUriString);
            Assert.AreEqual(info.Files, info1.Files);
        }
        public ActionResult Get(string nameSpace, string name)
        {
            string offset      = Request.Params["offset"];
            string bytesToRead = Request.Params["bytesToRead"];
            string peek        = Request.Params["peek"];

            try {
                if (!string.IsNullOrEmpty(peek) && Boolean.Parse(peek))
                {
                    // If peek == false, go to the next if condition.
                    DataMetaInfo meta      = _service.Peek(nameSpace, name);
                    var          xmlString = XmlUtil.ToXml <DataMetaInfo>(meta);
                    return(Content(xmlString));
                }
                else if (string.IsNullOrEmpty(offset) && string.IsNullOrEmpty(bytesToRead))
                {
                    DataMetaInfo meta      = _service.Get(nameSpace, name);
                    var          xmlString = XmlUtil.ToXml <DataMetaInfo>(meta);
                    return(Content(xmlString));
                }
                else if (!string.IsNullOrEmpty(bytesToRead) &&
                         !string.IsNullOrEmpty(bytesToRead))
                {
                    // Have both needed arguments
                    var dataBlock =
                        _service.Get(nameSpace, name, Int64.Parse(offset), Int32.Parse(bytesToRead));
                    return(File(dataBlock, HttpUtil.OctetStreamContentType,
                                string.Format("{0}.{1}.{2}", name, offset, bytesToRead)));
                }
                else
                {
                    var toThrow = new HttpException((int)HttpStatusCode.BadRequest,
                                                    "Unclear whether to download piece or whole data.");
                    Util.LogBeforeThrow(toThrow, _log_props);
                    throw toThrow;
                }
            } catch (DictionaryKeyNotFoundException ex) {
                var toThrow = new HttpException((int)HttpStatusCode.NotFound,
                                                "No file/directory available at this key.", ex);
                Util.LogBeforeThrow(toThrow, _log_props);
                throw toThrow;
            } catch (DictionaryServiceException ex) {
                var toThrow = new HttpException((int)HttpStatusCode.ServiceUnavailable,
                                                "Unable to get.", ex);
                Util.LogBeforeThrow(toThrow, _log_props);
                throw toThrow;
            }
        }
예제 #6
0
 protected SQLiteDataSerializer(DataMetaInfo meta) : base(meta)
 {
 }