MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / DynamicTemplate

Class DynamicTemplate

src/NodeRTLib/Reflector.cs:737–812  ·  view source on GitHub ↗

The class derived from DynamicObject.

Source from the content-addressed store, hash-verified

735
736 // The class derived from DynamicObject.
737 public class DynamicTemplate : DynamicObject
738 {
739 // The inner dictionary.
740 Dictionary<string, object> dictionary
741 = new Dictionary<string, object>();
742
743 private string templateLocation;
744
745 public string TemplateLocation
746 {
747 get
748 {
749 return templateLocation;
750 }
751 }
752
753 private string templateExtension;
754
755 public string TemplateExtension
756 {
757 get
758 {
759 return templateExtension;
760 }
761 }
762
763 public DynamicTemplate(string templateLocation, string templateExtension)
764 {
765 this.templateLocation = templateLocation;
766 this.templateExtension = templateExtension;
767 }
768
769 // This property returns the number of elements
770 // in the inner dictionary.
771 public int Count
772 {
773 get
774 {
775 return dictionary.Count;
776 }
777 }
778
779 // If you try to get a value of a property
780 // not defined in the class, this method is called.
781 public override bool TryGetMember(
782 GetMemberBinder binder, out object result)
783 {
784 string name = binder.Name;
785
786 // If the property name is found in a dictionary,
787 // set the result parameter to the property value and return true.
788 // Otherwise, try to load the template.
789 if (!dictionary.TryGetValue(name, out result))
790 {
791 Func<dynamic, String> template = TX.LazyTemplate(name, this.templateLocation, this.templateExtension);
792 if (template != null)
793 {
794 dictionary[name] = template;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected