Inheritance: IDynamicMetaObjectProvider
 private static DynamicViewModel ConvertHashtable(Hashtable hashtable)
 {
     var result = new DynamicViewModel();
     foreach (DictionaryEntry entry in hashtable) {
         result[entry.Key.ToString()] = FromObject(entry.Value);
     }
     return result;
 }
        public void ShouldBeAbleToReadDynamicModelProperties()
        {
            // Integration test to check that the T4 template host can read properties from the DynamicViewModel

            dynamic model = new DynamicViewModel();
            model.Name = "foo";
            model.Baz = 1;
            model.A = typeof(string);
            model.Values = new List<string> { "a", "b", "c" };

            var result = ProcessTemplate("simpleTemplate", model);
            Assert.AreEqual("The name is foo. There are 3 values.", result);
        }
        static string ProcessTemplate(string exampleTemplateName, DynamicViewModel model)
        {
            var templateQualifiedFileName = ExampleTemplates.GetPath(exampleTemplateName);

            if (!File.Exists(templateQualifiedFileName))
                throw new FileNotFoundException("File not found: " + exampleTemplateName);

            // Read the text template.
            string input = File.ReadAllText(templateQualifiedFileName);

            // Transform the text template.
            using (var host = new DynamicTextTemplatingEngineHost {
                TemplateFile = templateQualifiedFileName,
                Model = model
            }) {
                string output = new Engine().ProcessTemplate(input, host);
                if (host.Errors.HasErrors)
                    throw new TemplateProcessingErrorException(host.Errors);
                return output;
            }
        }