Example #1
0
        public override string ToString()
        {
            var stringBuilder = new StringBuilder();

            foreach (var attribute in Attributes)
            {
                stringBuilder.AppendLine(attribute.ToString());
            }
            stringBuilder.AppendLine(string.Format("{0} enum {1} : {2}",
                                                   AccessModifiers.ToTokenString(), Value.Name,
                                                   BaseType.ToString().ToLowerInvariant()).Trim());
            stringBuilder.AppendLine("{");

            var isFlags = Attributes.Any(x => x.AttributeType == typeof(FlagsAttribute));
            var value   = isFlags ? 1 : 0;

            foreach (var item in ValueNames)
            {
                if (item.HasDescription)
                {
                    stringBuilder.AppendSummary(item.Description);
                }
                stringBuilder.AppendLine(string.Format("{0} = {1},", GuerillaCs.ToTypeName(item.Name), value));
                value = isFlags ? value << 1 : ++value;
            }
            stringBuilder.AppendLine("};");
            return(stringBuilder.ToString().Trim());
        }
Example #2
0
        public TokenDictionary Format()
        {
            var tokenDictionary = HasBaseClass ? new TokenDictionary(BaseClass.Format()) : new TokenDictionary();

            string name, @namespace;

            if (GuerillaCs.SplitNamespaceFromFieldName(_value.Name, out name, out @namespace))
            {
                Name      = tokenDictionary.GenerateValidToken(GuerillaCs.ToTypeName(name));
                Namespace = new NamespaceInfo(GuerillaCs.ToTypeName(@namespace));
            }
            else
            {
                Name = tokenDictionary.GenerateValidToken(GuerillaCs.ToTypeName(_value.Name));
            }

            FormatFieldNames(tokenDictionary);
            foreach (var item in EnumDefinitions)
            {
                item.Format();
            }
            foreach (var item in ClassDefinitions)
            {
                item.Format();
            }
            return(tokenDictionary);
        }
Example #3
0
        public void Format()
        {
            var tokenDictionary = new TokenDictionary();

            for (int i = 0; i < ValueNames.Count; i++)
            {
                ValueNames[i] = tokenDictionary.GenerateValidToken(GuerillaCs.ToTypeName(ValueNames[i]));
            }
        }
Example #4
0
        private void FormatFieldNames(TokenDictionary tokenDictionary)
        {
            foreach (var item in Fields)
            {
                var token = tokenDictionary.GenerateValidToken(GuerillaCs.ToMemberName(item.Value.Name));
                item.Value.Name = token;
            }

            foreach (var item in Methods)
            {
                var token = tokenDictionary.GenerateValidToken(GuerillaCs.ToMemberName(item.ClassName));
                item.ClassName = token;
            }

            foreach (var item in EnumDefinitions)
            {
                var token = tokenDictionary.GenerateValidToken(GuerillaCs.ToTypeName(item.Value.Name));
                item.Value.Name = token;
            }
        }