/// <summary> /// Calls the base class because there may be some generic behavior in it /// List the Attachments by id /// </summary> /// <param name="entityId">attatchment id</param> /// <returns>A list of attachments</returns> public override async Task <IEnumerable <ILightAttachment> > ListAttachmentsByIdAsync <T>(string entityId) { await base.ListAttachmentsByIdAsync <T>(entityId); ILightAttachment lightAttachmentStorage; List <ILightAttachment> list = new List <ILightAttachment>(); Document doc = await GetByIdAsync <Document>(entityId); foreach (Attachment attachment in _client.CreateAttachmentQuery(doc.SelfLink)) { LightAttachment att = new LightAttachment { Id = attachment.Id, ContentType = attachment.ContentType }; if (_mediaStorage != null) { lightAttachmentStorage = await _mediaStorage.GetAsync(entityId, att.Id); att.MediaStream = lightAttachmentStorage.MediaStream; } else { att.MediaStream = File.OpenRead(attachment.MediaLink); } list.Add(att); } return(list); }
/// <summary> /// Converts the Attachment type to a LightAttachment type attachment /// </summary> /// <param name="attachment">the Attachment</param> /// <returns>The attachment in LightAttatchment type</returns> private LightAttachment ConvertLightAttachment(Attachment attachment) { LightAttachment lightAttachment = new LightAttachment() { Id = attachment.Id, Name = attachment.Id, MediaLink = attachment.MediaLink, ContentType = attachment.ContentType, ResourceId = attachment.ResourceId }; return(lightAttachment); }
/// <summary> /// Azure File allows you to store binary blobs/media /// either with Azure File or to your own remote media store. /// Allows you to represent the metadata of a media /// in terms of a special document called attachment /// </summary> /// <param name="entityId">id of the entity</param> /// <param name="fileName"> the name of the file</param> /// <param name="attachment">the attachment</param> /// <returns>The attachtment</returns> private LightAttachment GetLightAttachment(string entityId, string fileName, Stream attachment) { LightAttachment lightAttachment = new LightAttachment() { Id = fileName, Name = fileName, MediaStream = attachment, MediaLink = fileName, ResourceId = entityId, ContentType = MimeMapping.MimeUtility.GetMimeMapping(fileName) }; return(lightAttachment); }
public async Task <ILightAttachment> GetAsync(string resourceId, string id) { Stream stream = new MemoryStream(); await _client.DownloadObjectAsync(this.Container, resourceId + "/" + id, stream); LightAttachment _blob = new LightAttachment() { MediaStream = stream, Id = id, ResourceId = resourceId, ContentType = MimeMapping.MimeUtility.GetMimeMapping(id), Name = id }; return(_blob); }
public async Task <ILightAttachment> GetAsync(string resourceId, string id) { var blob = _containerReference.GetBlobReference(id); Stream stream = new MemoryStream(); await blob.DownloadToStreamAsync(stream); LightAttachment _blob = new LightAttachment() { MediaStream = stream, Id = id, ResourceId = resourceId, ContentType = blob.Properties.ContentType, Name = blob.Name, MediaLink = blob.Uri.AbsoluteUri }; return(_blob); }
/// <summary> /// Get Attachments /// But Google Cloud Firestore doesn't support attachments /// </summary> /// <param name="entityId">attachment id</param> /// <param name="fileName">name of the file</param> /// <returns>The attachment type LightAttachment</returns> public override async Task <ILightAttachment> GetAttachmentAsync <T>(string entityId, string fileName) { await base.GetAttachmentAsync <T>(entityId, fileName); ILightAttachment lightAttachment = new LightAttachment(); if (_mediaStorage != null) { var attachment = _mediaStorage.GetAsync("", ""); ILightAttachment lightAttachmentStorage = await _mediaStorage.GetAsync(entityId, fileName); lightAttachment.MediaStream = lightAttachmentStorage.MediaStream; } else { lightAttachment = null; } return(lightAttachment); }
/// <summary> /// Calls the base class because there may be some generic behavior in it /// Deletes the especific attachment /// </summary> /// <param name="entityId"> id of the document</param> /// <param name="fileName">id of the attachment</param> public override async Task DeleteAttachmentAsync <T>(string entityId, string fileName) { await base.DeleteAttachmentAsync <T>(entityId, fileName); Attachment attachment = (Attachment)await _client.ReadAttachmentAsync(GetAttachmentUri(entityId, fileName)); if (attachment != null) { await _client.DeleteAttachmentAsync(GetAttachmentUri(entityId, fileName)); if (_mediaStorage != null) { LightAttachment att = new LightAttachment { Id = fileName, ResourceId = entityId }; _mediaStorage.Remove(att); } } }
public async Task <ILightAttachment> GetAsync(string resourceId, string id) { Stream stream = new MemoryStream(); GetObjectRequest request = new GetObjectRequest { BucketName = Container, Key = id }; stream = await _client.GetObjectStreamAsync(Container, resourceId + "/" + id, null); LightAttachment _blob = new LightAttachment() { MediaStream = stream, Id = id, ResourceId = resourceId, ContentType = MimeMapping.MimeUtility.GetMimeMapping(id), Name = id }; return(_blob); }
public Model GetWornMesh(int gender) { int i1 = maleModel1; int i2 = maleModel2; int i3 = maleModel3; if (gender == 1) { i1 = femaleModel1; i2 = femaleModel2; i3 = femaleModel3; } if (i1 == -1) { return(null); } Model mesh = new Model(i1); if (i2 != -1) { if (i3 != -1) { mesh = new Model(3, new Model[] { mesh, new Model(i2), new Model(i3) }); } else { mesh = new Model(2, new Model[] { mesh, new Model(i2) }); } } if (gender == 0 && maleOffY != 0) { mesh.Translate(0, maleOffY, 0); } if (gender == 1 && femaleOffY != 0) { mesh.Translate(0, femaleOffY, 0); } if (oldColor != null) { mesh.SetColors(oldColor, newColor); } if (particleConfigs != null) { foreach (var config in particleConfigs) { var attachment = new ParticleAttachment(config.vertexIndex); attachment.EmissionRate = (float)config.emissionRate; attachment.GravityModifier = (float)config.gravityModifier; attachment.StartColor = new Color((float)config.r, (float)config.g, (float)config.b, (float)config.a); attachment.StartLifetime = (float)config.startLifetime; attachment.StartSize = (float)config.startSize; attachment.StartSpeed = (float)config.startSpeed; mesh.Attachments.Add(attachment); } } if (index == 7053) { var attachment = new LightAttachment(13); mesh.Attachments.Add(attachment); } return(mesh); }