This class will be instantiated on demand by the Script component.
Inheritance: GH_ScriptInstance
Esempio n. 1
0
    public Chapter1()
    {
        class1 obj1 = new class1();
        class2 obj2 = new class2();
        Type type = typeof(StreamReader); // typeof - извлечь объект типа Type из StreamReader

        if (obj1 is class1)
            Console.WriteLine("obj1 type class1"); //тру - типы одинаковые

        if (obj2 is class1)
            Console.WriteLine("obj2 type class2 : class1"); //тру - наследование

        if (obj1 is object)
            Console.WriteLine("obj1 type class1 : object"); //тру - object базовый класс

        obj2 = obj1 as class2; //сделать приведение типов если это возможно, иначе null
        if (obj2 == null)
            Console.WriteLine("приведение типов невозможно");

        Console.WriteLine(type.FullName); //название типа
        if (type.IsClass)
            Console.WriteLine("относится к классу"); //является ли классом
        if (!type.IsAbstract)
            Console.WriteLine("является конкретным классом"); //абстрактный ?
    }
 public void i_make_a_class2()
 {
     class2 bob = new class2(method1);
 }
    public Class1()     // constructor of Class 1
    {
        class2 cs = new class2();

        cs.Add(4, 5);
    }
Esempio n. 4
0
 public UtilityClasses(class1 c1, class2 c2)
 {
     this.c1 = c1;
     this.c2 = c2;
 }
Esempio n. 5
0
 protected override void Because_of()
 {
     var bo = new class2 { prop1 = "PROP1", prop2 = "PROP2" };
     _result = Mapper.Map(bo, new class2DTO());
 }
 public controller(class1 cl1, class2 cl2)
 {
     Console.WriteLine("Instanciation par controller(class1 cl1, class2 cl2)");
     _cl1 = cl1;
     _cl2 = cl2;
 }
 public controller(class2 cl2)
     : this(new class1(), cl2)
 {
     Console.WriteLine("Instanciation par controller(class2 cl2)");
 }
 static void Main(string[] args)
 {
     class1 c1 = new class1(1, 2);
     // create the Func as a lambda and pass to the constructor.
     class2 <int> c2 = new class2 <int>(c => c.getp1)
 }