コード例 #1
0
        public XamlILNodeEmitResult Emit(IXamlAstNode node, XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen)
        {
            if (node is XamlObjectFromDirectObjectNode objNode)
            {
                IXamlType xamlDirectType = context.GetWinUITypes().XamlDirect;
                codeGen
                .EmitCall(xamlDirectType.GetMethod(new FindMethodMethodSignature("GetDefault", xamlDirectType)
                {
                    IsStatic = true
                }));

                context.Emit(objNode.Value, codeGen, context.GetWinUITypes().IXamlDirectObject);
                codeGen
                .EmitCall(xamlDirectType.GetMethod(new FindMethodMethodSignature("GetObject", context.Configuration.WellKnownTypes.Object, context.GetWinUITypes().IXamlDirectObject)))
                .Castclass(objNode.Type.GetClrType());
                return(XamlILNodeEmitResult.Type(0, objNode.Type.GetClrType()));
            }
            else if (node is XamlDirectObjectFromObjectNode directObjNode)
            {
                IXamlType xamlDirectType = context.GetWinUITypes().XamlDirect;
                codeGen
                .EmitCall(xamlDirectType.GetMethod(new FindMethodMethodSignature("GetDefault", xamlDirectType)
                {
                    IsStatic = true
                }));

                context.Emit(directObjNode.Value, codeGen, context.Configuration.WellKnownTypes.Object);
                codeGen
                .EmitCall(xamlDirectType.GetMethod(new FindMethodMethodSignature("GetXamlDirectObject", context.GetWinUITypes().IXamlDirectObject, context.Configuration.WellKnownTypes.Object)));
                return(XamlILNodeEmitResult.Type(0, context.GetWinUITypes().IXamlDirectObject));
            }
            return(null);
        }
コード例 #2
0
 public XamlILNodeEmitResult Emit(IXamlAstNode node, XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen)
 {
     if (node is XamlDirectNewObjectNode objNode)
     {
         IXamlType xamlDirectType = context.GetWinUITypes().XamlDirect;
         codeGen
         .EmitCall(xamlDirectType.GetMethod(new FindMethodMethodSignature("GetDefault", xamlDirectType)
         {
             IsStatic = true
         }))
         .Ldc_I4((int)objNode.TypeIndex.GetLiteralValue())
         .EmitCall(xamlDirectType.GetMethod(new FindMethodMethodSignature("CreateInstance", context.GetWinUITypes().IXamlDirectObject, context.GetWinUITypes().XamlTypeIndex)));
         return(XamlILNodeEmitResult.Type(0, context.GetWinUITypes().IXamlDirectObject));
     }
     return(null);
 }