Beispiel #1
0
        public override void GenerateProperties(IDLInterface idlIntf)
        {
            if (idlIntf.Properties != null && idlIntf.Properties.Count > 0) // If got properties
            {
                foreach (IDLProperty idlProperty in idlIntf.Properties)
                {
                    bool hasGet = CodeBuilderCommon.HasGet(idlProperty);
                    bool hasSet = CodeBuilderCommon.HasSet(idlProperty);

                    if (!hasGet && !hasSet)
                    {
                        continue;
                    }

                    CodeMemberProperty property = new CodeMemberProperty();
                    property.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                    property.Name       = CodeBuilderCommon.GetCompilableName(idlProperty.Name);
                    property.HasGet     = hasGet;
                    property.HasSet     = hasSet;
                    property.Type       = CodeBuilderCommon.PropertyType(CodeTypeFactory.Default, idlProperty.Type);

                    property.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlProperty.Access, idlProperty.Name, idlProperty.Type)));
                    // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument.

                    CodePropertyReferenceExpression proprefTargetProperty = new CodePropertyReferenceExpression(thisProxyFieldRef, property.Name);
                    if (hasGet)
                    {
                        property.GetStatements.Add(
                            new CodeMethodReturnStatement(
                                proprefTargetProperty
                                )
                            );
                    }

                    if (hasSet)
                    {
                        property.SetStatements.Add(
                            new CodeAssignStatement(proprefTargetProperty
                                                    , new CodePropertySetValueReferenceExpression()
                                                    )
                            );
                    }

                    // Finish up.
                    typeProxy.Members.Add(property);
                } // Ends loop over properties
            }     // Ends if got properties
        }
Beispiel #2
0
        private void GenerateProperty(IDLInterface idlIntf, IDLProperty idlProperty
                                      , CodeTypeReference typerefDbusInterface
                                      , CodeTypeReference typerefDbusMarshal
                                      , CodeTypeDeclaration typeProxy)
        {
            bool hasGet = CodeBuilderCommon.HasGet(idlProperty);
            bool hasSet = CodeBuilderCommon.HasSet(idlProperty);

            if (hasGet || hasSet)
            {
                CodeMemberProperty property = new CodeMemberProperty();
                property.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                property.Name       = CodeBuilderCommon.GetCompilableName(idlProperty.Name);
                property.HasGet     = hasGet;
                property.HasSet     = hasSet;
                property.Type       = CodeBuilderCommon.PropertyType(CodeTypeFactory.DefaultProperty, idlProperty.Type);

                property.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlProperty.Access, idlProperty.Name, idlProperty.Type)));
                // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument.

                CodeVariableDeclarationStatement vardeclTarget         = this.DeclareTargetVariable(typerefDbusInterface, typerefDbusMarshal);
                CodePropertyReferenceExpression  proprefTargetProperty = new CodePropertyReferenceExpression(varrefTarget, property.Name);
                if (hasGet)
                {
                    property.GetStatements.Add(vardeclTarget);
                    property.GetStatements.Add(
                        new CodeMethodReturnStatement(
                            proprefTargetProperty
                            )
                        );
                }

                if (hasSet)
                {
                    property.SetStatements.Add(vardeclTarget);
                    property.SetStatements.Add(
                        new CodeAssignStatement(proprefTargetProperty
                                                , new CodePropertySetValueReferenceExpression()
                                                )
                        );
                }

                // Finish up.
                typeProxy.Members.Add(property);
            }
        }