Beispiel #1
0
        public void GenerateViewModelHandler(string scriptPath)
        {
            string handlerScriptPath = CodeGenerationHelper.GeneratPathWithSubfix(scriptPath, ".Handler.cs");
            string handlerCode       = "";

            if (string.IsNullOrEmpty(handlerCode))
            {
                handlerCode = CodeGenerationHelper.GenerateViewModelHandler(typeName, baseType);
            }
            else
            {
                handlerCode = handlerCode.Replace(": " + typeName, ": " + baseType);
            }
            CodeGenerationHelper.SaveScript(handlerScriptPath, handlerCode, false, typeName, baseType);
        }
Beispiel #2
0
        public void GenerateViewModelHandler(string backupCode, string baseType = null)
        {
            if (string.IsNullOrEmpty(baseType))
            {
                baseType = selectedType.BaseType.Name;
            }

            string handlerCode = backupCode;

            if (string.IsNullOrEmpty(handlerCode))
            {
                handlerCode = CodeGenerationHelper.GenerateViewModelHandler(selectedType.Name, baseType);
            }
            else
            {
                handlerCode = handlerCode.Replace(": " + selectedType.BaseType.Name, ": " + baseType);
            }
            bool saved = CodeGenerationHelper.SaveScript(handlerScriptPath, handlerCode, false, selectedType.BaseType.Name, baseType);

            if (saved)
            {
                AssetDatabase.Refresh(ImportAssetOptions.Default);
            }
        }