/// <summary> /// Set for the UserDefined cultureCode a new text matching a stringCode. /// </summary> /// <param name="stringCode"></param> /// <param name="text"></param> /// <returns></returns> public bool SetUserDefinedTranslatedText(StringCode stringCode, string text) { if (string.IsNullOrWhiteSpace(text)) { return(false); } TranslatedTextPage page = null; // get the page of the default cultureCode if (!_dictTextTranslatedPage.ContainsKey(CultureCode.UserDefined)) { // the culture code does not exists! return(false); } page = _dictTextTranslatedPage[CultureCode.UserDefined]; // now get the translated text matching the code TranslatedText translatedText = page.FindTranslatedTextByStringCode(stringCode); // the translated not yet exists, create it if (translatedText == null) { page.Add(stringCode, text); return(true); } // exists, set the new text translatedText.ReplaceText(text); return(true); }
// now get the translated text matching the code public TranslatedText FindTranslatedTextByStringCode(StringCode code) { // if exists, bye if (!_dictTranslatedText.ContainsKey(code)) { return(null); } return(_dictTranslatedText[code]); }
public bool Add(StringCode stringCode, string text) { // if exists, bye if (_dictTranslatedText.ContainsKey(stringCode)) { return(false); } TranslatedText translatedText = new TranslatedText(stringCode, text); _dictTranslatedText.Add(stringCode, translatedText); return(true); }
/// <summary> /// 获得字符定义 /// </summary> /// <param name="define">定义</param> /// <returns></returns> private string GetResource(StringCode code, Language language) { var item = from model in this.stringDB.AsEnumerable() where model.Field <string>("StringCode") == code.ToString() select model.Field <string>(language.ToString()); string result = string.Empty; if (item.Count() > 0) { result = item.First(); } else { result = CommonHelper.GetEnumDescription(code.GetType(), code); } return(result); }
public bool AddOrReplace(StringCode stringCode, string text) { TranslatedText translatedText = null; // if not exists, create it if (_dictTranslatedText.ContainsKey(stringCode)) { translatedText = _dictTranslatedText[stringCode]; } else { translatedText = new TranslatedText(stringCode, text); return(true); } // replace just the text translatedText.ReplaceText(text); return(true); }
public void AddMessage(MsgLevel level, StringCode code, int module = -1, params object[] param) { string str = this.GetResource(code, Language); if (param != null) { str = string.Format(str, param); } HostarLogBean bean = new HostarLogBean(level, str, module); if (bean.LogLevel >= MsgLevel.Warn) { lock (this.ErrLock) { this.msgQueue.Enqueue(bean); } } else { this.msgQueue.Enqueue(bean); } }
/// <summary> /// get the text translation of the string code in the current culture. /// If the code is not translated, return an empty string. /// </summary> /// <param name="code"></param> /// <returns></returns> public string GetTranslation(StringCode code) { TranslatedTextPage page = null; // get the page of the default cultureCode if (!_dictTextTranslatedPage.ContainsKey(_cultureCode)) { // the culture code does not exists! return("(null)"); } page = _dictTextTranslatedPage[_cultureCode]; // now get the translated text matching the code TranslatedText translatedText = page.FindTranslatedTextByStringCode(code); if (translatedText == null) { return("(null)"); } return(translatedText.Text); }
/// <summary> /// Set for the UserDefined cultureCode a new text matching a stringCode. /// </summary> /// <param name="stringCode"></param> /// <param name="text"></param> /// <returns></returns> public bool SetUserDefinedTranslatedText(StringCode stringCode, string text) { return(_coreSystem.TranslationMgr.SetUserDefinedTranslatedText(stringCode, text)); }
private Method CreateMethodFromCustomActivity(CustomActivityCode entity) { var result = new Method { AccessModifier = "private", Name = entity.Name, ReturnType = entity.ReturnType, Parameters = new List <MethodParameter>(), Sequence = new Sequence() }; var objectName = "entity"; result.Sequence.Values.Add(new AssignCode { To = $"var {objectName}", Value = $"new {entity.Name}()" }); var finallyBlock = new Sequence(); foreach (CustomMethodAssignCode assign in entity.Assigns) { result.Parameters.AddRange(fieldManager.GetUsingVariables(assign.Value) .Select(x => new MethodParameter { Variable = x, Direction = assign.Direction })); result.Sequence.Values.Add(new AssignCode { To = $"{objectName}.{assign.To}", Value = assign.Value }); if (assign.Direction == ParameterDirection.InOut || assign.Direction == ParameterDirection.Out) { finallyBlock.Values.Add(new AssignCode { To = assign.Value, Value = $"{objectName}.{assign.To}" }); } } for (var i = result.Parameters.Count - 1; i >= 0; i--) { MethodParameter parameter = result.Parameters[i]; if (result.Parameters.Where(x => x.Variable.Name == parameter.Variable.Name).Count() > 1) { result.Parameters.RemoveAt(i); } } var executeLine = $"{objectName}.Execute()"; if (entity.ReturnType != "void") { executeLine = "return " + executeLine; } var executeStringCode = new StringCode { Value = executeLine }; if (finallyBlock.Values.Count > 0) { var tryFinally = new TryCatchCode { Try = new StringCode { Value = executeLine }.WrapInSequence(), Catches = new List <CatchCode>(), Finally = finallyBlock }; result.Sequence.Values.Add(tryFinally); } else { result.Sequence.Values.Add(executeStringCode); } entity.Method = result; return(result); }
public TranslatedText(StringCode stringCode, string text) { StringCode = stringCode; Text = text; }
public StringCodeVM(StringCode stringCode) { StringCode = stringCode; }