Exemple #1
0
        public CodeProperty(
            IEnumerable <CodeAttribute>?customAttributes,
            CodeIdentifier name,
            CodeTypeToken type,
            Modifiers attributes,
            bool hasGetter,
            CodeBlock?getter,
            bool hasSetter,
            CodeBlock?setter,
            CodeComment?trailingComment,
            CodeXmlComment?xmlDoc,
            ICodeExpression?initializer)
            : base(customAttributes)
        {
            Name            = name;
            Type            = type;
            Attributes      = attributes;
            HasGetter       = hasGetter;
            Getter          = getter;
            HasSetter       = hasSetter;
            Setter          = setter;
            TrailingComment = trailingComment;
            XmlDoc          = xmlDoc;
            Initializer     = initializer;

            Reference = new CodeReference(this);
        }
Exemple #2
0
 public CodeNewArray(CodeTypeToken type, bool valueTyped, IEnumerable <ICodeExpression> values, bool inline)
 {
     Type       = type;
     ValueTyped = valueTyped;
     Inline     = inline;
     Values     = values.ToArray();
     _arrayType = new ArrayType(type.Type, new int?[] { Values.Count == 0 ? null : Values.Count }, false);
 }
Exemple #3
0
 public CodeAttribute(
     CodeTypeToken type,
     IEnumerable <ICodeExpression>?parameters,
     IEnumerable <CodeNamedParameter>?namedParameters)
 {
     Type             = type;
     _parameters      = new (parameters ?? Array <ICodeExpression> .Empty);
     _namedParameters = new (namedParameters ?? Array <CodeNamedParameter> .Empty);
 }
Exemple #4
0
        public CodeAsOperator(CodeTypeToken type, ICodeExpression value)
        {
            if (type.Type.IsValueType && !type.Type.IsNullable)
            {
                throw new InvalidOperationException($"as operator cannot be used with non-nullable value type: {type.Type}");
            }

            Type  = type;
            Value = value;
        }
Exemple #5
0
 public CodeNew(CodeTypeToken type, IEnumerable <ICodeExpression> parameters, IEnumerable <CodeAssignmentStatement> initializers)
 {
     Type         = type;
     Parameters   = parameters.ToArray() ?? Array <ICodeExpression> .Empty;
     Initializers = initializers.ToArray() ?? Array <CodeAssignmentStatement> .Empty;
 }
Exemple #6
0
 internal void AddInterface(CodeTypeToken interfaceType)
 {
     _implements.Add(interfaceType);
 }
Exemple #7
0
 internal void AddGenericParameter(CodeTypeToken genericParameter)
 {
     _typeArguments.Add(genericParameter);
 }
Exemple #8
0
 protected override void Visit(CodeTypeToken type)
 {
     CollectTypeImports(type.Type);
     base.Visit(type);
 }
Exemple #9
0
 protected override void Visit(CodeTypeToken type)
 {
     RegisterType(type.Type);
     base.Visit(type);
 }