protected virtual bool GenerateSecondary() { var expanded = GenFragmentExpander.ExpandSecondary(GenDataDef, GenObject, Fragment); Writer.Write(expanded); return(expanded != ""); }
public static bool Generate(GenDataDef genDataDef, GenWriter genWriter, GenObject genObject, Fragment fragment) { switch (fragment.FragmentType) { case FragmentType.Null: return(false); case FragmentType.Text: return(Write(genWriter, ((Text)fragment).TextValue)); case FragmentType.Placeholder: return(Write(genWriter, GetPlaceholderValue(fragment, genObject))); case FragmentType.Function: var fn = (Function)fragment; var paramFragments = fn.Body().FragmentList; var param = new string[paramFragments.Count]; for (var i = 0; i < paramFragments.Count; i++) { var paramFragment = paramFragments[i]; param[i] = GenFragmentExpander.Expand(genDataDef, genObject, paramFragment); } return((fn.FunctionName != "File" || !genWriter.CheckFile(param[0])) && Write(genWriter, LibraryManager.GetInstance().Execute(fn.FunctionName, param))); case FragmentType.TextBlock: var sb = new StringBuilder(); foreach (var f in ((TextBlock)fragment).Body().FragmentList) { if (f.GetType().Name == "Text") { sb.Append(((Text)f).TextValue); } else if (f.GetType().Name == "Placeholder") { sb.Append(GetPlaceholderValue(f, genObject)); } } return(Write(genWriter, sb.ToString())); default: return(Create(genDataDef, genWriter, genObject, fragment).Generate()); } }