예제 #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());
        }
예제 #2
0
        public override string ToString()
        {
            var methodStringBuilder = new StringBuilder();
            var modifiersString     = AccessModifiers.ToTokenString();

            methodStringBuilder.AppendFormat("{0}{3}{1}{4}{2}", modifiersString, Returns, GetMethodSignature(),
                                             string.IsNullOrWhiteSpace(modifiersString) ? "" : " ",
                                             string.IsNullOrWhiteSpace(Returns) ? "" : " ");
            if (Wrapper)
            {
                methodStringBuilder.AppendFormat(" : base({0})", GetArguments(Arguments));
            }
            methodStringBuilder.AppendLine();
            methodStringBuilder.AppendLine("{");
            if (!string.IsNullOrWhiteSpace(Body))
            {
                methodStringBuilder.AppendLine(Body);
            }
            methodStringBuilder.AppendLine("}");
            return(methodStringBuilder.ToString().Trim());
        }
예제 #3
0
        public override string ToString()
        {
            var hasSetter = SetBody != null;
            var hasGetter = GetBody != null;

            var builder = new StringBuilder();

            builder.Append(string.Format("{0} {1} {2} ", AccessModifiers.ToTokenString(), Returns, Name));
            var indent = 0;

            builder.Append("{".Tab(ref indent));
            if (hasGetter)
            {
                var auto = string.IsNullOrWhiteSpace(GetBody);
                builder.Append(auto ? " get; " : string.Format(" get {{ {0} }}", GetBody));
            }
            if (hasSetter)
            {
                var auto = string.IsNullOrWhiteSpace(SetBody);
                builder.Append(auto ? " set; " : string.Format(" set {{ {0} }}", GetBody));
            }
            builder.Append(" }".Tab(ref indent));
            return(builder.ToString());
        }
예제 #4
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            // write Summary
            if (Value.HasDescription)
            {
                stringBuilder.AppendSummary(Value.Description);
            }
            // write Attributes
            foreach (var attribute in Attributes)
            {
                stringBuilder.AppendLine(attribute.ToString());
            }

            var typeString = GetTypeOutput();

            // write Field
            stringBuilder.AppendLine(string.Format("{0} {1}{2} {3};",
                                                   AccessModifiers.ToTokenString(),
                                                   typeString, IsArray ? "[]" : "", Value.Name));

            return(stringBuilder.ToString().Trim());
        }