Esempio n. 1
0
        protected override DataInfo Factory(EnumScript choice, Type tobj, ConfigJS.JSNamespace JSNamespac)
        {
            switch (choice)
            {
            case EnumScript.JS:
                return(new EnumInfo_JS(tobj, this.JsObjCol, JSNamespac, this.flagGetFactory));

            case EnumScript.TS:
                return(new EnumInfo_TS(tobj, this.JsObjCol, JSNamespac, this.flagGetFactory));

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get instance.
        /// </summary>
        /// <param name="choice"></param>
        /// <param name="tobj"></param>
        /// <param name="JSNamespace"></param>
        /// <returns></returns>
        internal static TypeSorter_Script GetInstance(EnumScript choice, TypeSorter_ tobj, ConfigJS.JSNamespace JSNamespace)
        {
            switch (choice)
            {
            case EnumScript.JS:
                return(new TypeSorter_JS(tobj, JSNamespace));

            case EnumScript.TS:
                return(new TypeSorter_TS(tobj, JSNamespace));

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Get instance.
        /// </summary>
        /// <returns></returns>
        static public ScriptHelper GetInstance(EnumScript choice)
        {
            switch (choice)
            {
            case EnumScript.JS:
                return(ScriptHelper.ScriptHelper_JS);

            case EnumScript.TS:
                return(ScriptHelper.ScriptHelper_TS);

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Serialise returns of action.
        /// </summary>
        /// <param name="choice"></param>
        /// <param name="alias"></param>
        /// <returns></returns>
        public string ToScript_Return(EnumScript choice, bool alias)
        {
            string jsonValue;

            if (AspMvcInfo.TypesOfAspNetSetWebApi != null)
            {
                Type type_return = WebApiHelper.GetEffectiveReturnType(this.MethodInfo);
                jsonValue = GetScript_EmptyValue_WithFactory(type_return, alias, _JSNamespace, choice, this.ModelInfo.found_complex_types);
            }
            else
            {
                jsonValue = "{}";
            }
            return(jsonValue);
        }
Esempio n. 5
0
        /// <summary>
        /// Serialise parameters of action.
        /// {param1:obj1, param2:2, param3:"" } or null
        /// </summary>
        /// <param name="choice"></param>
        /// <param name="sb"></param>
        /// <param name="nsAlias"></param>
        /// <param name="modelInfo"></param>
        /// <returns>true: appending, false: nothing</returns>
        public bool ToScript_Params(EnumScript choice, StringBuilder sb, bool nsAlias)
        {
            ParameterInfo[] piArray = this.MethodInfo.GetParameters();

            if (piArray.Length > 0)
            {
                sb.Append("{");
                ActionInfo.GetScript_Params(piArray, _JSNamespace, choice, sb, nsAlias, this.ModelInfo);
                sb.Append("}");
                return(true);
            }
            else
            {
                return(false);
            }
        }
	public void playClip(EnumScript.CustomAudioClips audioClip)
	{
		switch(audioClip)
		{
			case EnumScript.CustomAudioClips.failHorn:
				audio.PlayOneShot(failHorn);
				break;
			case EnumScript.CustomAudioClips.dingDing:
				audio.PlayOneShot(dingDing);
				break;
            case EnumScript.CustomAudioClips.explosion:
                audio.PlayOneShot(explosion);
                break;
			default:
				break;
		}
	}
Esempio n. 7
0
 abstract protected DataInfo Factory(EnumScript choice, Type tobj, ConfigJS.JSNamespace JSNamespace);
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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_);
        }
Esempio n. 11
0
        /// <summary>
        /// Get parameters of action in JS in string.
        /// </summary>
        /// <param name="piArray"></param>
        /// <param name="_JSNamespace"></param>
        /// <param name="choice"></param>
        /// <param name="jsParams"></param>
        /// <param name="nsAlias"></param>
        /// <param name="separator"></param>
        /// <returns>true => appending, false => nothing </returns>
        static internal bool GetScript_Params(ParameterInfo[] piArray, ConfigJS.JSNamespace _JSNamespace, EnumScript choice, StringBuilder jsParams, bool nsAlias, ModelInfo modelInfo, char separator = ',')
        {
            for (var ii = 0; ii < piArray.Length; ii++)
            {
                var    pi        = piArray[ii];
                string paramName = pi.Name;

                string scriptValue = GetScript_EmptyValue_WithFactory(pi.ParameterType, nsAlias, _JSNamespace, choice, modelInfo.found_complex_types);

                if (ii >= 1)
                {
                    jsParams.Append(separator);
                }

                jsParams.Append(ScriptHelper.GetInstance(choice).GetKeyValue(paramName, scriptValue));
            }

            return(piArray.Length > 0);
        }
Esempio n. 12
0
	public void setResistanceScale(EnumScript.ResistanceScale localScale)
	{
		scale = localScale;
	}