public Maybe <Stream> GetBlobOffsetStream(string containerName, string blobName, long offsetBytes, long lengthBytes, out string etag) { lock (_syncRoot) { if (!Containers.ContainsKey(containerName) || !Containers[containerName].BlobNames.Contains(blobName)) { etag = null; return(Maybe <Stream> .Empty); } etag = Containers[containerName].BlobsEtag[blobName]; var stream = Containers[containerName].GetBlob(blobName); stream.Position = offsetBytes; var returnStream = new MemoryStream(); byte[] buffer = new byte[8192]; int bytesRead = 1; while (lengthBytes > 0 && bytesRead > 0) { bytesRead = stream.Read(buffer, 0, Math.Min((int)lengthBytes, buffer.Length)); returnStream.Write(buffer, 0, bytesRead); lengthBytes -= bytesRead; } returnStream.Position = 0; return(new Maybe <Stream>(returnStream)); } }
public Maybe <XElement> GetBlobXml(string containerName, string blobName, out string etag, IDataSerializer serializer = null) { etag = null; var formatter = (serializer ?? DefaultSerializer) as IIntermediateDataSerializer; if (formatter == null) { return(Maybe <XElement> .Empty); } MemoryStream stream; lock (_syncRoot) { if (!Containers.ContainsKey(containerName) || !Containers[containerName].BlobNames.Contains(blobName)) { return(Maybe <XElement> .Empty); } etag = Containers[containerName].BlobsEtag[blobName]; stream = Containers[containerName].GetBlob(blobName); } stream.Position = 0; return(formatter.UnpackXml(stream)); }
/// <remarks></remarks> public Maybe <T> UpsertBlobOrSkip <T>( string containerName, string blobName, Func <Maybe <T> > insert, Func <T, Maybe <T> > update, IDataSerializer serializer = null) { lock (_syncRoot) { Maybe <T> input; if (Containers.ContainsKey(containerName)) { if (Containers[containerName].BlobNames.Contains(blobName)) { var blobData = Containers[containerName].GetBlob(blobName); input = blobData == null ? Maybe <T> .Empty : (T)blobData; } else { input = Maybe <T> .Empty; } } else { Containers.Add(containerName, new MockContainer()); input = Maybe <T> .Empty; } var output = input.HasValue ? update(input.Value) : insert(); if (output.HasValue) { Containers[containerName].SetBlob(blobName, output.Value); } return(output); } }
/// <inheritdoc/> protected override async Task ExecuteAsync(CancellationToken stoppingToken) { if (!this.Environment.RunsInDocker()) { return; } var containerShortId = System.Environment.MachineName; var containerId = (await this.Docker.Containers.InspectContainerAsync(containerShortId, stoppingToken)).ID; var response = null as NetworkResponse; try { response = await this.Docker.Networks.InspectNetworkAsync(this.Options.Network, stoppingToken); } catch (DockerNetworkNotFoundException) { await this.Docker.Networks.CreateNetworkAsync(new() { Name = this.Options.Network }, stoppingToken); } finally { if (response == null ? true : !response !.Containers.ContainsKey(containerId)) { await this.Docker.Networks.ConnectNetworkAsync(this.Options.Network, new NetworkConnectParameters() { Container = containerId }, stoppingToken); } } }
public int?ContainerQuantity(string containerName) { if (!Containers.ContainsKey(containerName)) { return(null); } return(Containers[containerName].Quantity); }
public int?ContainerMaximum(string containerName) { if (!Containers.ContainsKey(containerName)) { return(null); } return(Containers[containerName].Maximum); }
public bool IsBlobLocked(string containerName, string blobName) { lock (_syncRoot) { return((Containers.ContainsKey(containerName) && Containers[containerName].BlobNames.Contains(blobName)) && Containers[containerName].BlobsLeases.ContainsKey(blobName)); } }
public string GetBlobEtag(string containerName, string blobName) { lock (_syncRoot) { return((Containers.ContainsKey(containerName) && Containers[containerName].BlobNames.Contains(blobName)) ? Containers[containerName].BlobsEtag[blobName] : null); } }
private CloudBlobContainer GetContainer(string containerName) { if (!Containers.ContainsKey(containerName)) { Containers.Add(containerName, GetClient().GetContainerReference(containerName)); Containers[containerName].CreateIfNotExistsAsync().Wait(); } return(Containers[containerName]); }
public DistributedApplicationDataContainer CreateContainer( string name, DistributedApplicationDataLocality locality) { return(Containers.ContainsKey(name) ? Containers[name] : _containers.TryAdd(name, new DistributedApplicationDataContainer(name, locality)) ? Containers[name] : null); }
bool PutBlob(string containerName, string blobName, object item, Type type, bool overwrite, string expectedEtag, out string etag, IDataSerializer serializer = null) { var dataSerializer = serializer ?? DefaultSerializer; lock (_syncRoot) { etag = null; if (Containers.ContainsKey(containerName)) { if (Containers[containerName].BlobNames.Contains(blobName)) { if (!overwrite || expectedEtag != null && expectedEtag != Containers[containerName].BlobsEtag[blobName]) { return(false); } using (var stream = new MemoryStream()) { dataSerializer.Serialize(item, stream, type); Containers[containerName].SetBlob(blobName, stream); } etag = Containers[containerName].BlobsEtag[blobName]; return(true); } using (var stream = new MemoryStream()) { dataSerializer.Serialize(item, stream, type); Containers[containerName].AddBlob(blobName, stream); } etag = Containers[containerName].BlobsEtag[blobName]; return(true); } if (!BlobStorageExtensions.IsContainerNameValid(containerName)) { throw new NotSupportedException("the containerName is not compliant with azure constraints on container names"); } Containers.Add(containerName, new MemoryContainer()); using (var stream = new MemoryStream()) { dataSerializer.Serialize(item, stream, type); Containers[containerName].AddBlob(blobName, stream); } etag = Containers[containerName].BlobsEtag[blobName]; return(true); } }
public void JoinContainer(MockObject container, DateTime joinTime) { if (container == null || Containers.ContainsKey(container.Uuid)) { return; } Containers[container.Uuid] = container; container.JoinContainee(this, joinTime); LastJoinedTime = joinTime; UpdateObjectLastWrite(joinTime); }
public void UnjoinContainer(MockObject container, DateTime unjoinTime) { if (container == null || !Containers.ContainsKey(container.Uuid)) { return; } Containers.Remove(container.Uuid); container.UnjoinContainee(this, unjoinTime); LastUnjoinedTime = unjoinTime; UpdateObjectLastWrite(unjoinTime); }
private void RemoveContainer(string name) { if (Containers.ContainsKey(name)) { var target = Containers[name]; if (Containers.Remove(name)) { if (target && target.gameObject) { GameObject.Destroy(target.gameObject); } } } }
public Maybe <Stream> GetBlobStream(string containerName, string blobName, out string etag) { lock (_syncRoot) { if (!Containers.ContainsKey(containerName) || !Containers[containerName].BlobNames.Contains(blobName)) { etag = null; return(Maybe <Stream> .Empty); } etag = Containers[containerName].BlobsEtag[blobName]; return(Containers[containerName].GetBlob(blobName)); } }
private void OnEntityCreated(Entity entity) { var name = entity.GetType().Name + "s"; Transform container = null; if (!Containers.ContainsKey(name)) { container = new GameObject(name).transform; container.parent = transform; Containers.Add(name, container); } entity.transform.parent = container; }
private void radButton2_Click_1(object sender, EventArgs e) { var aContainer = (Containers.ContainsKey(textboxId.Text)) ? Containers[textboxId.Text] : new Container(); aContainer.Discard = checkDiscard.Checked; aContainer.Id = textboxId.Text; aContainer.Name = textboxName.Text; aContainer.New = textboxNew.Text; aContainer.Store = textboxStore.Text; Containers[textboxId.Text] = aContainer; PopulateContainerDropDown(); }
/// <remarks></remarks> public Maybe <object> GetBlob(string containerName, string blobName, Type type, out string etag, IDataSerializer serializer = null) { lock (_syncRoot) { if (!Containers.ContainsKey(containerName) || !Containers[containerName].BlobNames.Contains(blobName)) { etag = null; return(Maybe <object> .Empty); } etag = Containers[containerName].BlobsEtag[blobName]; return(Containers[containerName].GetBlob(blobName)); } }
bool PutBlobStream(string containerName, string blobName, Stream stream, bool overwrite, string expectedEtag, out string etag) { var memoryStream = stream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); } memoryStream.Position = 0; lock (_syncRoot) { etag = null; if (Containers.ContainsKey(containerName)) { if (Containers[containerName].BlobNames.Contains(blobName)) { if (!overwrite || expectedEtag != null && expectedEtag != Containers[containerName].BlobsEtag[blobName]) { return(false); } Containers[containerName].SetBlob(blobName, memoryStream); etag = Containers[containerName].BlobsEtag[blobName]; return(true); } Containers[containerName].AddBlob(blobName, memoryStream); etag = Containers[containerName].BlobsEtag[blobName]; return(true); } if (!BlobStorageExtensions.IsContainerNameValid(containerName)) { throw new NotSupportedException("the containerName is not compliant with azure constraints on container names"); } Containers.Add(containerName, new MemoryContainer()); Containers[containerName].AddBlob(blobName, memoryStream); etag = Containers[containerName].BlobsEtag[blobName]; return(true); } }
private void radButton2_Click_1(object sender, EventArgs e) { var aContainer = (Containers.ContainsKey(textboxId.Text)) ? Containers[textboxId.Text] : new Container(); aContainer.Discard = checkDiscard.Checked; aContainer.Id = textboxId.Text; aContainer.Name = textboxName.Text; aContainer.New = textboxNew.Text; aContainer.Store = textboxStore.Text; Containers[textboxId.Text] = aContainer; var temp = BuildContainerShape(aContainer); radDiagramToolbox1.Items.Add(temp); SerializeContainers(); PopulateContainerDropDown(); }
public Maybe <T> UpsertBlobOrSkip <T>(string containerName, string blobName, Func <Maybe <T> > insert, Func <T, Maybe <T> > update, IDataSerializer serializer = null) { lock (_syncRoot) { Maybe <T> input; if (Containers.ContainsKey(containerName)) { if (Containers[containerName].BlobNames.Contains(blobName)) { using (var stream = Containers[containerName].GetBlob(blobName)) { input = (T)(serializer ?? DefaultSerializer).Deserialize(stream, typeof(T)); } } else { input = Maybe <T> .Empty; } } else { Containers.Add(containerName, new MemoryContainer()); input = Maybe <T> .Empty; } var output = input.HasValue ? update(input.Value) : insert(); if (output.HasValue) { using (var stream = new MemoryStream()) { (serializer ?? DefaultSerializer).Serialize(output.Value, stream, typeof(T)); Containers[containerName].SetBlob(blobName, stream); } } return(output); } }
private SpriteContainer GetContainer(string containerName) { if (Containers.ContainsKey(containerName)) { return(Containers[containerName]); } else { if (containerPathMap.ContainsKey(containerName)) { GameObject prefab = Resources.Load <GameObject>(containerPathMap[containerName]); if (prefab != null) { GameObject instance = GameObject.Instantiate(prefab, Parent); SpriteContainer spriteContainer = instance.GetComponent <SpriteContainer>(); Containers.Add(spriteContainer.containerName, spriteContainer); return(spriteContainer); } } return(null); } }
public static Dictionary <string, string> Parse(this IEnumerable <string> Cookies, Dictionary <string, string> Containers = null) { if (Containers == null) { Containers = new Dictionary <string, string>(); } foreach (string cookie in Cookies) { string[] carr = cookie.Split(';'); if (carr.Length >= 1) { string[] c = carr[0].Split('='); if (c.Length == 2) { if (Containers.ContainsKey(c[0])) { Containers.Remove(c[0]); } Containers.Add(c[0], c[1]); } } } return(Containers); }
/// <summary> /// Gets the container. /// </summary> /// <param name="containerName">Name of the container.</param> /// <returns></returns> protected IDependencyContainer GetContainer(string containerName) { return(!Containers.ContainsKey(containerName) ? null : Containers[containerName]); }