public static Invocation ToInvocation(this MenuSuite menuSuite) { IEnumerable <ParameterBase> signature = new[] { new SimpleParameter("ID", menuSuite.ID), new SimpleParameter("Name", menuSuite.Name) }; IEnumerable <ParameterBase> objectProperties = menuSuite .ObjectProperties .Where(p => p.HasValue) .SelectMany(p => p.ToParameters()); IEnumerable <ParameterBase> properties = menuSuite .Properties .Where(p => p.HasValue) .SelectMany(p => p.ToParameters()); IEnumerable <ParameterBase> subObjects = new[] { new ScriptBlockParameter( "SubObjects", menuSuite.Nodes.ToInvocations().Cast <Statement>() ) }; return(new Invocation( "New-CBreezeMenuSuite", signature .Concat(objectProperties) .Concat(properties) .Concat(subObjects) )); }
public static void Write(this MenuSuite menuSuite, CSideWriter writer) { writer.BeginSection(menuSuite.GetObjectSignature()); menuSuite.ObjectProperties.Write(writer); menuSuite.Properties.Write(writer); menuSuite.Nodes.Write(writer); writer.EndSection(); }
public static FileInfo Write(this MenuSuite menuSuite, string fileName) { using (var streamWriter = new StreamWriter(fileName, false, Encoding.GetEncoding("ibm850"))) { menuSuite.Write(streamWriter); } return(new FileInfo(fileName)); }
public static void Write(this MenuSuite menuSuite, TextWriter textWriter) => menuSuite.Write(new CSideWriter(textWriter));
public static FileInfo WriteToFolder(this MenuSuite menuSuite, string folderName) => menuSuite.Write(Path.Combine(folderName, $"men{menuSuite.ID}.txt"));