Example #1
0
        protected CodeMemberMethod RenderMethod(object instance, KeyValuePair <MethodInfo, GenerateMethod> templateMethod, IDiagramNodeItem data)
        {
            MethodInfo info;
            var        dom = TemplateType.MethodFromTypeMethod(templateMethod.Key.Name, out info, false);

            CurrentMember    = dom;
            CurrentAttribute = templateMethod.Value;
            PushStatements(dom.Statements);

            var args       = new List <object>();
            var parameters = info.GetParameters();

            foreach (var arg in parameters)
            {
                args.Add(GetDefault(arg.ParameterType));
            }

            CurrentDeclaration.Members.Add(dom);

            var result = info.Invoke(instance, args.ToArray());
            var a      = result as IEnumerable;

            if (a != null)
            {
                a.Cast <object>().ToArray();
                //    foreach (var item in dummyIteraters)
                //    {

                //    }
            }

            PopStatements();

            //var isOverried = false;
            //if (!IsDesignerFile && dom.Attributes != MemberAttributes.Final && templateMethod.Value.Location == TemplateLocation.Both)
            //{
            //    dom.Attributes |= MemberAttributes.Override;
            //    isOverried = true;
            //}
            //if ((info.IsVirtual && !IsDesignerFile) || (info.IsOverride() && !info.GetBaseDefinition().IsAbstract && IsDesignerFile))
            //{
            //    if (templateMethod.Value.CallBase)
            //    {
            //        //if (!info.IsOverride() || !info.GetBaseDefinition().IsAbstract && IsDesignerFile)
            //        //{
            //        dom.invoke_base(true);
            //        //}

            //    }
            //}
            InvertApplication.SignalEvent <ICodeTemplateEvents>(_ => _.MethodAdded(instance, this, dom));
            return(dom);
        }