public virtual void Serialize(SyncItem item, Stream outputStream)
 {
     using (var writer = new StreamWriter(outputStream))
     {
         item.Serialize(writer);
     }
 }
示例#2
0
        public void SaveItem(SyncItem syncItem)
        {
            Assert.ArgumentNotNull(syncItem, "syncItem");

            var newPath = GetPhysicalSyncItemPath(syncItem);

            var parentPath = Path.GetDirectoryName(newPath);

            if (parentPath != null)
            {
                Directory.CreateDirectory(parentPath);
            }

            using (new WatcherDisabler(_watcher))
            {
                using (var fileStream = File.Open(newPath, FileMode.Create, FileAccess.Write, FileShare.Write))
                {
                    using (var writer = new StreamWriter(fileStream))
                    {
                        syncItem.Serialize(writer);
                    }
                }
            }

            _index.UpdateIndexes(syncItem);
        }
 public virtual void Serialize(SyncItem item, Stream outputStream)
 {
     using (var writer = new StreamWriter(outputStream))
     {
         item.Serialize(writer);
     }
 }
        private static void WriteResultsToFile(Stream stream, SyncItem syncItem)
        {
            TruncateFile(stream);

            using (TextWriter writer = new StreamWriter(stream))
            {
                syncItem.Serialize(writer);
            }
        }
 public static void SaveSyncItem(SyncItem item, string path)
 {
     using (var fileStream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None))
     {
         using (var writer = new StreamWriter(fileStream))
         {
             item.Serialize(writer);
         }
     }
 }
示例#6
0
 public static void SaveSyncItem(SyncItem item, string path)
 {
     using (var fileStream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None))
     {
         using (var writer = new StreamWriter(fileStream))
         {
             item.Serialize(writer);
         }
     }
 }
示例#7
0
        public void CreateItem(SyncItem syncItem)
        {
            var newPath = PathUtils.GetFilePath(new ItemReference(syncItem.DatabaseName, syncItem.ItemPath).ToString());

            var parentPath = Path.GetDirectoryName(newPath);
            Directory.CreateDirectory(parentPath);

            using (var fileStream = File.Open(newPath, FileMode.CreateNew, FileAccess.Write, FileShare.Write))
            {
                using (var writer = new StreamWriter(fileStream))
                {
                    syncItem.Serialize(writer);
                }
            }

            _innerItems.Add(syncItem);
        }
示例#8
0
        public void CreateItem(SyncItem syncItem)
        {
            var newPath = PathUtils.GetFilePath(new ItemReference(syncItem.DatabaseName, syncItem.ItemPath).ToString());

            var parentPath = Path.GetDirectoryName(newPath);

            Directory.CreateDirectory(parentPath);

            using (var fileStream = File.Open(newPath, FileMode.CreateNew, FileAccess.Write, FileShare.Write))
            {
                using (var writer = new StreamWriter(fileStream))
                {
                    syncItem.Serialize(writer);
                }
            }

            _innerItems.Add(syncItem);
        }
示例#9
0
        public static SyncItem Clone(this SyncItem item)
        {
            using (var ms = new MemoryStream())
            {
                using (var writer = new StreamWriter(ms))
                {
                    item.Serialize(writer);

                    writer.Flush();

                    ms.Seek(0, SeekOrigin.Begin);

                    using (var reader = new StreamReader(ms))
                    {
                        return(SyncItem.ReadItem(new Tokenizer(reader)));
                    }
                }
            }
        }
示例#10
0
		public void SaveItem(SyncItem syncItem)
		{
			Assert.ArgumentNotNull(syncItem, "syncItem");

			var newPath = GetPhysicalSyncItemPath(syncItem);

			var parentPath = Path.GetDirectoryName(newPath);
			if (parentPath != null)
				Directory.CreateDirectory(parentPath);

			using (new WatcherDisabler(_watcher))
			{
				using (var fileStream = File.Open(newPath, FileMode.Create, FileAccess.Write, FileShare.Write))
				{
					using (var writer = new StreamWriter(fileStream))
					{
						syncItem.Serialize(writer);
					}
				}
			}

			_index.UpdateIndexes(syncItem);
		}