示例#1
0
 protected override object NewEnum(NewCodeElementItemParams newItemParams, string path)
 {
     return(_namespace.AddEnum(path,
                               newItemParams.Position,
                               newItemParams.Bases.ToCSVDTEParameter(),
                               newItemParams.AccessKind
                               ));
 }
示例#2
0
    public void AddsErrorImportForEnums()
    {
        var testEnum = root.AddEnum(new CodeEnum {
            Name = "TestEnum",
        }).First();

        ILanguageRefiner.Refine(new GenerationConfiguration {
            Language = GenerationLanguage.Go
        }, root);
        Assert.Single(testEnum.Usings.Where(x => x.Name == "errors"));
    }
示例#3
0
        public CodeEnumWriterTests()
        {
            writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.Ruby, DefaultPath, DefaultName);
            tw     = new StringWriter();
            writer.SetTextWriter(tw);
            var root = CodeNamespace.InitRootNamespace();

            parentNamespace = root.AddNamespace("parentNamespace");
            currentEnum     = parentNamespace.AddEnum(new CodeEnum {
                Name = EnumName,
            }).First();
        }
    public void ReplacesReservedEnumOptions()
    {
        var model = root.AddEnum(new CodeEnum
        {
            Name = "model",
        }).First();
        var option = new CodeEnumOption {
            Name = "break", // this a keyword
        };

        model.AddOption(option);
        ILanguageRefiner.Refine(new GenerationConfiguration {
            Language = GenerationLanguage.Java
        }, root);
        Assert.Equal("break_escaped", option.Name);
        Assert.Equal("break", option.SerializationName);
    }
 public ShellCodeEnum AddEnum(string Name, object Position, object Bases, vsCMAccess Access)
 {
     return(new ShellCodeEnum(_namespace.AddEnum(Name, Position, Bases, Access)));
 }
示例#6
0
    private void AddSerializationProperties()
    {
        var addData = parentClass.AddProperty(new CodeProperty {
            Name = "additionalData",
            Kind = CodePropertyKind.AdditionalData,
        }).First();

        addData.Type = new CodeType {
            Name = "string"
        };
        var dummyProp = parentClass.AddProperty(new CodeProperty {
            Name = "dummyProp",
        }).First();

        dummyProp.Type = new CodeType {
            Name = "string"
        };
        var dummyCollectionProp = parentClass.AddProperty(new CodeProperty {
            Name = "dummyColl",
        }).First();

        dummyCollectionProp.Type = new CodeType {
            Name           = "string",
            CollectionKind = CodeTypeBase.CodeTypeCollectionKind.Array,
        };
        var dummyComplexCollection = parentClass.AddProperty(new CodeProperty {
            Name = "dummyComplexColl"
        }).First();
        var complexTypeClass = root.AddClass(new CodeClass
        {
            Name = "SomeComplexType"
        }).First();

        dummyComplexCollection.Type = new CodeType {
            Name           = "Complex",
            CollectionKind = CodeTypeBase.CodeTypeCollectionKind.Array,
            TypeDefinition = complexTypeClass
        };
        var dummyEnumProp = parentClass.AddProperty(new CodeProperty {
            Name = "dummyEnumCollection",
        }).First();
        var enumDefinition = root.AddEnum(new CodeEnum
        {
            Name = "EnumType"
        }).First();

        dummyEnumProp.Type = new CodeType {
            Name           = "SomeEnum",
            TypeDefinition = enumDefinition
        };
        parentClass.AddProperty(new CodeProperty {
            Name = "definedInParent",
            Type = new CodeType {
                Name = "string"
            },
            OriginalPropertyFromBaseType = new CodeProperty {
                Name = "definedInParent",
                Type = new CodeType {
                    Name = "string"
                }
            }
        });
    }
 public static CodeTypeDeclaration AddEnum(this CodeNamespace @namespace, string name, bool isInternal = false) => @namespace.AddEnum(name, null, isInternal);