Esempio n. 1
0
        public IILLocal?GenMain(IGenerationContext context)
        {
            var il            = context.IL;
            var needsForProps = context.NeedsForProperties(_implementationType, _arePropertiesAutowired).ToList();

            if (needsForProps.Count > 0)
            {
                var result = il.DeclareLocal(_implementationType);
                context.PushToILStack(context.NeedsForConstructor(_constructorInfo));
                il.Newobj(_constructorInfo).Stloc(result);
                foreach (var need in needsForProps)
                {
                    if (!context.IsResolvableNeed(need))
                    {
                        continue;
                    }
                    var resolvedNeed = context.ResolveNeed(need);
                    if (resolvedNeed.IsCorruptingILStack(context))
                    {
                        var local = resolvedNeed.GenMain(context);
                        if (local == null)
                        {
                            local = il.DeclareLocal(need.ClrType);
                            il.Stloc(local);
                        }

                        il.Ldloc(result);
                        il.Ldloc(local);
                    }
                    else
                    {
                        il.Ldloc(result);
                        var local = resolvedNeed.GenMain(context);
                        if (local != null)
                        {
                            il.Ldloc(local);
                        }
                    }

                    il.Call(need.PropertyInfo !.GetSetMethod(true) !);
                }

                return(result);
            }

            context.PushToILStack(context.NeedsForConstructor(_constructorInfo));
            context.IL.Newobj(_constructorInfo);
            return(null);
        }
Esempio n. 2
0
 public IEnumerable <INeed> GetNeeds(IGenerationContext context)
 {
     return(context.NeedsForConstructor(_constructorInfo).Concat(context.NeedsForProperties(_implementationType, _arePropertiesAutowired)));
 }
Esempio n. 3
0
 public IILLocal GenMain(IGenerationContext context)
 {
     context.PushToILStack(context.NeedsForConstructor(_constructorInfo));
     context.IL.Newobj(_constructorInfo);
     return null;
 }
Esempio n. 4
0
 public IEnumerable<INeed> GetNeeds(IGenerationContext context)
 {
     return context.NeedsForConstructor(_constructorInfo);
 }
Esempio n. 5
0
 public bool IsCorruptingILStack(IGenerationContext context)
 {
     return context.AnyCorruptingStack(context.NeedsForConstructor(_constructorInfo));
 }