public void Load_should_initialize_properties_existing()
 {
     var sc = StreamingSource.Properties;
     var properties = new Properties();
     sc.Load(StreamContext.FromText("a=b\nc=d"), properties);
     Assert.That(properties["a"], Is.EqualTo("b"));
     Assert.That(properties["c"], Is.EqualTo("d"));
 }
コード例 #2
0
 // Implicit construction.
 // N.B. Conforms with Streaming source patterns
 public static Properties FromStream(Stream stream, Encoding encoding = null)
 {
     if (stream == null)
         throw new ArgumentNullException("stream");
     Properties p = new Properties();
     p.Load(stream, encoding);
     return p;
 }
コード例 #3
0
        public static Properties FromFile(string fileName)
        {
            if (fileName == null)
                throw new ArgumentNullException("fileName"); // $NON-NLS-1
            if (string.IsNullOrWhiteSpace(fileName))
                throw Failure.AllWhitespace("fileName");

            Properties p = new Properties();
            p.Load(fileName);
            return p;
        }
コード例 #4
0
        public void try_adapt_nominal()
        {
            Properties p = new Properties();
            var ps = p.TryAdapt("StreamingSource");
            var pp = p.TryAdapt("Builder");

            Assert.That(ps, Is.InstanceOf<PropertiesStreamingSource>());
            Assert.That(pp, Is.Null);
        }
コード例 #5
0
        public static Properties FromStreamContext(StreamContext source, Encoding encoding = null)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            Properties p = new Properties();
            p.Load(source.OpenRead(), encoding ?? source.Encoding);
            return p;
        }
コード例 #6
0
        public static Properties Parse(string text)
        {
            if (string.IsNullOrEmpty(text))
                return new Properties();

            Properties result = new Properties();
            foreach (var kvp in ParseKeyValuePairs(text))
                result.InnerMap.Add(kvp.Key, kvp.Value);

            return result;
        }