/// <summary> /// Generates the folder readme. /// </summary> /// <param name="folders">The folders.</param> /// <param name="folder">The folder.</param> /// <returns></returns> protected String generateFolderReadme(IEnumerable <folderNode> folders, folderNode folder = null) { builderForMarkdown builder = new builderForMarkdown(); if (folder != null) { builder.AppendHeading("Folder structure", 2); builder.AppendLine(); builder.AppendHeading(folder.name, 3); builder.AppendLine(" > " + folder.path); builder.AppendLine(" > " + folder.description); builder.AppendLine(); builder.AppendHorizontalLine(); } else { builder.AppendHeading("Folder structure", 2); builder.AppendLine(); builder.AppendParagraph("Application directory structure"); builder.AppendHorizontalLine(); foreach (var fold in folders) { // builder.nextTabLevel(); builder.AppendHeading(fold.name, 3); builder.AppendLine(" > " + fold.path); builder.AppendLine(" > " + fold.description); builder.AppendLine(); // builder.prevTabLevel(); } } builder.AppendLine(); builder.AppendHorizontalLine(); PropertyCollection pc = notation.buildPropertyCollection <PropertyCollection>(false, false, "cite"); builder.AppendPairs(pc, false); builder.AppendLine(); builder.AppendHorizontalLine(); builder.AppendLine("File generated: ".add(DateTime.Now.ToLongDateString(), " ").add(DateTime.Now.ToLongTimeString())); builder.AppendLine("Application: <<".add(name, " ").add(">>", " ")); return(builder.ContentToString(true)); }
/// <summary> /// Podesava vrednosti celog objekta - bez nasledjenih /// </summary> /// <param name="settings">The settings.</param> /// <param name="instanceName">Name of the instance.</param> /// <param name="parentName">Name of the parent.</param> /// <param name="loger">The loger.</param> public static void editSettings(Object settings, String instanceName = "", String parentName = "", ILogBuilder loger = null) { Type settingsType = settings.GetType(); PropertyInfo[] props = settingsType.GetProperties(); List <PropertyInfo> propList = new List <PropertyInfo>(); foreach (PropertyInfo pro in props) { if (pro.CanWrite) { if (pro.PropertyType.IsEnum) { propList.Add(pro); } else if (pro.PropertyType.IsPrimitive) { propList.Add(pro); } else if (pro.PropertyType == typeof(String)) { propList.Add(pro); } else { if (pro.DeclaringType == settingsType) { if (pro.Name != "Item") { propList.Add(pro); } else { } } } } } props = propList.ToArray(); String titleLine = ""; if (String.IsNullOrEmpty(instanceName)) { titleLine = "Variables [" + props.Length + "] in an instance of [" + settingsType.Name + "]."; } else { if (String.IsNullOrEmpty(parentName)) { titleLine = "Variables [" + props.Length + "] in [" + parentName + "->" + instanceName + "] of [" + settingsType.Name + "]."; } else { titleLine = "Variables [" + props.Length + "] in [" + instanceName + "] of [" + settingsType.Name + "]."; } } Console.WriteLine(titleLine); Console.WriteLine(); builderForMarkdown input_builderForMarkdown = (builderForMarkdown)loger; if (input_builderForMarkdown != null) { input_builderForMarkdown.rootTabLevel(); input_builderForMarkdown.AppendHeading(titleLine, 1); input_builderForMarkdown.AppendTableRow(acePaletteVariationRole.header, "Caption", "Property", "Value", "New value", "Description"); } foreach (PropertyInfo prop in props) { List <String> msgOut = new List <string>(); DescriptionAttribute descAttribute; DisplayNameAttribute displayNameAttribute; String description = ""; String displayName = ""; Object[] propAttributes = prop.GetCustomAttributes(false); foreach (Object propAtt in propAttributes) { descAttribute = propAtt as DescriptionAttribute; if (descAttribute != null) { description = descAttribute.Description; } displayNameAttribute = propAtt as DisplayNameAttribute; if (displayNameAttribute != null) { displayName = displayNameAttribute.DisplayName; } } Object propValue = null; propValue = prop.GetValue(settings, null); Object propNewValue = new Object(); Console.WriteLine(); Console.WriteLine("" + displayName + " (" + prop.Name + ") = " + propValue.ToString()); Console.WriteLine("-- " + description); String oldValue = propValue.ToString(); propNewValue = null; if (prop.PropertyType.IsEnum) { propNewValue = askForOption("Select value from list below", propValue); } else { switch (prop.PropertyType.Name.ToLower()) { case "string": propNewValue = askForStringInline("Insert new value", propValue as String); break; case "decimal": String tmpString = askForStringInline("Insert new value", propValue.ToString()); Decimal decimalResult; if (Decimal.TryParse(tmpString, out decimalResult)) { propNewValue = decimalResult; } else { Console.WriteLine("Invalid input - default value set: " + propValue.ToString()); propNewValue = propValue; } break; case "int32": String tmpStringInt = askForStringInline("Insert new value", propValue.ToString()); Int32 intResult; if (Int32.TryParse(tmpStringInt, out intResult)) { propNewValue = intResult; } else { Console.WriteLine("Invalid input - default value set: " + propValue.ToString()); propNewValue = propValue; } break; case "bool": case "boolean": propNewValue = askYesNo("Select new value", (Boolean)propValue); break; } } if (propNewValue != null) { prop.SetValue(settings, propNewValue, new object[0]); Console.WriteLine("Value set: " + propNewValue.ToString()); } else { Console.WriteLine("Skipping parameter: " + prop.Name + ":" + prop.PropertyType.Name); } input_builderForMarkdown.AppendTableRow(acePaletteVariationRole.none, displayName, prop.Name, oldValue, propNewValue.ToString(), description); Console.WriteLine(); } }
//public String makeFolderSignature() public void scopeOutOperation(IRenderExecutionContext context, IMetaContentNested oldScope) { if (context.directoryScope.FullName == context.directoryRoot.FullName) { } else { builderForMarkdown dirReadMe = new builderForMarkdown(); dirReadMe.AppendHorizontalLine(); dirReadMe.AppendHeading("Directory for [" + oldScope.name + "]", 3); dirReadMe.AppendLine("Report: {{{test_caption}}}, {{{sys_time}}}, {{{sys_date}}}"); dirReadMe.AppendLine("> Open 'index.html' for report content"); dirReadMe.AppendHorizontalLine(); dirReadMe.AppendHeading("Report element description", 2); dirReadMe.AppendPair("Element class type", oldScope.GetType().Name, true, " \t\t = \t"); dirReadMe.AppendPair("Element logical level", oldScope.elementLevel.ToString(), true, " \t\t = \t"); dirReadMe.AppendPair("Element logical path", oldScope.path, true, " \t\t = \t"); //.elementLevel.ToString()); dirReadMe.AppendPair("Element isRoot", oldScope.isThisRoot, true, " \t\t = \t"); //.elementLevel.ToString()); dirReadMe.AppendHorizontalLine(); dirReadMe.AppendHeading("Element data dump", 2); var pc = oldScope.AppendDataFields(null); dirReadMe.AppendPairs(pc, false, " \t\t = \t"); dirReadMe.AppendHorizontalLine(); dirReadMe.AppendHeading("Contextual data contextual dump", 2); var p2c = context.data; dirReadMe.AppendPairs(p2c, false, " \t\t = \t"); dirReadMe.AppendHorizontalLine(); dirReadMe.AppendLine("File created: {{{sys_time}}}, {{{sys_date}}}, {{{meta_year}}}"); dirReadMe.AppendLine("By: {{{meta_softwareName}}}"); dirReadMe.AppendLine("{{{meta_copyright}}}, {{{meta_author}}}, {{{meta_organization}}}"); dirReadMe.AppendHorizontalLine(); dirReadMe.AppendLine("File system path: " + context.directoryScope.FullName); dirReadMe.AppendLine("Report root path: " + context.directoryRoot.FullName); string content = dirReadMe.ContentToString(true, reportOutputFormatName.markdown); content = content.applyToContent(pc); content = content.applyToContent(p2c); string path = context.directoryScope.FullName.add("readme.md", "\\"); content.saveStringToFile(path, getWritableFileMode.overwrite, Encoding.UTF8); // leaving the directory context.directoryScope = context.directoryScope.Parent; } setRelPath(context); }