public STM32SampleRelocator() { /* * Known problems with trying to map frameworks: * HAL: * Much longer build times * LL-only samples don't provide cfg files for HAL * HAL-only samples don't provide stm32_assert.h needed by LL * lwIP: * Different SDKs have slightly different file layouts * Some samples don't provide sys_xxx() functions */ AutoDetectedFrameworks = new AutoDetectedFramework[] {/* * new AutoDetectedFramework {FrameworkID = "com.sysprogs.arm.stm32.hal", * FileRegex = new Regex(@"\$\$SYS:VSAMPLE_DIR\$\$/[^/\\]+/Drivers/[^/\\]+_HAL_Driver", RegexOptions.Compiled | RegexOptions.IgnoreCase), * DisableTriggerRegex = new Regex(@"_ll_[^/\\]+\.c", RegexOptions.Compiled | RegexOptions.IgnoreCase), * Configuration = new Dictionary<string, string>() } */ /*new AutoDetectedFramework {FrameworkID = "com.sysprogs.arm.stm32.LwIP", * FileRegex = new Regex(@"\$\$SYS:VSAMPLE_DIR\$\$/[^/\\]+/Middlewares/Third_Party/LwIP", RegexOptions.Compiled | RegexOptions.IgnoreCase), * DisableTriggerRegex = new Regex(@"^$", RegexOptions.Compiled | RegexOptions.IgnoreCase), * Configuration = new Dictionary<string, string>() }*/ }; AutoPathMappings = new PathMapping[] { new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Drivers/STM32[^/\\]+xx_HAL_Driver/(.*)", "$$SYS:BSP_ROOT$$/STM32{1}xxxx/STM32{1}xx_HAL_Driver/{2}"), new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Drivers/CMSIS/(.*)", "$$SYS:BSP_ROOT$$/STM32{1}xxxx/CMSIS_HAL/{2}"), new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Middlewares/ST/STM32_USB_(Host|Device)_Library/(.*)", "$$SYS:BSP_ROOT$$/STM32_USB_{2}_Library/{3}"), new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Middlewares/Third_Party/(FreeRTOS)/(.*)", "$$SYS:BSP_ROOT$$/{2}/{3}"), }; }
public virtual bool LoadText(string path, ref string content) { if (!PathMapping.GetInstance().DecodePath(ref path)) { var temp = Resources.Load <TextAsset>(path); if (temp == null) { #if UNITY_EDITOR Debug.Log(string.Format("Can't Find {0} ", path)); #endif return(false); } content = temp.text; } else { if (!File.Exists(path)) { return(false); } content = File.ReadAllText(path); } return(true); }
public Esp32SampleRelocator() { AutoDetectedFrameworks = new AutoDetectedFramework[0]; AutoPathMappings = new PathMapping[] { }; }
public NordicSampleRelocator() { AutoDetectedFrameworks = new AutoDetectedFramework[0]; AutoPathMappings = new PathMapping[] { new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/(components|config|external)/(.*)", "$$SYS:BSP_ROOT$$/nRF5x/{1}/{2}"), }; }
/// <summary> /// 从本地删除配置 /// </summary> /// <param name="path"></param> public virtual bool DeleteFromDisk(string path) { path = PathMapping.GetInstance().DecodePath(path); if (File.Exists(path)) File.Delete(path); return true; }
public NordicSampleRelocator(ReverseConditionTable optionalConditionTableForFrameworkMapping) : base(optionalConditionTableForFrameworkMapping) { AutoDetectedFrameworks = new AutoDetectedFramework[0]; AutoPathMappings = new PathMapping[] { new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/(components|config|external|integration|modules)/(.*)", "$$SYS:BSP_ROOT$$/nRF5x/{1}/{2}"), }; }
public override void Initialize() { base.Initialize(); SetConfigType(new CodeGenConfig()); string path = PathMapping.GetInstance().DecodePath("{EDITOR}/CTS/EditorClassTemplate.unityjson"); // Build In 编辑器路径一律写死 if (File.Exists(path)) { templateFile = File.ReadAllText(path); } }
public static T LoadEditorResource <T>(string file_name_with_extension) where T : UnityEngine.Object { // string path = string.Format("{0}/EditorResources/", PathMapping.GetSmartDataViewEditorPath()); string path = PathMapping.GetInstance().DecodePath("{EDITOR}/EditorResources/"); path = PathMapping.PathCombine(path, file_name_with_extension); var splitIndex = path.IndexOf("Assets/"); path = path.Substring(splitIndex); return(AssetDatabase.LoadAssetAtPath <T>(path)); }
public void GetFileEndWithOverRequest() { var context = CreateContext(); string path = PathMapping.Map(TestFilePath); context.SendFile(path, 10, 400) .Wait(); context.Response.Body.Position = 0; context.Response.Body.ReadAll() .ShouldEqual("test. This is simply a test. (Save with ASCII codepage)"); context.Response.Headers.ContentLength.ShouldEqual(55); }
public virtual bool SaveText(string path, string content) { DeleteFromDisk(path); path = PathMapping.GetInstance().DecodePath(path); var dir = Path.GetDirectoryName(path); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); File.WriteAllText(path, content); return true; }
public void GetFileStart() { var context = CreateContext(); string path = PathMapping.Map(TestFilePath); context.SendFile(path, 0, 20) .Wait(); context.Response.Body.Position = 0; context.Response.Body.ReadAll() .ShouldEqual("This is a test. This"); context.Response.Headers.ContentLength.ShouldEqual(20); }
/// <summary> /// 加载配置(静态) /// </summary> /// <param name="path"></param> /// <typeparam name="V"></typeparam> /// <returns></returns> public V LoadConfig <V>(string path) where V : new() { path = PathMapping.GetInstance().DecodePath(path); byte[] byteArray = File.ReadAllBytes(path); if (byteArray.Length == 0) { return(new V()); } using (var ms = new MemoryStream(byteArray)) { return(Serializer.Deserialize <V>(ms)); } }
public object LoadConfig(Type t, string path) { path = PathMapping.GetInstance().DecodePath(path); byte[] byteArray = File.ReadAllBytes(path); if (byteArray.Length == 0) { return(null); } using (var ms = new MemoryStream(byteArray)) { return(Serializer.Deserialize(t, ms)); } }
/// <summary> /// 保存配置到本地 /// </summary> /// <param name="path"></param> public bool SaveToDisk(string path, object target) { path = PathMapping.GetInstance().DecodePath(path); DeleteFromDisk(path); MemoryStream memoryStream = new MemoryStream(); Serializer.Serialize(memoryStream, target); var array = new byte[memoryStream.Length]; memoryStream.Position = 0L; memoryStream.Read(array, 0, array.Length); File.WriteAllBytes(path, array); return(true); }
/// <summary> /// 保存配置到本地 /// </summary> /// <param name="path"></param> public bool SaveToDisk(string path, object target) { path = PathMapping.GetInstance().DecodePath(path); byte[] bytes = null; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, target); bytes = new byte[ms.Position]; var fullBytes = ms.GetBuffer(); Array.Copy(fullBytes, bytes, bytes.Length); } DeleteFromDisk(path); File.WriteAllBytes(path, bytes); return(true); }
protected override void RenderExtensionButton(CodeGen item) { string error = VerfiyLineData(item, false); if (string.IsNullOrEmpty(error)) { string export_path = PathMapping.GetInstance().DecodePath(item.CodeExportPath); if (!Directory.Exists(export_path)) { Directory.CreateDirectory(export_path); } //检测代码是否已存在 string path = Path.Combine(export_path, string.Format("{0}Export.cs", item.ClassType)); string disPlay = Language.Build; if (File.Exists(path)) { GUI.color = Color.green; disPlay = Language.ReBuild; } if (GUILayout.Button(disPlay, new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith) })) { WriteFile(item, path); } GUI.color = Color.white; } else { if (GUILayout.Button(EditorGUIStyle.LoadEditorResource <Texture2D>("warning.png"), new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith), GUILayout.Height(18) })) { ShowNotification(new GUIContent(error)); } } }
/// <summary> /// Add resources in a folder and it's sub folder /// </summary> /// <param name="path"></param> /// <param name="assembly"></param> /// <param name="rootNameSpace"></param> /// <remarks> /// <para>This method is not going to map files but keep the mapping and /// try to look up views every time they are requested. This is the method /// to use to add a resource folder that has sub folders. /// </para> /// </remarks> public void AddPath(string path, Assembly assembly, string rootNameSpace) { var mapping = new PathMapping { Assembly = assembly, UriPath = path.ToLower(), RootNameSpace = rootNameSpace }; _pathMappings.Add(mapping); // We need to create a resource index since resource loading // is case sensitive and paths supplied by web client will probably not have // the correct case. foreach (var resourceName in assembly.GetManifestResourceNames()) { if (!resourceName.StartsWith(rootNameSpace)) { continue; } mapping.Resources.Add(resourceName); } }
/// <summary> /// Add resources in a folder and it's sub folder /// </summary> /// <param name="path"></param> /// <param name="assembly"></param> /// <param name="rootNameSpace"></param> /// <remarks> /// <para>This method is not going to map files but keep the mapping and /// try to look up views every time they are requested. This is the method /// to use to add a resource folder that has sub folders. /// </para> /// </remarks> public void AddPath(string path, Assembly assembly, string rootNameSpace) { var mapping = new PathMapping { Assembly = assembly, UriPath = path.ToLower(), RootNameSpace = rootNameSpace }; _pathMappings.Add(mapping); // We need to create a resource index since resource loading // is case sensitive and paths supplied by web client will probably not have // the correct case. foreach (var resourceName in assembly.GetManifestResourceNames()) { if (!resourceName.StartsWith(rootNameSpace)) continue; mapping.Resources.Add(resourceName); } }
public STM32SampleRelocator() { /* Known problems with trying to map frameworks: HAL: * Much longer build times * LL-only samples don't provide cfg files for HAL * HAL-only samples don't provide stm32_assert.h needed by LL lwIP: * Different SDKs have slightly different file layouts * Some samples don't provide sys_xxx() functions */ AutoDetectedFrameworks = new AutoDetectedFramework[] {/* new AutoDetectedFramework {FrameworkID = "com.sysprogs.arm.stm32.hal", FileRegex = new Regex(@"\$\$SYS:VSAMPLE_DIR\$\$/[^/\\]+/Drivers/[^/\\]+_HAL_Driver", RegexOptions.Compiled | RegexOptions.IgnoreCase), DisableTriggerRegex = new Regex(@"_ll_[^/\\]+\.c", RegexOptions.Compiled | RegexOptions.IgnoreCase), Configuration = new Dictionary<string, string>() } */ /*new AutoDetectedFramework {FrameworkID = "com.sysprogs.arm.stm32.LwIP", FileRegex = new Regex(@"\$\$SYS:VSAMPLE_DIR\$\$/[^/\\]+/Middlewares/Third_Party/LwIP", RegexOptions.Compiled | RegexOptions.IgnoreCase), DisableTriggerRegex = new Regex(@"^$", RegexOptions.Compiled | RegexOptions.IgnoreCase), Configuration = new Dictionary<string, string>() }*/ }; AutoPathMappings = new PathMapping[] { new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Drivers/STM32[^/\\]+xx_HAL_Driver/(.*)", "$$SYS:BSP_ROOT$$/STM32{1}xxxx/STM32{1}xx_HAL_Driver/{2}"), new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Drivers/CMSIS/(.*)", "$$SYS:BSP_ROOT$$/STM32{1}xxxx/CMSIS_HAL/{2}"), new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Middlewares/ST/STM32_USB_(Host|Device)_Library/(.*)", "$$SYS:BSP_ROOT$$/STM32_USB_{2}_Library/{3}"), new PathMapping(@"\$\$SYS:VSAMPLE_DIR\$\$/STM32Cube_FW_([^_]+)_[^/\\]+/Middlewares/Third_Party/(FreeRTOS)/(.*)", "$$SYS:BSP_ROOT$$/{2}/{3}"), }; }
/// <summary> /// Add resources in a folder and it's sub folder /// </summary> /// <param name="path"></param> /// <param name="assembly"></param> /// <param name="rootNameSpace"></param> /// <remarks> /// <para>This method is not going to map files but keep the mapping and /// try to look up views every time they are requested. This is the method /// to use to add a resource folder that has sub folders. /// </para> /// </remarks> public void AddPath(string path, Assembly assembly, string rootNameSpace) { var mapping = new PathMapping { Assembly = assembly, UriPath = path.ToLower(), RootNameSpace = rootNameSpace }; _pathMappings.Add(mapping); foreach (var resourceName in assembly.GetManifestResourceNames()) { if (!resourceName.StartsWith(rootNameSpace)) continue; mapping.Resources.Add(resourceName); } }
public void TestFilesExist(PathMapping mapping) { Assert.True(File.Exists(mapping.FileName)); }