Exemplo n.º 1
0
        public override void Modify(object templateInstance, MemberInfo info, TemplateContext ctx)
        {
            base.Modify(templateInstance, info, ctx);
            var propertyInfo = info as PropertyInfo;
            var t            = ctx.ProcessType(propertyInfo.PropertyType);

            if (t != null)
            {
                ctx.CurrentProperty.Type = new CodeTypeReference(t);
            }
        }
Exemplo n.º 2
0
        public override void Modify(object templateInstance, MemberInfo info, TemplateContext ctx)
        {
            base.Modify(templateInstance, info, ctx);
            var methodInfo = info as MethodInfo;
            var t          = ctx.ProcessType(methodInfo.ReturnType);

            if (t != null)
            {
                ctx.CurrentMethod.ReturnType = new CodeTypeReference(t);
            }
            var prms = methodInfo.GetParameters();

            for (int index = 0; index < prms.Length; index++)
            {
                var parameter         = prms[index];
                var templateParameter = ctx.CurrentMethod.Parameters[index];
                var x = ctx.ProcessType(parameter.ParameterType);
                if (x != null)
                {
                    templateParameter.Type = new CodeTypeReference(x);
                }
            }
            var isOverried = false;

            if (!ctx.IsDesignerFile && ctx.CurrentMember.Attributes != MemberAttributes.Final && ctx.CurrentAttribute.Location == TemplateLocation.Both)
            {
                ctx.CurrentMethod.Attributes |= MemberAttributes.Override;
                isOverried = true;
            }
            if ((methodInfo.IsVirtual && !ctx.IsDesignerFile) || (methodInfo.IsOverride() && !methodInfo.GetBaseDefinition().IsAbstract&& ctx.IsDesignerFile))
            {
                if ((ctx.CurrentAttribute as GenerateMethod).CallBase)
                {
                    //if (!info.IsOverride() || !info.GetBaseDefinition().IsAbstract && IsDesignerFile)
                    //{
                    ctx.CurrentMethod.invoke_base(true);
                    //}
                }
            }
        }
Exemplo n.º 3
0
 private void CreateField(TemplateContext ctx)
 {
     if (FieldType != null)
     {
         Field = ctx.CurrentDeclaration._private_(ctx.ProcessType(FieldType), "_{0}", ctx.CurrentProperty.Name.Clean());
     }
     else
     {
         Field = ctx.CurrentDeclaration._private_(ctx.CurrentProperty.Type, "_{0}", ctx.CurrentProperty.Name.Clean());
     }
     if (_customAttributes != null)
     {
         Field.CustomAttributes.AddRange(_customAttributes.Select(p => new CodeAttributeDeclaration(new CodeTypeReference(p))).ToArray());
     }
 }