internal static string GenerateMemberCode (MDRefactoringContext ctx, TypeSystemAstBuilder builder, IMember member) { var method = builder.ConvertEntity (member) as MethodDeclaration; if (method != null) { method.Body = new BlockStatement { new ThrowStatement (new ObjectCreateExpression (ctx.CreateShortType ("System", "NotImplementedException"))) }; method.Modifiers &= ~Modifiers.Virtual; method.Modifiers &= ~Modifiers.Abstract; method.Attributes.Add (new AttributeSection { Attributes = { GenerateExportAttribute (ctx, member) } }); return method.ToString (ctx.FormattingOptions); } var property = builder.ConvertEntity (member) as PropertyDeclaration; if (property == null) return null; var p = (IProperty)member; property.Modifiers &= ~Modifiers.Virtual; property.Modifiers &= ~Modifiers.Abstract; if (p.CanGet) { property.Getter.Body = new BlockStatement { new ThrowStatement (new ObjectCreateExpression (ctx.CreateShortType ("System", "NotImplementedException"))) }; property.Getter.Attributes.Add (new AttributeSection { Attributes = { GenerateExportAttribute (ctx, p.Getter) } }); } if (p.CanSet) { property.Setter.Body = new BlockStatement { new ThrowStatement (new ObjectCreateExpression (ctx.CreateShortType ("System", "NotImplementedException"))) }; property.Setter.Attributes.Add (new AttributeSection { Attributes = { GenerateExportAttribute (ctx, p.Setter) } }); } return property.ToString (ctx.FormattingOptions); }
protected override IEnumerable<string> GenerateCode (List<object> includedMembers) { var generator = Options.CreateCodeGenerator (); generator.AutoIndent = false; var ctx = new MDRefactoringContext (Options.Document, Options.Document.Editor.Caret.Location); var builder = ctx.CreateTypeSystemAstBuilder (); foreach (IMember member in includedMembers) { var method = builder.ConvertEntity (member) as MethodDeclaration; method.Body = new BlockStatement () { new ThrowStatement (new ObjectCreateExpression (ctx.CreateShortType ("System", "NotImplementedException"))) }; var astType = ctx.CreateShortType ("MonoTouch.Foundation", "ExportAttribute"); if (astType is SimpleType) { astType = new SimpleType ("Export"); } else { astType = new MemberType (new MemberType (new SimpleType ("MonoTouch"), "Foundation"), "Export"); } var attr = new ICSharpCode.NRefactory.CSharp.Attribute { Type = astType, }; method.Modifiers &= ~Modifiers.Virtual; var exportAttribute = member.GetAttribute (new FullTypeName (new TopLevelTypeName ("MonoTouch.Foundation", "ExportAttribute"))); attr.Arguments.Add (new PrimitiveExpression (exportAttribute.PositionalArguments.First ().ConstantValue)); method.Attributes.Add (new AttributeSection { Attributes = { attr } }); yield return method.ToString (); } }