EndsWith









How do I use Ends With
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Form1.cs Copy
212   protected override void OnLoad(System.EventArgs e)
213   {
214    base.OnLoad(e);
215    string sPath = Application.ExecutablePath;
216    sPath = System.IO.Path.GetDirectoryName(sPath);
217
218    if (sPath.EndsWith("\\bin"))
219    {
220     sPath = sPath.Substring(0, sPath.Length - 4);
221    }
222
223    gradeclass.DataModule = new gradeclass(sPath);
224
225   }
File name: ScmlPostProcessor.cs Copy
44             string[] movedFromAssetPaths)
45         {
46             //Reimport everything if the importer itself has been modified or added
47             //.Union(deletedAssets).Union(movedAssets).Union(movedFromAssetPaths)
48             bool shouldReimportAll = importedAssets.Where(s => s.EndsWith(ASSET_PATH)).FirstOrDefault() != null;
49
50             //If we should reimport all SCML files, replace the passed in array with ALL scml project files
51             if(shouldReimportAll)
52             {
53                 Debug.Log("Reimporting all SCML files in project...");
54                 importedAssets = AssetDatabase.GetAllAssetPaths().Where(assetPath => assetPath.EndsWith(".scml")).ToArray();
55             }
56
57             foreach (var path in importedAssets)
58             {
59                 if (!path.EndsWith(".scml"))
60                     continue;
61
62                 ImportScml(path);
63             }
64         }
File name: AssetUtils.cs Copy
35         public static Sprite GetSpriteAtPath(string filePath, string spriteFolder)
36         {
37             Sprite sprite = null;
38
39             if (string.IsNullOrEmpty(spriteFolder))
40             {
41                 var assetPath = AssetDatabase.GetAllAssetPaths().Where(path => path.EndsWith(filePath)).FirstOrDefault();
42                 if (!string.IsNullOrEmpty(assetPath))
43                 {
44                     sprite = (Sprite)AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite));
45                 }
46             }
47             else
48             {
49                 var assetPath = System.IO.Path.Combine(spriteFolder, filePath);
50                 sprite = (Sprite)AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite));
51             }
52             return sprite;
53         }
File name: Tiled2UnityMenuItems.cs Copy
59         private static void DeleteAssetsAt(string dir)
60         {
61             // Note: Does not remove any text files.
62             foreach (string f in Directory.GetFiles(dir))
63             {
64                 if (f.EndsWith(".txt", true, null))
65                     continue;
66
67                 if (f.EndsWith(".meta", true, null))
68                     continue;
69
70                 // Just to be safe. Do not remove scripts.
71                 if (f.EndsWith(".cs", true, null))
72                     continue;
73
74                 AssetDatabase.DeleteAsset(f);
75             }
76         }
File name: TiledAssetPostProcessor.cs Copy
14         private static bool IsTiled2UnityFile(string assetPath)
15         {
16             return UseThisImporter(assetPath) && assetPath.EndsWith(".tiled2unity.xml");
17         }
File name: TiledAssetPostProcessor.cs Copy
19         private static bool IsTiled2UnityTexture(string assetPath)
20         {
21             bool startsWith = assetPath.StartsWith("Assets/Tiled2Unity/Textures/");
22             bool endsWithTxt = assetPath.EndsWith(".txt");
23             return startsWith && !endsWithTxt;
24         }
File name: TiledAssetPostProcessor.cs Copy
26         private static bool IsTiled2UnityWavefrontObj(string assetPath)
27         {
28             bool startsWith = assetPath.StartsWith("Assets/Tiled2Unity/Meshes/");
29             bool endsWith = assetPath.EndsWith(".obj");
30             return startsWith && endsWith;
31         }
File name: TiledAssetPostProcessor.cs Copy
33         private static bool IsTiled2UnityPrefab(string assetPath)
34         {
35             bool startsWith = assetPath.StartsWith("Assets/Tiled2Unity/Prefabs/");
36             bool endsWith = assetPath.EndsWith(".prefab");
37             return startsWith && endsWith;
38         }

EndsWith 137 lượt xem

Gõ tìm kiếm nhanh...