Пример #1
0
        /// <summary>
        /// Create from assembly resource
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public static ITemplate FromResource(AssemblyResource resource, Encoding encoding = null)
        {
            Expect.IsNotNull(resource, nameof(resource));

            var templateText = resource.ReadAllText(encoding);

            return(FromString(templateText));
        }
Пример #2
0
        /// <summary>
        /// Load from resource
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="encoding"></param>
        public void LoadResource(AssemblyResource resource, Encoding encoding = null)
        {
            Expect.IsNotNull(resource, nameof(resource));
            encoding = encoding ?? EncodingUtil.DefaultEncoding;

            string content = resource.ReadAllText(encoding);

            LoadString(content);
        }
        public void FromString()
        {
            var tplText = _res.ReadAllText(Encoding.UTF8);

            AssertTemplate(VelocityTemplate.FromString(tplText));
        }
 public void ReadAllText()
 {
     Assert.AreEqual("abcd", _resource.ReadAllText(EncodingUtil.DefaultEncoding));
 }