public Directive.Directive GetVelocimacro(string vmName, string sourceTemplate) { VelocimacroProxy velocimacroProxy = null; lock (this) { velocimacroProxy = this.vmManager.get(vmName, sourceTemplate); if (velocimacroProxy != null && this.Autoload) { string libraryName = this.vmManager.GetLibraryName(vmName, sourceTemplate); if (libraryName != null) { try { VelocimacroFactory.Twonk twonk = (VelocimacroFactory.Twonk) this.libModMap[libraryName]; if (twonk != null) { Template template = twonk.template; long modificationTime = twonk.modificationTime; long lastModified = template.ResourceLoader.GetLastModified(template); if (lastModified > modificationTime) { this.LogVMMessageInfo("Velocimacro : autoload reload for VMs from VM library template : " + libraryName); twonk.modificationTime = lastModified; template = this.rsvc.GetTemplate(libraryName); twonk.template = template; twonk.modificationTime = template.LastModified; } } } catch (System.Exception ex) { this.LogVMMessageInfo(string.Concat(new object[] { "Velocimacro : error using VM library template ", libraryName, " : ", ex })); } velocimacroProxy = this.vmManager.get(vmName, sourceTemplate); } } } return(velocimacroProxy); }
public void InitVelocimacro() { lock (this) { this.ReplacementPermission = true; this.Blather = true; this.LogVMMessageInfo("Velocimacro : initialization starting."); this.vmManager.NamespaceUsage = false; object property = this.rsvc.GetProperty("velocimacro.library"); if (property != null) { if (property is ArrayList) { this.macroLibVec = (ArrayList)property; } else if (property is string) { this.macroLibVec = new ArrayList(); this.macroLibVec.Add(property); } for (int i = 0; i < this.macroLibVec.Count; i++) { string text = (string)this.macroLibVec[i]; if (text != null && !text.Equals("")) { this.vmManager.RegisterFromLib = true; this.LogVMMessageInfo("Velocimacro : adding VMs from VM library template : " + text); try { Template template = this.rsvc.GetTemplate(text); VelocimacroFactory.Twonk twonk = new VelocimacroFactory.Twonk(this); twonk.template = template; twonk.modificationTime = template.LastModified; this.libModMap[text] = twonk; } catch (System.Exception ex) { this.LogVMMessageInfo(string.Concat(new object[] { "Velocimacro : error using VM library template ", text, " : ", ex })); } this.LogVMMessageInfo("Velocimacro : VM library template macro registration complete."); this.vmManager.RegisterFromLib = false; } } } this.AddMacroPermission = true; if (!this.rsvc.GetBoolean("velocimacro.permissions.allow.inline", true)) { this.AddMacroPermission = false; this.LogVMMessageInfo("Velocimacro : allowInline = false : VMs can not be defined inline in templates"); } else { this.LogVMMessageInfo("Velocimacro : allowInline = true : VMs can be defined inline in templates"); } this.ReplacementPermission = false; if (this.rsvc.GetBoolean("velocimacro.permissions.allow.inline.to.replace.global", false)) { this.ReplacementPermission = true; this.LogVMMessageInfo("Velocimacro : allowInlineToOverride = true : VMs defined inline may replace previous VM definitions"); } else { this.LogVMMessageInfo("Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions"); } this.vmManager.NamespaceUsage = true; this.TemplateLocalInline = this.rsvc.GetBoolean("velocimacro.permissions.allow.inline.local.scope", false); if (this.TemplateLocalInline) { this.LogVMMessageInfo("Velocimacro : allowInlineLocal = true : VMs defined inline will be local to their defining template only."); } else { this.LogVMMessageInfo("Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed."); } this.vmManager.TemplateLocalInlineVM = this.TemplateLocalInline; this.Blather = this.rsvc.GetBoolean("velocimacro.messages.on", true); if (this.Blather) { this.LogVMMessageInfo("Velocimacro : messages on : VM system will output logging messages"); } else { this.LogVMMessageInfo("Velocimacro : messages off : VM system will be quiet"); } this.Autoload = this.rsvc.GetBoolean("velocimacro.library.autoreload", false); if (this.Autoload) { this.LogVMMessageInfo("Velocimacro : autoload on : VM system will automatically reload global library macros"); } else { this.LogVMMessageInfo("Velocimacro : autoload off : VM system will not automatically reload global library macros"); } this.rsvc.Info("Velocimacro : initialization complete."); } }