public XamlRuntimeContext(IXamlType definition, IXamlType constructedType,
                                  XamlLanguageEmitMappings <TBackendEmitter, TEmitResult> mappings,
                                  Action <XamlRuntimeContext <TBackendEmitter, TEmitResult>, TBackendEmitter> factory)
        {
            ContextType = definition.MakeGenericType(constructedType);

            IXamlField Get(string s) =>
            ContextType.Fields.FirstOrDefault(f => f.Name == s);

            IXamlMethod GetMethod(string s) =>
            ContextType.Methods.FirstOrDefault(f => f.Name == s);

            RootObjectField             = Get(XamlRuntimeContextDefintion.RootObjectFieldName);
            IntermediateRootObjectField = Get(XamlRuntimeContextDefintion.IntermediateRootObjectFieldName);
            ParentListField             = Get(XamlRuntimeContextDefintion.ParentListFieldName);
            PropertyTargetObject        = Get(XamlRuntimeContextDefintion.ProvideTargetObjectName);
            PropertyTargetProperty      = Get(XamlRuntimeContextDefintion.ProvideTargetPropertyName);
            PushParentMethod            = GetMethod(XamlRuntimeContextDefintion.PushParentMethodName);
            PopParentMethod             = GetMethod(XamlRuntimeContextDefintion.PopParentMethodName);
            Constructor = ContextType.Constructors.First();
            Factory     = il => factory(this, il);
            if (mappings.ContextFactoryCallback != null)
            {
                Factory = il =>
                {
                    factory(this, il);
                    mappings.ContextFactoryCallback(this, il);
                }
            }
            ;
        }
    }
 public XamlEmitContextWithLocals(TBackendEmitter emitter,
                                  TransformerConfiguration configuration,
                                  XamlLanguageEmitMappings <TBackendEmitter, TEmitResult> emitMappings,
                                  XamlRuntimeContext <TBackendEmitter, TEmitResult> runtimeContext,
                                  IXamlLocal contextLocal,
                                  Func <string, IXamlType, IXamlTypeBuilder <TBackendEmitter> > createSubType,
                                  IFileSource file,
                                  IEnumerable <object> emitters)
     : base(emitter, configuration, emitMappings, runtimeContext, contextLocal, createSubType, file, emitters)
 {
 }
Exemplo n.º 3
0
 public XamlEmitContext(TBackendEmitter emitter, TransformerConfiguration configuration,
                        XamlLanguageEmitMappings <TBackendEmitter, TEmitResult> emitMappings,
                        XamlRuntimeContext <TBackendEmitter, TEmitResult> runtimeContext,
                        IXamlLocal contextLocal,
                        Func <string, IXamlType, IXamlTypeBuilder <TBackendEmitter> > createSubType, IFileSource file,
                        IEnumerable <object> emitters)
 {
     File           = file;
     Emitter        = emitter;
     Emitters       = emitters.ToList();
     Configuration  = configuration;
     RuntimeContext = runtimeContext;
     ContextLocal   = contextLocal;
     CreateSubType  = createSubType;
     EmitMappings   = emitMappings;
 }