private void AddProxyInfo(ClassNotation @class, ProxyGeneratorContext context, ITypeSymbolInfo type) { @class.Members.Add(new FieldNotation() { Accessibility = AccessibilityInfo.Public, Type = type.FullName, Name = context.GetProxyFieldName() }); var setProxyNode = new MethodNotation() { Accessibility = AccessibilityInfo.Public, ReturnType = "void", Name = "SetProxy" }; setProxyNode.Parameters.Add(new ParameterNotation() { Type = "object", Name = "instance" }); setProxyNode.Parameters.Add(new ParameterNotation() { Type = "System.IServiceProvider", Name = "serviceProvider" }); setProxyNode.Body.AddRange(Notation.Create(context.GetProxyFieldName(), " = instance as ", type.FullName, ";")); @class.Members.Add(setProxyNode); @class.Inherits.Add("Norns.Destiny.AOP.IInterceptProxy".ToNotation()); foreach (var f in @class.Members.Select(i => i as FieldNotation).Where(i => i != null && i.IsFromDI)) { setProxyNode.Body.AddRange(Notation.Create(f.Name, " = serviceProvider.GetService(typeof(", f.Type, ")) as ", f.Type, ";")); } }
public static void SetCurrentMethodNotation(this ProxyGeneratorContext context, MethodNotation method) { context[CurrentMethodNotation] = method; }