Ejemplo n.º 1
0
        public void Run(RefactoringContext context)
        {
            var property = context.GetNode <PropertyDeclaration> ();
            var field    = GetBackingField(context);

            context.ReplaceReferences(field, property);

            // create new auto property
            var newProperty = (PropertyDeclaration)property.Clone();

            newProperty.Getter.Body = BlockStatement.Null;
            newProperty.Setter.Body = BlockStatement.Null;

            using (var script = context.StartScript()) {
                script.Remove(context.Unit.GetNodeAt <FieldDeclaration> (field.Region.BeginLine, field.Region.BeginColumn));
                script.Replace(property, newProperty);
            }
        }