// String array public static bool DataINIReadWrite(this IniData _Data, string _Section, string _Key, ref List <string> _Value, bool _Write = true, string _Separator = ",") { IniData data = _Data; bool status = false; string value = HEVText.ToString(_Value, _Separator); string dataValue = data[_Section][_Key]; if (!HEVText.Validate(dataValue)) { if (value == "" && dataValue == "") { status = true; } else { if (_Write) { data[_Section][_Key] = value; } status = false; } } else { value = dataValue; status = true; } _Data = data; _Value = HEVText.ToStringList(value, _Separator, true); return(status); }
// String public static bool DataINIReadWrite(this IniData _Data, string _Section, string _Key, ref string _Value, bool _Write = true) { IniData data = _Data; bool status = false; string value = _Value; string dataValue = data[_Section][_Key]; if (!HEVText.Validate(dataValue)) { if (value == "" && dataValue == "") { status = true; } else { if (_Write) { data[_Section][_Key] = value; } status = false; } } else { value = dataValue; status = true; } _Data = data; _Value = value; return(status); }
public static (IniData, bool) INIRead(string _String) { if (!HEVText.Validate(_String)) { HEVConsole.Print("INIRead() Empty string.", EPrintType.eError); return(null, false); } bool status = false; FileIniDataParser parser = new FileIniDataParser(); parser.Parser.Configuration.ThrowExceptionsOnError = true; IniData data = null; try { data = parser.Parser.Parse(_String); status = true; } catch { status = false; } if (!status) { HEVConsole.Print("INIRead() Parser to data.", EPrintType.eError); return(null, false); } return(data, true); }
public static (List <T>, bool) JSONReadClassList <T>(string _String) where T : class, new() { if (!typeof(T).IsClass) { throw new ArgumentException("Error - JSONReadClassList() must have a valid class."); } List <T> localClass = new List <T>(); string fileText = _String; bool status = false; if (!HEVText.Validate(_String)) { HEVConsole.Print("JSONReadClassList() Empty string.", EPrintType.eWarning); return(localClass, false); } status = fileText.JSONParseClassTry <List <T> >(out localClass); return(localClass, status); }
private void InitMutex(string _CustomID) { #if MUTEX_ENABLED //( (GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes( typeof( GuidAttribute ), false ).GetValue( 0 ) ).Value; string appGuid = HEVIO.AssemblyGuidCurrent(); string mutexId = string.Format("Global\\{{{0}}}", appGuid); if (HEVText.Validate(_CustomID)) { mutexId = _CustomID; } mutex = new Mutex(false, mutexId); var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); var securitySettings = new MutexSecurity(); securitySettings.AddAccessRule(allowEveryoneRule); mutex.SetAccessControl(securitySettings); #endif }
public static (string[], bool) FileTextReadStringArray(string _URL, int _StartLine = 0, int _EndLine = -1) { string[] lines = null; bool status = false; if (!FileValidate(_URL)) { return(lines, false); } if (!HEVText.Validate(System.IO.File.ReadAllText(_URL))) { HEVConsole.Print("FileTextRead() Invalid URL " + _URL, EPrintType.eWarning); lines = new string[] { "Empty" }; return(lines, false); } lines = System.IO.File.ReadAllLines(_URL); (lines, status) = HEVText.GetStringArrayLines(lines, _StartLine, _EndLine); if (!status) { return(lines, false); } return(lines, true); }