12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Runtime.Serialization;
- using System.Text;
- using System.Threading.Tasks;
- using static Venus_Core.NiceRobotAction;
- namespace Venus_MainPages.Unity
- {
- public static class CommonFunction
- {
- //internal T
- public static T GetValue<T>(Dictionary<string, object> RtDataValues, string str)
- {
- if (RtDataValues==null)
- {
- return default(T);
- }
- if (RtDataValues.Keys.Contains(str))
- {
- try
- {
- if(RtDataValues[str]!=null)
- return (T)Convert.ChangeType(RtDataValues[str], typeof(T));
- else
- {
- return default(T);
- }
-
- }
- catch
- {
- return default(T);
- }
- }
- else
- {
- return default(T);
- }
- }
- public static IEnumerable<string> GetFilesNames(string path)
- {
- if (Directory.Exists(path))
- {
- return Directory.GetFiles(path, "*.rcp")?
- .Select(Path.GetFileNameWithoutExtension);
- }
- else
- {
- return new List<string>();
- }
- }
- public static T ToEnum<T>(this string value,out bool isParseOK) where T : struct
- {
- T result;
- if (Enum.TryParse<T>(value, true, out result))
- {
- isParseOK = true;
- return result;
- }
- else
- {
- isParseOK = false;
- return default(T);
- }
- }
- }
- }
|