コード例 #1
0
 /// <summary>
 /// Constructs a DataUri from the provided string.
 /// </summary>
 /// <param name="uriSource"></param>
 public DataUri(string uriSource)
 {
     if (string.IsNullOrWhiteSpace(uriSource))
     {
         throw new ArgumentNullException(nameof(uriSource));
     }
     if (!uriSource.Trim().ToLower().StartsWith(SCHEME))
     {
         throw new ArgumentOutOfRangeException(ParsingHelper.UriWrongSchemeError(SCHEME));
     }
     if (!Uri.IsWellFormedUriString(uriSource, UriKind.RelativeOrAbsolute))
     {
         throw new UriFormatException();
     }
     Uri = new Uri(uriSource);
     if (Uri.LocalPath.Contains(DataTypes.Binary.SEPARATOR))
     {
         BinaryData = new DataTypes.Binary(Uri.LocalPath, out _params);
         BinaryData.PropertyChanged += Value_PropertyChanged;
     }
     else
     {
         TextData = new DataTypes.Text(Uri.LocalPath, out _params);
         TextData.PropertyChanged += Value_PropertyChanged;
     }
 }
コード例 #2
0
 /// <summary>
 /// Constructs a DataUri from  the specified <see cref="DataTypes.Binary"/>
 /// </summary>
 /// <param name="binaryData">The Binary value to use for the resulting DataUri</param>
 public DataUri(DataTypes.Binary binaryData)
 {
     BinaryData = binaryData ?? throw new ArgumentNullException(nameof(binaryData));
     Uri        = new Uri(ToString());
     BinaryData.PropertyChanged += Value_PropertyChanged;
     TextData = null;
     _params  = null;
 }
コード例 #3
0
        /// <summary>
        /// Constructs a DataUri from the provided URI
        /// </summary>
        /// <param name="source"></param>
        public DataUri(Uri source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (source.Scheme != SCHEME)
            {
                throw new ArgumentOutOfRangeException(ParsingHelper.UriWrongSchemeError(SCHEME));
            }

            Uri = source;
            if (Uri.LocalPath.Contains(DataTypes.Binary.SEPARATOR))
            {
                BinaryData = new DataTypes.Binary(Uri.LocalPath, out _params);
                BinaryData.PropertyChanged += Value_PropertyChanged;
            }
            else
            {
                TextData = new DataTypes.Text(Uri.LocalPath, out _params);
                TextData.PropertyChanged += Value_PropertyChanged;
            }
        }