Esempio n. 1
0
        public string GetName(IEmitter emitter)
        {
            string fieldName = this.Name;

            if (this.VarInitializer != null)
            {
                var rr = emitter.Resolver.ResolveNode(this.VarInitializer, emitter) as MemberResolveResult;
                fieldName = OverloadsCollection.Create(emitter, rr.Member).GetOverloadName();
            }
            else if (this.Entity is PropertyDeclaration)
            {
                fieldName = OverloadsCollection.Create(emitter, (PropertyDeclaration)this.Entity).GetOverloadName();
            }
            else
            {
                fieldName = emitter.ChangeCase ? TypeConfigItem.ToLowerCamelCase(fieldName) : fieldName;
            }
            return(fieldName);
        }
        public string GetName(IEmitter emitter)
        {
            string fieldName = this.Name;

            if (this.VarInitializer != null)
            {
                var rr = emitter.Resolver.ResolveNode(this.VarInitializer, emitter) as MemberResolveResult;
                fieldName = OverloadsCollection.Create(emitter, rr.Member).GetOverloadName();
            }
            else if (this.Entity is PropertyDeclaration)
            {
                fieldName = OverloadsCollection.Create(emitter, (PropertyDeclaration)this.Entity).GetOverloadName();
            }
            else
            {
                fieldName = emitter.AssemblyInfo.PreserveMemberCase ? fieldName : TypeConfigItem.ToLowerCamelCase(fieldName);

                if (Helpers.IsReservedWord(fieldName))
                {
                    fieldName = Helpers.ChangeReservedWord(fieldName);
                }
            }
            return(fieldName);
        }
Esempio n. 3
0
        private void WriteProp(TypeConfigItem ev, string name, bool getter)
        {
            this.Write(getter ? "get" : "set");
            this.Write(name);
            this.WriteOpenParentheses();

            if (!getter)
            {
                this.Write("value");
                this.WriteColon();
                string typeName = BridgeTypes.ToJsName(ev.Entity.ReturnType, this.Emitter);
                typeName = EmitBlock.HandleType(typeName);
                this.Write(typeName);
            }

            this.WriteCloseParentheses();
            this.WriteColon();

            if (!getter)
            {
                this.Write("void");
            }
            else
            {
                string typeName = BridgeTypes.ToJsName(ev.Entity.ReturnType, this.Emitter);
                typeName = EmitBlock.HandleType(typeName);
                this.Write(typeName);
            }

            this.WriteSemiColon();
            this.WriteNewLine();
        }
Esempio n. 4
0
        private void WriteEvent(TypeConfigItem ev, string name)
        {
            this.Write(name);
            this.WriteOpenParentheses();
            this.Write("value");
            this.WriteColon();
            string typeName = BridgeTypes.ToJsName(ev.Entity.ReturnType, this.Emitter);
            typeName = EmitBlock.HandleType(typeName);
            this.Write(typeName);
            this.WriteCloseParentheses();
            this.WriteColon();
            this.Write("void");

            this.WriteSemiColon();
            this.WriteNewLine();
        }
Esempio n. 5
0
        private void WriteEvent(TypeConfigItem ev, string name)
        {
            XmlToJsDoc.EmitComment(this, ev.Entity);
            this.Write(name);
            this.WriteOpenParentheses();
            this.Write("value");
            this.WriteColon();
            string typeName = BridgeTypes.ToTypeScriptName(ev.Entity.ReturnType, this.Emitter);
            this.Write(typeName);
            this.WriteCloseParentheses();
            this.WriteColon();
            this.Write("void");

            this.WriteSemiColon();
            this.WriteNewLine();
        }
Esempio n. 6
0
        public string GetName(IEmitter emitter, bool withoutTypeParams = false)
        {
            string fieldName = this.Name;

            if (this.VarInitializer != null)
            {
                var rr = emitter.Resolver.ResolveNode(this.VarInitializer, emitter) as MemberResolveResult;
                fieldName = OverloadsCollection.Create(emitter, rr.Member).GetOverloadName(false, null, withoutTypeParams);
            }
            else if (this.Entity is PropertyDeclaration)
            {
                fieldName = OverloadsCollection.Create(emitter, (PropertyDeclaration)this.Entity).GetOverloadName(false, null, withoutTypeParams);
            }
            else
            {
                bool done = false;
                if (this.Entity != null)
                {
                    var rr = emitter.Resolver.ResolveNode(this.Entity, emitter) as MemberResolveResult;

                    if (rr != null)
                    {
                        fieldName = OverloadsCollection.Create(emitter, rr.Member).GetOverloadName(false, null, withoutTypeParams);
                        done      = true;
                    }
                }

                if (!done)
                {
                    fieldName = emitter.AssemblyInfo.PreserveMemberCase ? fieldName : TypeConfigItem.ToLowerCamelCase(fieldName);

                    /*if (Helpers.IsReservedWord(fieldName))
                     * {
                     *  fieldName = Helpers.ChangeReservedWord(fieldName);
                     * }*/
                }
            }
            return(fieldName);
        }