Beispiel #1
0
        private void AfterGeneration()
        {
            @namespace?.AddEnum(@enum);
            var usings = CodeBuilder.Using(new string[] { "Ludiq" });
            var output = (string.IsNullOrEmpty(decorated.@namespace) || string.IsNullOrWhiteSpace(decorated.@namespace)) ? usings + "\n\n" + @enum.Generate(0) : usings + "\n\n" + @namespace.Generate(0);

            EnumExtensions.Save(guid, decorated, output);
        }
Beispiel #2
0
        public override string Generate(int indent)
        {
            if (Data != null)
            {
                var output = string.Empty;
                NamespaceGenerator @namespace = null;
                EnumGenerator      @enum      = null;

                if (string.IsNullOrEmpty(Data.title))
                {
                    return(output);
                }

                if (!string.IsNullOrEmpty(Data.category))
                {
                    @namespace = NamespaceGenerator.Namespace(Data.category);
                }

                @enum = EnumGenerator.Enum(Data.title.LegalMemberName());

                indices.Clear();

                for (int i = 0; i < Data.items.Count; i++)
                {
                    if (!string.IsNullOrEmpty(Data.items[i].name))
                    {
                        while (indices.Contains(Data.items[i].index))
                        {
                            Data.items[i].index++;
                        }

                        indices.Add(Data.items[i].index);

                        @enum.AddItem(Data.items[i].name, Data.items[i].index);
                    }
                }

                @enum.indexing = Data.useIndex;

#if VISUAL_SCRIPTING_1_7
                if (Data.lastCompiledName != Data.GetFullTypeName())
                {
                    @enum.AddAttribute(AttributeGenerator.Attribute <RenamedFromAttribute>().AddParameter(Data.lastCompiledName));
                }
#endif

                if (@namespace != null)
                {
                    @namespace.AddEnum(@enum);
                    return(@namespace.Generate(indent));
                }

                return(@enum.Generate(indent));
            }

            return(string.Empty);
        }