Exemplo n.º 1
0
 private void UpdateKPRPCJSON(EntryConfig _conf)
 {
     // if the config is identical to an empty (default) config, only update if a JSON string already exists
     if (!_conf.Equals(new EntryConfig()) || _strings.GetKeys().Contains("KPRPC JSON"))
     {
         changeAdvancedString("KPRPC JSON", Jayrock.Json.Conversion.JsonConvert.ExportToString(_conf), true);
     }
 }
Exemplo n.º 2
0
        private bool ValidateStringName(string str, out string strResult,
                                        out bool bError)
        {
            strResult = KPRes.FieldNameInvalid;
            bError    = true;

            if (str == null)
            {
                Debug.Assert(false); return(false);
            }

            if (str.Length == 0)
            {
                strResult = KPRes.FieldNamePrompt;
                bError    = false;              // Name not acceptable, but no error
                return(false);
            }

            if (str == m_strStringName)            // Case-sensitive
            {
                strResult = string.Empty;
                bError    = false;
                return(true);
            }

            foreach (string strStd in m_lStdNames)
            {
                if (str.Equals(strStd, StrUtil.CaseIgnoreCmp))
                {
                    return(false);
                }
            }

            if (str.IndexOfAny(m_vInvalidChars) >= 0)
            {
                return(false);
            }

            if (str.Equals(m_strStringName, StrUtil.CaseIgnoreCmp) &&
                !m_vStringDict.Exists(str))
            {
            }                                                   // Just changing case
            else
            {
                foreach (string strExisting in m_vStringDict.GetKeys())
                {
                    if (str.Equals(strExisting, StrUtil.CaseIgnoreCmp))
                    {
                        strResult = KPRes.FieldNameExistsAlready;
                        return(false);
                    }
                }
            }

            strResult = string.Empty;
            bError    = false;
            return(true);
        }
Exemplo n.º 3
0
		public static void NormalizeNewLines(ProtectedStringDictionary dict,
			bool bWindows)
		{
			if(dict == null) { Debug.Assert(false); return; }

			if(m_vNewLineChars == null)
				m_vNewLineChars = new char[]{ '\r', '\n' };

			List<string> vKeys = dict.GetKeys();
			foreach(string strKey in vKeys)
			{
				ProtectedString ps = dict.Get(strKey);
				if(ps == null) { Debug.Assert(false); continue; }

				string strValue = ps.ReadString();
				if(strValue.IndexOfAny(m_vNewLineChars) < 0) continue;

				dict.Set(strKey, new ProtectedString(ps.IsProtected,
					NormalizeNewLines(strValue, bWindows)));
			}
		}
Exemplo n.º 4
0
		public static void NormalizeNewLines(ProtectedStringDictionary dict,
			bool bWindows)
		{
			if(dict == null) { Debug.Assert(false); return; }

			if(m_vNewLineChars == null)
				m_vNewLineChars = new char[]{ '\r', '\n' };

			List<string> vKeys = dict.GetKeys();
			foreach(string strKey in vKeys)
			{
				ProtectedString ps = dict.Get(strKey);
				if(ps == null) { Debug.Assert(false); continue; }

				string strValue = ps.ReadString();
				if(strValue.IndexOfAny(m_vNewLineChars) < 0) continue;

				dict.Set(strKey, new ProtectedString(ps.IsProtected,
					NormalizeNewLines(strValue, bWindows)));
			}
		}