Dev2.Studio.ViewModels.Administration.DialogueViewModel.SetImage C# (CSharp) Method

SetImage() private method

private SetImage ( string imageSource ) : void
imageSource string
return void
        private void SetImage(string imageSource)
        {
            if(string.IsNullOrEmpty(imageSource))
            {
                _imageSource = null;
            }
            else
            {
                Uri imageUri;
                bool validUri = Uri.TryCreate(imageSource, UriKind.RelativeOrAbsolute, out imageUri);

                if(validUri)
                {

                    // Once initialized, the image must be released so that it is usable by other resources
                    var btMap = new BitmapImage();
                    btMap.BeginInit();
                    btMap.UriSource = imageUri;
                    btMap.CacheOption = BitmapCacheOption.OnLoad;
                    btMap.EndInit();
                    _imageSource = btMap;
                }
                else
                {
                    throw new UriFormatException(String.Format("Uri :{0} was not in the correct format", imageSource));
                }
            }

        }