コード例 #1
0
        private static void AddListOfPeople()
        {
            var people = new List <Person>
            {
                new Person {
                    Name = "John", Age = 10, Pets = new List <string> {
                        "dog", "cat"
                    }
                },
                new Person {
                    Name = "Jane", Age = 20, Pets = new List <string> {
                        "bird", "snake"
                    }
                },
                new Person {
                    Name = "Tom", Age = 30, Pets = new List <string> {
                        "fish", "hamster"
                    }
                }
            };


            // 'Inject' the object into PowerShell
            PowerShellExtensions.AddVariable("People", people);
        }
コード例 #2
0
        private static void AddPersonVariable()
        {
            var p = new Person
            {
                Name = "John",
                Age  = 10,
                Pets = new List <string> {
                    "dog", "cat"
                }
            };

            // 'Inject' the object into PowerShell
            PowerShellExtensions
            .AddVariable("Person", p);
        }