Inheritance: ContentInstallStep
コード例 #1
0
        private void TreeWalker(string path)
        {
            var containerPath = TransformFileToContent(path);

            var dirs         = Directory.GetDirectories(path);
            var files        = new List <string>(Directory.GetFiles(path));
            var contentFiles = new List <string>(Directory.GetFiles(path, "*.content"));

            if (containerPath.ToLower() == "/root/system/schema/contenttypes")
            {
                foreach (var file in files)
                {
                    _manifest.AddContentType(new ContentTypeInstallStep(_manifest, null)
                    {
                        ResourceName = file
                    });
                }
                return;
            }

            foreach (string contentFile in contentFiles)
            {
                files.Remove(contentFile);
                var contentInfo = new ContentInstallStep(_manifest, contentFile, containerPath);
                _manifest.AddContent(contentInfo);
                contentInfo.Initialize();

                foreach (var attachment in contentInfo.Content.Attachments)
                {
                    files.Remove(attachment.FileName);
                }
            }
            while (files.Count > 0)
            {
                var filePath = files[0];
                var fileInfo = new FileInstallStep(_manifest, filePath, containerPath);
                _manifest.AddContent(fileInfo);
                files.RemoveAt(0);
            }

            foreach (string subPath in dirs)
            {
                TreeWalker(subPath);
            }
        }
コード例 #2
0
		private void TreeWalker(string path)
		{
			var containerPath = TransformFileToContent(path);

			var dirs = Directory.GetDirectories(path);
			var files = new List<string>(Directory.GetFiles(path));
			var contentFiles = new List<string>(Directory.GetFiles(path, "*.content"));
			if (containerPath.ToLower() == "/root/system/schema/contenttypes")
			{
				foreach(var file in files)
					_manifest.AddContentType(new ContentTypeInstallStep(_manifest, null) { ResourceName = file });
				return;
			}

			foreach (string contentFile in contentFiles)
			{
				files.Remove(contentFile);
				var contentInfo = new ContentInstallStep(_manifest, contentFile, containerPath);
				_manifest.AddContent(contentInfo);
				contentInfo.Initialize();

				foreach (var attachment in contentInfo.Content.Attachments)
				    files.Remove(attachment.FileName);
			}
			while (files.Count > 0)
			{
				var filePath = files[0];
				var fileInfo = new FileInstallStep(_manifest, filePath, containerPath);
				_manifest.AddContent(fileInfo);
				files.RemoveAt(0);
			}

			foreach (string subPath in dirs)
				TreeWalker(subPath);
		}