Exemplo n.º 1
0
            protected override void beforeWriteTo()
            {
                if (!mbeforeWriteToGot)
                {
                    //mAddChild = instance.Type.GetMethod("AddChild", 1);
                    ILRuntime.CLR.TypeSystem.IType type = instance.Type;
                    while (mbeforeWriteTo == null && type is ILRuntime.CLR.TypeSystem.ILType)
                    {
                        mbeforeWriteTo = type.GetMethod("beforeWriteTo", 0);
                        type           = type.BaseType;
                    }
                    mbeforeWriteToGot = true;
                }

                //对于虚函数而言,必须设定一个标识位来确定是否当前已经在调用中,否则如果脚本类中调用base.TestVirtual()就会造成无限循环,最终导致爆栈
                if (mbeforeWriteTo != null && !isbeforeWriteToInvoking)
                {
                    isbeforeWriteToInvoking = true;

                    var result = appdomain.Invoke(mbeforeWriteTo, instance, null);
                    isbeforeWriteToInvoking = false;
                }
                else
                {
                    base.beforeWriteTo();
                }
            }
Exemplo n.º 2
0
            protected override void afterMergeFrom()
            {
                if (!mafterMergeFromGot)
                {
                    //mAddChild = instance.Type.GetMethod("AddChild", 1);
                    ILRuntime.CLR.TypeSystem.IType type = instance.Type;
                    while (mafterMergeFrom == null && type is ILRuntime.CLR.TypeSystem.ILType)
                    {
                        mafterMergeFrom = type.GetMethod("afterMergeFrom", 0);
                        type            = type.BaseType;
                    }
                    mafterMergeFromGot = true;
                }

                //对于虚函数而言,必须设定一个标识位来确定是否当前已经在调用中,否则如果脚本类中调用base.TestVirtual()就会造成无限循环,最终导致爆栈
                if (mafterMergeFrom != null && !isafterMergeFromInvoking)
                {
                    isafterMergeFromInvoking = true;

                    var result = appdomain.Invoke(mafterMergeFrom, instance, null);
                    isafterMergeFromInvoking = false;
                }
                else
                {
                    base.afterMergeFrom();
                }
            }