SetBucketRefererRequestSerializer.cs 1021 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System.IO;
  8. namespace Aliyun.OSS.Transform
  9. {
  10. internal class SetBucketRefererRequestSerializer : RequestSerializer<SetBucketRefererRequest, RefererConfiguration>
  11. {
  12. public SetBucketRefererRequestSerializer(ISerializer<RefererConfiguration, Stream> contentSerializer)
  13. : base(contentSerializer)
  14. { }
  15. public override Stream Serialize(SetBucketRefererRequest request)
  16. {
  17. var model = new RefererConfiguration
  18. {
  19. AllowEmptyReferer = request.AllowEmptyReferer,
  20. RefererList = new RefererConfiguration.RefererListModel {Referers = new string[request.RefererList.Count]}
  21. };
  22. for (var i = 0; i < request.RefererList.Count ; i++)
  23. model.RefererList.Referers[i] = request.RefererList[i];
  24. return ContentSerializer.Serialize(model);
  25. }
  26. }
  27. }