Exemple #1
0
        public override string ToString()
        {
            var builder = new TypescriptBuilder();

            Build(builder, null);
            return(builder.ToString());
        }
        public override TypescriptBuilder Build(TypescriptBuilder builder, IElement parent)
        {
//            export function displayName(args: Partial<DisplayNameAttribute>)
//            {
//                return function(target: any, propertyKey: string | symbol) {
//                    if (!target.___attributes)
//                        target.___attributes = {};
//                    if (!target.___attributes.properties)
//                        target.___attributes.properties = {}
//                    if (!target.___attributes.properties[propertyKey])
//                        target.___attributes.properties[propertyKey] = {}
//                    target.___attributes.properties[propertyKey].displayName = args;
//                }
//            }

            return(builder.Append("export function ").Append(Identifier).Append("(params: Partial<").Append(ArgumentsClassName).Append(">) {")
                   .Indent().NewLine()
                   .Append("return function(target: any, propertyKey: string | symbol) {")
                   .Indent().NewLine()
                   .Append("if (!target.___attributes)")
                   .Indent().NewLine()
                   .Append("target.___attributes = {};")
                   .Unindent().NewLine()
                   .Append("if (!target.___attributes.properties)")
                   .Indent().NewLine()
                   .Append("target.___attributes.properties = {};")
                   .Unindent().NewLine()
                   .Append("if (!target.___attributes.properties[propertyKey]").Append(")")
                   .Indent().NewLine()
                   .Append("target.___attributes.properties[propertyKey]").Append(" = {};")
                   .Unindent().NewLine()
                   .Append("target.___attributes.properties[propertyKey].").Append(ShortName).Append(" = params;")
                   .Unindent().NewLine().Append("}")
                   .Unindent().NewLine().Append('}'));
        }
        public override TypescriptBuilder Build(TypescriptBuilder builder, IElement parent)
        {
            builder.Append(Code);

            if (!string.IsNullOrWhiteSpace(Comment))
            {
                builder.Append(new Comment(Comment), this);
            }

            return(builder);
        }
        public override TypescriptBuilder Build(TypescriptBuilder builder, IElement parent)
        {
//            export function noun(args: Partial<DisplayNameAttribute>) {
//                return function<T extends { new (...args: any[]): {} }>(ctor: T) {
//                    return class extends ctor {
//                        ___attributes;
//                        constructor(...args: any[]) {
//                            super();
//                            if (!this.___attributes)
//                                this.___attributes = {};
//                            this.___attributes.noun = args;
//                        }
//                    };
//                };
//            }

            return(builder.Append("export function ").Append(Identifier).Append("(params: Partial<").Append(ArgumentsClassName).Append(">) {")
                   .Indent().NewLine()
                   .Append("return function<T extends { new (...args: any[]): {} }>(ctor: T) {")
                   .Indent().NewLine()
                   .Append("return class extends ctor {")
                   .Indent().NewLine()
                   .Append(prefix).Append(';')
                   .Append("constructor(...args: any[]) {")
                   .Indent().NewLine()
                   .Append("super();").NewLine()
                   .Append("if (!this.").Append(prefix).Append(")")
                   .Indent().NewLine()
                   .Append("this.").Append(prefix).Append(" = { };")
                   .Unindent().NewLine()
                   .Append("this.").Append(prefix).Append('.').Append(ShortName).Append(" = params;")
                   .Unindent().NewLine().Append('}')
                   .Unindent().NewLine().Append("}")
                   .Unindent().NewLine().Append("}")
                   .Unindent().NewLine().Append('}'));
        }
Exemple #5
0
 public abstract TypescriptBuilder Build(TypescriptBuilder builder, IElement parent);