Example #1
0
        /// <summary>
        /// function declaration
        /// ex: _alias0.LoginModel = _alias0.LoginModel || function () { var args = Array.prototype.slice.call(arguments); var obj = { "UserName": "", "Password": "", "RememberMe": false }; obj.constructor = _alias0.LoginModel; return obj; };
        /// </summary>
        /// <param name="withAlias"></param>
        /// <returns></returns>
        private List <string> CreateJsObjectDeclaration(bool withAlias)
        {
            List <string> funcDecl_Array = new List <string>();

            foreach (var dic in Classes)
            {
                foreach (var kv in dic)
                {
                    {
                        var    ts_out   = TypeSorter_Script.GetInstance(EnumScript.JS, kv.Value, _JSNamespace);
                        string funcDecl = ScriptHelper.GetInstance(EnumScript.JS).GetFactoryDeclaration(
                            kv.Key,
                            ts_out.ScriptValue(this.found_complex_types),
                            true,
                            _JSNamespace.GetObjectFullName(kv.Key, withAlias));
                        funcDecl_Array.Add(funcDecl);
                    }
                }
            }
            return(funcDecl_Array);
        }
Example #2
0
        /// <summary>
        /// ex: 'Course:$dp.$JsNet.MvcApplicationExample.Models.Course'. 'Course' is name of property.
        /// </summary>
        /// <param name="mi"></param>
        /// <param name="telem_work"></param>
        /// <param name="isCollection"></param>
        /// <returns></returns>
        override protected string GetScriptKeyValue_FactoryCall(MemberInfo mi, Type telem_work, bool isCollection)
        {
            string tname;

            if (telem_work == typeof(System.Object))
            {
                tname = "Object";
            }
            else
            {
                tname = _JSNamespace.GetObjectFullName(telem_work, false);
            }

            if (isCollection)
            {
                tname = (new ScriptTypeInfo_TS()).TArrayFactoryFunctionDefinitionCall(tname);
            }


            var key_value = string.Format("{0}:{1}", mi.Name, tname);

            return(key_value);
        }
Example #3
0
        /// <summary>
        /// ex: 'Course:$dp.$JsNet.MvcApplicationExample.Models.Course'. 'Course' is name of property.
        /// ex: "Courses_":$dp.$shared.$arrayFactory($dp.$shared.$circularReferenceManagerFactory.apply(null, args)($dp.$JsNet.ContosoUniversity.Models.Course))
        /// </summary>
        /// <param name="mi"></param>
        /// <param name="telem_work"></param>
        /// <param name="isCollection"></param>
        /// <returns></returns>
        override protected string GetScriptKeyValue_FactoryCall(MemberInfo mi, Type telem_work, bool isCollection)
        {
            string key_value = TypeSorter_JS.GetJsKeyValue_FactoryCall(mi, telem_work, isCollection, _JSNamespace.GetObjectFullName(telem_work, true));

            return(key_value);
        }
Example #4
0
        internal static string GetScript_EmptyValue_WithFactory_forEnum(Type t, bool nsAlias, ConfigJS.JSNamespace _JSNamespace, EnumScript choice)
        {
            if (t.IsEnum == false)
            {
                throw new Exception("t must be Enum");
            }

            string jsValue;
            Type   telem_work;
            bool   isCollection = TypeHelper.GetElementTypeOfCollection(t, out telem_work);

            if (isCollection == false)
            {
                telem_work = t;
            }

            //-- telem_work  is collection.
            jsValue = ScriptHelper.GetInstance(choice).GetObjectFactoryName(telem_work, isCollection, true, _JSNamespace.GetObjectFullName(telem_work, nsAlias));

            return(jsValue);
        }
Example #5
0
        internal static string GetScript_EmptyValue_WithFactory(Type t, bool nsAlias, ConfigJS.JSNamespace _JSNamespace, EnumScript choice, HashSet <Type> found_complex_types)
        {
            string jsValue;

            if (!ScriptHelper.GetInstance(choice).GetPrimitiveEmptyValue(t, out jsValue))
            {
                bool isCollection;

                //-- it's class so, we use functionReference.
                Type telem_work = TypeHelper.FindCustomTypeOrDefault(t, out isCollection);

                if (telem_work != null)
                {
                    if (isCollection)
                    {
                        //-- telem_work  is collection.
                        jsValue = ScriptHelper.GetInstance(choice).GetObjectFactoryName(telem_work, isCollection, false, _JSNamespace.GetObjectFullName(telem_work, nsAlias));
                    }
                    else
                    {
                        if (AspMvcInfo.TypesOfAspNetSetWebApi != null)
                        {
                            if (
                                AspMvcInfo.TypesOfAspNetSetMvc.TMvc.Type_ActionResult.IsAssignableFrom(telem_work) == false &&
                                AspMvcInfo.TypesOfAspNetSetWebApi.TNetHttp.Type_HttpResponseMessage.IsAssignableFrom(telem_work) == false &&

                                (
                                    AspMvcInfo.TypesOfAspNetSetWebApi.TWebHttp.Type_IHttpActionResult == null ||

                                    (AspMvcInfo.TypesOfAspNetSetWebApi.TWebHttp.Type_IHttpActionResult != null &&
                                     AspMvcInfo.TypesOfAspNetSetWebApi.TWebHttp.Type_IHttpActionResult.IsAssignableFrom(telem_work) == false)
                                )
                                )
                            {
                                jsValue = GetObjectFactoryName_wrapper_with_found_complex_types(telem_work, isCollection, nsAlias, _JSNamespace, choice, found_complex_types);
                            }
                            else
                            {
                                jsValue = "{}";
                            }
                        }
                        else
                        {
                            //-- no web api.
                            if (AspMvcInfo.TypesOfAspNetSetMvc.TMvc.Type_ActionResult.IsAssignableFrom(telem_work) == false)
                            {
                                jsValue = GetObjectFactoryName_wrapper_with_found_complex_types(telem_work, isCollection, nsAlias, _JSNamespace, choice, found_complex_types);
                            }
                            else
                            {
                                jsValue = "{}";
                            }
                        }
                    }
                }
                else
                {
                    jsValue = "{}";
                }
            }

            return(jsValue);
        }
Example #6
0
        private static string GetObjectFactoryName_wrapper_with_found_complex_types(Type telem_work, bool isCollection, bool nsAlias, ConfigJS.JSNamespace _JSNamespace, EnumScript choice, HashSet <Type> found_complex_types)
        {
            string jsValue_;

            System.Diagnostics.Debug.Assert(ScriptHelper.GetCategoryType(telem_work) == ScriptHelper.EnumType.tcomplex, "it must be complex type");

            //-- complex type
            if (found_complex_types != null && found_complex_types.Contains(telem_work) == false)
            {
                telem_work = typeof(System.Object);
            }

            jsValue_ = ScriptHelper.GetInstance(choice).GetObjectFactoryName(telem_work, isCollection, false, _JSNamespace.GetObjectFullName(telem_work, nsAlias));

            return(jsValue_);
        }