コード例 #1
0
		internal static File LoadFileWithId(int id)
		{
			try
			{
				var media = new Media(id);
				var file = new File();
				LoadMediaBase(file, media);
				file.FileName = media.Text;
				file.MultilanguageFileName = media.HasProperty("title") ? media.getProperty("title").Value.ToString() : media.Text;
				return file;
			}
			catch (Exception)
			{
				return null;
			}
		}
コード例 #2
0
		private static void LoadMediaBase(MediaBase entity, Media media)
		{
			entity.Id = media.Id;
			entity.ParentId = media.ParentId;
			entity.CreateDateTime = media.CreateDateTime;
			entity.IsTrashed = media.IsTrashed;

			entity.FileExtension = media.getProperty("umbracoExtension").Value.ToString();
			entity.RelativePathToFile = media.HasProperty("umbracoFile") ? media.getProperty("umbracoFile").Value.ToString() : string.Empty;
			entity.FileSize = Convert.ToInt64(media.getProperty("umbracoBytes").Value.ToString());
		}