Microsoft.Azure.Commands.RecoveryServices.GetAzureSiteRecoveryProtectionEntity.GetByName C# (CSharp) Method

GetByName() private method

Queries by name.
private GetByName ( ) : void
return void
        private void GetByName()
        {
            ProtectionEntityListResponse protectionEntityListResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectionEntity(
                this.ProtectionContainerId);

            bool found = false;
            foreach (ProtectionEntity pe in protectionEntityListResponse.ProtectionEntities)
            {
                if (0 == string.Compare(this.Name, pe.Name, true))
                {
                    this.WriteProtectionEntity(pe);
                    found = true;
                }
            }

            if (!found)
            {
                throw new InvalidOperationException(
                    string.Format(
                    Properties.Resources.ProtectionEntityNotFound,
                    this.Name,
                    this.ProtectionContainerId));
            }
        }