示例#1
0
        private void StartState()
        {
            string message;

            switch (bodyPart)
            {
            case BlobBody.Head:
                message = "You have a killer headache today. Wonder whats caused that.";
                break;

            case BlobBody.Ass:
                message = "Feels like you've sat on something strange recently.";
                break;

            case BlobBody.Stomach:
                message = "You feel nauseous, its probably nothing to worry about.";
                break;

            default:
                message = "You feel nauseous, its probably nothing to worry about.";
                break;
            }

            Chat.AddExamineMsgFromServer(gameObject, message);

            stateTimer = 0f;
            state      = BlobStates.Middle;
        }
示例#2
0
        private void MiddleState()
        {
            //Check to see whether middle state should start
            if (stateTimer <= TimeToMiddle)
            {
                return;
            }

            //If middle state has been running 240 seconds, change to end state!
            if (stateTimer >= TimeToEnd)
            {
                state         = BlobStates.End;
                internalTimer = 0f;
                return;
            }

            //Every 20 seconds have chance for message
            if (internalTimer <= MessageFrequency)
            {
                return;
            }

            // 75% theres no message this time this second
            if (Random.Range(0, 100) <= 75)
            {
                return;
            }

            internalTimer = 0f;

            string message;

            if (Random.Range(0, 100) <= 25)
            {
                switch (bodyPart)
                {
                case BlobBody.Head:
                    message = middlePhrasesHead.GetRandom();
                    break;

                case BlobBody.Ass:
                    message = middlePhrasesAss.GetRandom();
                    break;

                case BlobBody.Stomach:
                    message = middlePhrasesStomach.GetRandom();
                    break;

                default:
                    message = middlePhrasesStomach.GetRandom();
                    break;
                }
            }
            else
            {
                message = GenericMiddlePhrases.GetRandom();
            }

            Chat.AddExamineMsgFromServer(gameObject, $"<color=#FF151F>{message}</color>");
        }
示例#3
0
        /// <summary>List files</summary>
        public async Task <List <BlobItem> > ListFilesAsync(string prefix     = null, BlobTraits traits = BlobTraits.None,
                                                            BlobStates states = BlobStates.None, CancellationToken continuationToken = default)
        {
            var result = new List <BlobItem>();

            // For >= C# 8.0 use:
            //await foreach (BlobItem blobItem in _blobContainerClient.GetBlobsAsync(traits, states, prefix, continuationToken))
            //{
            //    result.Add(blobItem);
            //}

            // For < C# 8.0 use:
            AsyncPageable <BlobItem>    blobPages  = _blobContainerClient.GetBlobsAsync(traits, states, prefix, continuationToken);
            IAsyncEnumerator <BlobItem> enumerator = blobPages.GetAsyncEnumerator();

            try
            {
                while (await enumerator.MoveNextAsync())
                {
                    result.Add(enumerator.Current);
                }
            }
            finally
            {
                await enumerator.DisposeAsync();
            }


            return(result);
        }
 public override AsyncPageable <BlobItem> GetBlobsAsync(
     BlobTraits traits = BlobTraits.None,
     BlobStates states = BlobStates.None,
     string?prefix     = null,
     CancellationToken cancellationToken = default)
 {
     return(new BlobsList(StoredFiles.Keys));
 }
示例#5
0
 public GetBlobsAsyncCollection(
     BlobContainerClient client,
     BlobTraits traits,
     BlobStates states,
     string prefix)
 {
     _client = client;
     _traits = traits;
     _states = states;
     _prefix = prefix;
 }
示例#6
0
 public GetBlobsByHierarchyAsyncCollection(
     BlobContainerClient client,
     string delimiter,
     BlobTraits traits,
     BlobStates states,
     string prefix)
 {
     _client    = client;
     _delimiter = delimiter;
     _traits    = traits;
     _states    = states;
     _prefix    = prefix;
 }
示例#7
0
        /// <inheritdoc/>
        public async Task <List <BlobItem> > ListBlobs(string org, string app, string instanceGuid, ElementState state = ElementState.Active)
        {
            List <BlobItem> blobs     = new List <BlobItem>();
            BlobStates      blobState = state.Equals(ElementState.Active) ? BlobStates.None : BlobStates.Deleted;

            BlobContainerClient container = await _clientProvider.GetBlobClient(org, Program.Environment);

            await foreach (BlobItem item in container.GetBlobsAsync(BlobTraits.None, blobState, $"{org}/{app}/{instanceGuid}"))
            {
                blobs.Add(item);
            }

            if (blobs.Count > 0 && state.Equals(ElementState.Deleted))
            {
                blobs = blobs.Where(b => b.Deleted == true).ToList();
            }

            return(blobs);
        }
示例#8
0
        private void PeriodicUpdate()
        {
            if (!CustomNetworkManager.IsServer)
            {
                return;
            }

            stateTimer += updateTime;

            internalTimer += updateTime;

            if (bypass)
            {
                FormBlob();
                return;
            }

            if (bypass2)
            {
                state = BlobStates.End;
            }

            CheckState();
        }
示例#9
0
        /// <summary>
        /// list blobs by blob prefix and container name
        /// </summary>
        /// <param name="containerName">container name</param>
        /// <param name="prefix">blob preifx</param>
        /// <returns>An enumerable collection of IListBlobItem</returns>
        internal async Task ListBlobsByPrefix(long taskId, IStorageBlobManagement localChannel, string containerName, string prefix, Func <string, bool> blobFilter = null, bool includeDeleted = false, bool includeVersion = false)
        {
            CloudBlobContainer container = await GetCloudBlobContainerByName(localChannel, containerName).ConfigureAwait(false);

            BlobContainerClient track2container = AzureStorageContainer.GetTrack2BlobContainerClient(container, localChannel.StorageContext, ClientOptions);

            int listCount     = InternalMaxCount;
            int MaxListCount  = 5000;
            int requestCount  = MaxListCount;
            int realListCount = 0;
            BlobContinuationToken continuationToken = ContinuationToken;
            string track2ContinuationToken          = this.ContinuationToken is null ? null : this.ContinuationToken.NextMarker;

            if (UseTrack2Sdk())                                                      // For new feature only available on Track2 SDK, need list with Track2 SDK.
            {
                BlobTraits blobTraits = BlobTraits.Metadata | BlobTraits.CopyStatus; // | BlobTraits.Tags;
                BlobStates blobStates = BlobStates.Snapshots;
                if (includeDeleted)
                {
                    blobStates = blobStates | BlobStates.Deleted;
                }
                if (includeVersion)
                {
                    blobStates = blobStates | BlobStates.Version;
                }

                do
                {
                    requestCount  = Math.Min(listCount, MaxListCount);
                    realListCount = 0;
                    IEnumerator <Page <BlobItem> > enumerator = track2container.GetBlobs(blobTraits, blobStates, prefix, CmdletCancellationToken)
                                                                .AsPages(track2ContinuationToken, requestCount)
                                                                .GetEnumerator();

                    Page <BlobItem> page;
                    enumerator.MoveNext();
                    page = enumerator.Current;
                    foreach (BlobItem item in page.Values)
                    {
                        if (blobFilter == null || blobFilter(item.Name))
                        {
                            OutputStream.WriteObject(taskId, GetAzureStorageBlob(item, track2container, localChannel.StorageContext, page.ContinuationToken, ClientOptions));
                        }
                        realListCount++;
                    }
                    track2ContinuationToken = page.ContinuationToken;

                    if (InternalMaxCount != int.MaxValue)
                    {
                        listCount -= realListCount;
                    }
                } while (listCount > 0 && !string.IsNullOrEmpty(track2ContinuationToken));
            }
            else
            {
                BlobRequestOptions requestOptions = RequestOptions;
                bool useFlatBlobListing           = true;
                BlobListingDetails details        = BlobListingDetails.Snapshots | BlobListingDetails.Metadata | BlobListingDetails.Copy;
                if (includeDeleted)
                {
                    details = details | BlobListingDetails.Deleted;
                }

                do
                {
                    requestCount  = Math.Min(listCount, MaxListCount);
                    realListCount = 0;
                    BlobResultSegment blobResult = await localChannel.ListBlobsSegmentedAsync(container, prefix, useFlatBlobListing,
                                                                                              details, requestCount, continuationToken, requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false);

                    foreach (IListBlobItem blobItem in blobResult.Results)
                    {
                        CloudBlob blob = blobItem as CloudBlob;

                        if (blob == null)
                        {
                            continue;
                        }

                        if (blobFilter == null || blobFilter(blob.Name))
                        {
                            WriteCloudBlobObject(taskId, localChannel, blob, blobResult.ContinuationToken);
                            realListCount++;
                        }
                    }

                    if (InternalMaxCount != int.MaxValue)
                    {
                        listCount -= realListCount;
                    }

                    continuationToken = blobResult.ContinuationToken;
                }while (listCount > 0 && continuationToken != null);
            }
        }
示例#10
0
        /// <summary>
        /// Convert the details into ListBlobsIncludeItem values.
        /// </summary>
        /// <returns>ListBlobsIncludeItem values</returns>
        internal static IEnumerable <ListBlobsIncludeItem> AsIncludeItems(BlobTraits traits, BlobStates states)
        {
            // NOTE: Multiple strings MUST be appended in alphabetic order or signing the string for authentication fails!
            // TODO: Remove this requirement by pushing it closer to header generation.
            var items = new List <ListBlobsIncludeItem>();

            if ((traits & BlobTraits.CopyStatus) == BlobTraits.CopyStatus)
            {
                items.Add(ListBlobsIncludeItem.Copy);
            }
            if ((states & BlobStates.Deleted) == BlobStates.Deleted)
            {
                items.Add(ListBlobsIncludeItem.Deleted);
            }
            if ((traits & BlobTraits.Metadata) == BlobTraits.Metadata)
            {
                items.Add(ListBlobsIncludeItem.Metadata);
            }
            if ((states & BlobStates.Snapshots) == BlobStates.Snapshots)
            {
                items.Add(ListBlobsIncludeItem.Snapshots);
            }
            if ((traits & BlobTraits.Tags) == BlobTraits.Tags)
            {
                items.Add(ListBlobsIncludeItem.Tags);
            }
            if ((states & BlobStates.Uncommitted) == BlobStates.Uncommitted)
            {
                items.Add(ListBlobsIncludeItem.Uncommittedblobs);
            }
            if ((states & BlobStates.Version) == BlobStates.Version)
            {
                items.Add(ListBlobsIncludeItem.Versions);
            }
            return(items.Count > 0 ? items : null);
        }
 public override AsyncPageable <BlobItem> GetBlobsAsync(BlobTraits traits = BlobTraits.None, BlobStates states = BlobStates.None, string prefix = null, CancellationToken cancellationToken = default)
 {
     if (GetBlobsAsyncException != null)
     {
         throw GetBlobsAsyncException;
     }
     return(new MockAsyncPageable <BlobItem>(Blobs));
 }
 public DeleteAllBlobsInContainer(string storageConnectionString, string prefix = null, BlobStates details = BlobStates.None)
 {
     client          = new BlobServiceClient(storageConnectionString);
     this.prefix     = prefix;
     this.blobStates = details;
 }
示例#13
0
            public override AsyncPageable <BlobItem> GetBlobsAsync(BlobTraits traits = BlobTraits.None, BlobStates states = BlobStates.None, string prefix = null, CancellationToken cancellationToken = default)
            {
                if (GetBlobsAsyncException != null)
                {
                    throw GetBlobsAsyncException;
                }

                return(new MockAsyncPageable <BlobItem>(Blobs.Where(b => prefix == null || b.Name.StartsWith(prefix, StringComparison.Ordinal))));
            }
示例#14
0
 static void AssertOptions(string expected, BlobTraits traits, BlobStates states) => Assert.AreEqual(
     expected,
     string.Join(",", System.Linq.Enumerable.Select(BlobExtensions.AsIncludeItems(traits, states), item => Azure.Storage.Blobs.BlobRestClient.Serialization.ToString(item))));
示例#15
0
        private IAsyncEnumerable <BlobItem> ListBlobs(BlobContainerClient container, string prefix, BlobTraits traits, BlobStates states)
        {
            // Clean up the prefix if required
            prefix = prefix == null ? null : SafePath.MakeSafeFilePath(prefix);

            return(container.GetBlobsAsync(traits, states, prefix));
        }