/* The managed wrapper gives C the ownership of the filled out parameter */ public static void out_own_string_from_virtual() { test.Testing obj = new StringReturner(); /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ Test.AssertEquals("out_own_inherited", obj.CallOutOwnString()); System.GC.Collect(); }
/* The managed wrapper must surrender the ownership to the C after the virtual call. */ public static void return_own_string_from_virtual() { var obj = new StringReturner(); /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ Test.AssertEquals("own_inherited", obj.CallReturnOwnString()); System.GC.Collect(); obj.Dispose(); }
/* The managed wrapper should take ownership of the in parameter */ public static void in_own_string_from_virtual() { StringReturner obj = new StringReturner(); /* for (int i = 0; i < 10000; i++) { */ String sent = "in_own_inherited"; obj.CallInOwnString(sent); Test.AssertEquals(sent, obj.received_in_own); /* } */ System.GC.Collect(); }
static void Main(string[] args) { Print print = Function.nameWriter; print("AAAA"); print = new Print(Function.surnameWriter); print("BBBB"); Console.WriteLine(); StringReturner stringReturner = Function.nameReturner; Console.WriteLine(stringReturner()); stringReturner = new StringReturner(Function.surnameReturner); Console.WriteLine(stringReturner()); Console.WriteLine(); Print multiPrint = Function.nameWriter; multiPrint += Function.surnameWriter; multiPrint("No data!"); Console.WriteLine(); AnonymousWriter anonymWriter = delegate(int tmp) { Console.WriteLine("In anonymous delegate"); Console.WriteLine("Value of anonymWriter: " + tmp); }; anonymWriter(7); Console.WriteLine(); AnonymousReturner anonymReturner = delegate(long tmp) { Console.WriteLine("In anonymous delegate"); return(tmp / 10); }; Console.WriteLine("Value of anonymReturner: " + anonymReturner(10000001)); Console.WriteLine(); Func <int, int, string> sum = delegate(int tmp1, int tmp2) { return("Result: " + (tmp1 + tmp2)); }; Console.WriteLine(sum(66, 4)); Console.WriteLine(); Action <int, int> action = Function.sum; Function.absoluteSum(1, 2, action); Console.ReadKey(); }
public abstract void Log(LogLevel logLevel, StringReturner stringReturner, int msgCode = 0);