示例#1
0
        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)
                       ));
        }
示例#2
0
 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();
 }
示例#3
0
        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));
        }
示例#4
0
 public static void Write(this MenuSuite menuSuite, TextWriter textWriter) => menuSuite.Write(new CSideWriter(textWriter));
示例#5
0
 public static FileInfo WriteToFolder(this MenuSuite menuSuite, string folderName) => menuSuite.Write(Path.Combine(folderName, $"men{menuSuite.ID}.txt"));