public override void Render(System.IO.TextWriter writer) { if (Code == null) { return; } writer.Write(MyDataContext.ResolveVariables(Code)); }
public override void Render(System.IO.TextWriter writer) { if (string.IsNullOrEmpty(Src)) { return; } string localSrc = Src; if (AppendCultureInfo && MyDataContext != null && !string.IsNullOrEmpty(MyDataContext.Culture)) { string[] cparts = MyDataContext.Culture.Split(new char[] { '-' }); char splitter; if (localSrc.Contains("?")) { splitter = '&'; } else { splitter = '?'; } if (cparts.Length >= 2) { localSrc += String.Concat(splitter, "lang=", cparts[0], "&country=", cparts[1]); } else { localSrc += String.Concat(splitter, "lang=", cparts[0]); } } localSrc = MyDataContext.ResolveVariables(localSrc); //look for server-side override if (ServerResolvedValue != null || !string.IsNullOrEmpty(ResultKey)) { if (string.IsNullOrEmpty(ServerResolvedValue)) { ServerResolvedValue = DataContext.VARIABLE_START + DataContext.RESERVED_KEY_FETCHED_MARKUP + "." + ResultKey + DataContext.VARIABLE_END; } if (ServerResolvedValue.Contains(DataContext.VARIABLE_START) && ServerResolvedValue.Contains(DataContext.VARIABLE_END)) { writer.Write(MyDataContext.ResolveVariables(ServerResolvedValue)); } else { writer.Write(ServerResolvedValue); } return; } if (string.IsNullOrEmpty(Method)) { Method = "GET"; } string targetId = TargetElement; if (string.IsNullOrEmpty(targetId)) { if (string.IsNullOrEmpty(ID)) { ID = GetUniqueID(); } targetId = ID; } if (GenerateDomElement) { writer.Write("<div id=\""); writer.Write(ID); writer.WriteLine("\"></div>"); } string regLine = "MyOpenSpace.ClientRequestProcessor.addRequest('##URL##', '##RESPONSE_TARGET##', '##ID##', crrParams);"; if (ClientResponseType.Render == ResponseType) { regLine = regLine.Replace("##URL##", localSrc) .Replace("##RESPONSE_TARGET##", ResponseType.ToString().ToLower()) .Replace("##ID##", targetId); } else { regLine = regLine.Replace("##URL##", localSrc) .Replace("##RESPONSE_TARGET##", ResponseType.ToString().ToLower()) .Replace("##ID##", DataKey); } writer.Write(GadgetMaster.JS_START_BLOCK_TAGS); writer.Write(BuildJsRequestParamsObject("crrParams")); writer.WriteLine(regLine); writer.WriteLine("delete crrParams;"); writer.Write(GadgetMaster.JS_END_BLOCK_TAGS); //"MyOpenSpace.TemplateProcessor.ClientRenderRequest.addRequest" }
public override void Render(System.IO.TextWriter writer) { IEnumerable simpleList = MyDataContext.GetEnumerableVariableObject(RepeatedDataKey); if (null == simpleList) { return; } //TODO - hunt down why repeat nested in templates not parsed. if (Controls.Count == 0 && MyOffset.ChildOffsets.Count > 0) { BuildControlTreeFromOffsets(); } bool hasPrequel = (!string.IsNullOrEmpty(LoopPrequel)); bool hasSequel = (!string.IsNullOrEmpty(LoopSequel)); //System.Collections.Hashtable LoopContext context = new LoopContext(0, 0); //resolve the count if (simpleList is IList) { context.Count = ((IList)simpleList).Count; } else { //enumerate to count items int count = 0; foreach (object item in simpleList) { count++; } context.Count = count; } //saftey check on LoopContextVariableKey if (string.IsNullOrEmpty(LoopContextVariableKey)) { LoopContextVariableKey = "Context"; } foreach (object item in simpleList) { object realItem = item; if (item is DictionaryEntry) { realItem = ((DictionaryEntry)item).Value; } MyDataContext.RegisterLocalValue(this.LoopItemKey, realItem); if (MyDataContext.HasVariable(this.LoopContextVariableKey)) { MyDataContext.RemoveLocalValue(this.LoopContextVariableKey); } MyDataContext.RegisterLocalValue(this.LoopContextVariableKey, context); //Evaluate any conditionals if (EvaluateLoopConditionalExpressionPasses()) { if (hasPrequel) { writer.Write(MyDataContext.ResolveVariables(LoopPrequel)); } RenderTemplateInstance(writer); if (hasSequel) { writer.Write(MyDataContext.ResolveVariables(LoopSequel)); } } context.Index++; MyDataContext.RemoveLocalValue(this.LoopItemKey); } //remove the final context variable if (MyDataContext.HasVariable(this.LoopContextVariableKey)) { MyDataContext.RemoveLocalValue(this.LoopContextVariableKey); } }