Mono.CSharp.Property.CreateAutomaticProperty C# (CSharp) Method

CreateAutomaticProperty() public method

public CreateAutomaticProperty ( ) : void
return void
        void CreateAutomaticProperty()
        {
            // Create backing field
            Field field = new BackingField (this);
            if (!field.Define ())
                return;

            Parent.PartialContainer.AddField (field);

            FieldExpr fe = new FieldExpr (field, Location);
            if ((field.ModFlags & Modifiers.STATIC) == 0)
                fe.InstanceExpression = new CompilerGeneratedThis (fe.Type, Location);

            // Create get block
            Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
            Return r = new Return (fe, Location);
            Get.Block.AddStatement (r);

            // Create set block
            Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location);
            Assign a = new SimpleAssign (fe, new SimpleName ("value", Location));
            Set.Block.AddStatement (new StatementExpression (a));
        }