Пример #1
0
        /// <summary> Create a field initializer with new keyword. Example: IntReactiveProperty a = new IntReactiveProperty()</summary>
        private static EqualsValueClauseSyntax CreateNewFieldInitializer(FieldGenerationData data)
        {
            var arguments = SyntaxFactory.ArgumentList();

            if (!string.IsNullOrEmpty(data.m_InitializerValue) || VariableTypeCheckerUtility.IsVariableBoolean(data.m_VariableType))
            {
                arguments = arguments.AddArguments(SyntaxFactory.Argument(LiteralExpressionUtility.CreateLiteralExpression(data.m_VariableType, data.m_InitializerValue)));
            }

            return(SyntaxFactory.EqualsValueClause(SyntaxFactory.ObjectCreationExpression(
                                                       NameSyntaxUtility.GetNameSyntax(data.m_VariableType), arguments, null)));
        }
        private static AttributeArgumentSyntax GetAttributeArgumentSyntax(AttributeArgumentData data)
        {
            var argumentSyntax = SyntaxFactory.AttributeArgument(LiteralExpressionUtility.CreateLiteralExpression(data.m_ArgumentType, data.m_ArgumentValue));

            if (data.m_IsPartOfConstructor)
            {
                argumentSyntax = argumentSyntax.WithNameEquals(NameSyntaxUtility.GetNameEqualsSyntax(data.m_ArgumentName));
            }
            else
            {
                argumentSyntax = argumentSyntax.WithNameColon(NameSyntaxUtility.GetNameColonSyntax(data.m_ArgumentName));
            }

            return(argumentSyntax);
        }
Пример #3
0
 /// <summary> Create a field initializer without the new keyword. Example: int a = 0 </summary>
 private static EqualsValueClauseSyntax CreateFieldInitializer(FieldGenerationData data)
 {
     return(SyntaxFactory.EqualsValueClause(LiteralExpressionUtility.CreateLiteralExpression(data.m_VariableType, data.m_InitializerValue)));
 }