Beispiel #1
0
        private void UploadFileButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PDFNameListBox.Items.Clear();

                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Multiselect = true;
                openFileDialog.ShowDialog();

                foreach (var item in openFileDialog.FileNames)
                {
                    var         fileName    = Path.GetFileNameWithoutExtension(item);
                    RadioButton radioButton = new RadioButton
                    {
                        Content = fileName,
                    };
                    PDFNameListBox.Items.Add(radioButton);
                    _pdf.Add(fileName, item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error occured: {ex.Message}");
            }
        }
        private static void WriteDiagnosticResults(ImmutableArray <Tuple <ProjectId, Diagnostic> > diagnostics, string fileName)
        {
            var orderedDiagnostics =
                diagnostics
                .OrderBy(i => i.Item2.Id)
                .ThenBy(i => i.Item2.Location.SourceTree?.FilePath, StringComparer.OrdinalIgnoreCase)
                .ThenBy(i => i.Item2.Location.SourceSpan.Start)
                .ThenBy(i => i.Item2.Location.SourceSpan.End);

            var           uniqueLines    = new HashSet <string>();
            StringBuilder completeOutput = new StringBuilder();
            StringBuilder uniqueOutput   = new StringBuilder();

            foreach (var diagnostic in orderedDiagnostics)
            {
                string message       = diagnostic.Item2.ToString();
                string uniqueMessage = $"{diagnostic.Item1}: {diagnostic.Item2}";
                completeOutput.AppendLine(message);
                if (uniqueLines.Add(uniqueMessage))
                {
                    uniqueOutput.AppendLine(message);
                }
            }

            string directoryName            = Path.GetDirectoryName(fileName);
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
            string extension      = Path.GetExtension(fileName);
            string uniqueFileName = Path.Combine(directoryName, $"{fileNameWithoutExtension}-Unique{extension}");

            File.WriteAllText(fileName, completeOutput.ToString(), Encoding.UTF8);
            File.WriteAllText(uniqueFileName, uniqueOutput.ToString(), Encoding.UTF8);
        }
        static int IdFromTitle(string title, Type resourceType, string defType, Resources resource, string packageName)
        {
            int id = 0;

            if (title == null)
            {
                return(id);
            }

            string name = Path.GetFileNameWithoutExtension(title);

            id = GetId(resourceType, name);

            if (id > 0)
            {
                return(id);
            }

            if (packageName != null)
            {
                id = resource.GetIdentifier(name, defType, packageName);

                if (id > 0)
                {
                    return(id);
                }
            }

            id = resource.GetIdentifier(name, defType, null);

            return(id);
        }
Beispiel #4
0
        void OnFocus()
        {
            //Check what graphs are available.
            GraphPaths = GraphEditorUtils.GetAllGraphsInProject();
            Func <string, GUIContent> selector = (s => new GUIContent(Path.GetFileNameWithoutExtension(s), s));

            graphSelections = GraphPaths.Select(selector).ToArray();

            //Keep the same graph selected even when the list of graphs changes.
            selectedGraph = GraphPaths.IndexOf((graph == null ? "" : graph.FilePath));


            //If this graph was deleted, reset the editor.
            if (selectedGraph == -1)
            {
                unsavedStr = "";

                graph = null;

                reconnectingOutput      = -1;
                reconnectingInput       = -2;
                reconnectingInput_Index = 0;

                activeWindowID = -1;
            }

            NewNodeOptions = NodeOptionsGenerator.GenerateList();
        }
 private void SaveFileButton_Click(object sender, RoutedEventArgs e)
 {
     _saveFileDialog.ShowDialog();
     _destination = _saveFileDialog.FileName;
     _fileName    = Path.GetFileNameWithoutExtension(_saveFileDialog.FileName);
     Close();
 }
Beispiel #6
0
        private void SetIcon(Abstractions.IconEntry view)
        {
            if (!string.IsNullOrEmpty(view.Icon))
            {
                //var resId = Resources.GetIdentifier(view.Icon,"drawable", PackageName)
                //var resId = (int)typeof(Resource.Drawable).GetField(Path.GetFileNameWithoutExtension(view.Icon)).GetValue(null);

                try
                {
                    //Context context => CrossCurrentActivity.Current.Activity;

                    var context = App.Application.Context;
                    var resId   = context.Resources.GetIdentifier(Path.GetFileNameWithoutExtension(view.Icon), "drawable", context.PackageName);
                    if (resId != 0)
                    {
                        Control.SetCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            else
            {
                Control.SetCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
            }
        }
        private void MemoryPictureList_OnSequentialSelected(object sender, List <MemoryPictureItem> selectedItems)
        {
            try
            {
                //记录顺序测试结果
                var memorizedPictureList = GetLastThreeMemorizedPictures();
                for (int i = 0; i < 3; i++)
                {
                    var memorizedPicture           = memorizedPictureList[i];
                    var sequentialTestingClickInfo = _currentTestRecordInfo.SequentialTestingClickInfos[i];

                    var memorizedPictureName = Path.GetFileNameWithoutExtension(memorizedPicture.PictureItem.ImageUri);
                    sequentialTestingClickInfo.IsRight = sequentialTestingClickInfo.PictureName == memorizedPictureName;
                }

                ResetMemoryPictureListStatus();
                StartLocationMemoryTesting();
                CurrentStateTextBlock.Text       = "记忆还原-位置";
                CurrentStateDetailTextBlock.Text = "判断该位置是否与学习阶段相同,是选勾,否选叉";
            }
            catch (Exception e)
            {
                LogHelper.LogInfo($"{e.Message}from{nameof(MemoryPictureList_OnSequentialSelected)}\r\n{e.StackTrace}");
            }
        }
Beispiel #8
0
        private void OpenMovie_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter           = "Movie files (mkv, mp4, ogv, avi, wmv)|*.mkv; *.mp4; *.ogv; *.avi; *.wmv|All files (*.*)|*.*",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)
            };

            if (openFileDialog.ShowDialog() == true)
            {
                searchName.IsEnabled = true;
                search.IsEnabled     = true;
                writeTags.IsEnabled  = true;

                fileName = openFileDialog.FileName;

                string movieRegex = @"([ .\w']+?)(\W\d{4}\W?.*)";
                string movieName  = Path.GetFileNameWithoutExtension(fileName);
                Match  match      = Regex.Match(movieName, movieRegex);

                if (match.Success)
                {
                    movieName = match.Groups[1].Value.Replace(@".", " ");
                }

                searchName.Text = movieName;

                // Clear previous search results
                searchResults.Items.Clear();
                writeTags.IsEnabled = false;

                lblStatus.Text   = "Check movie name and press search.";
                lblFileName.Text = fileName;
            }
        }
Beispiel #9
0
        protected bool CheckIfCurrentSolutionHasReferenceToAcumatica()
        {
            if (Workspace?.CurrentSolution == null)
            {
                return(false);
            }

            bool hasAcumaticaProjectsInSolution =
                Workspace.CurrentSolution.Projects.Any(project => IsAcumaticaAssemblyName(project.Name) ||
                                                       IsAcumaticaAssemblyName(project.AssemblyName));

            if (hasAcumaticaProjectsInSolution)
            {
                return(true);
            }

            bool hasMetadataRefs = (from project in Workspace.CurrentSolution.Projects
                                    from reference in project.MetadataReferences
                                    select Path.GetFileNameWithoutExtension(reference.Display))
                                   .Any(reference => IsAcumaticaAssemblyName(reference));

            return(hasMetadataRefs);

            //*********************************************************************************************************************************
            bool IsAcumaticaAssemblyName(string dllName) => ColoringConstants.PlatformDllName == dllName ||
            ColoringConstants.AppDllName == dllName;
        }
Beispiel #10
0
        public static BuildReference ByName(string name, bool copyLocal = false)
        {
#if NET46
            var assembly = Assembly.Load(name);
            return(new BuildReference(
                       new[] { MetadataReference.CreateFromFile(assembly.Location) },
                       copyLocal,
                       new Uri(assembly.CodeBase).LocalPath));
#elif NETSTANDARD1_6 || NETCOREAPP2_0
            var references = Enumerable.ToList(
                from l in DependencyContext.Default.CompileLibraries
                from r in l.ResolveReferencePaths()
                where IOPath.GetFileNameWithoutExtension(r) == name
                select MetadataReference.CreateFromFile(r));
            if (references.Count == 0)
            {
                throw new InvalidOperationException(
                          $"Assembly '{name}' not found.");
            }

            return(new BuildReference(
                       references,
                       copyLocal));
#else
#error target frameworks need to be updated.
#endif
        }
Beispiel #11
0
        public static string[] CloneMaps(int numCopies, string mxdPath)
        {
            List <string> maps     = new List <string>();
            string        testPath = Path.Combine(Path.GetDirectoryName(mxdPath), "TestMaps");

            if (System.IO.Directory.Exists(testPath))
            {
                System.IO.Directory.Delete(testPath, true);
            }

            IMapDocument srcMap = new MapDocumentClass();

            srcMap.Open(mxdPath);
            srcMap.Save(false);
            Marshal.FinalReleaseComObject(srcMap);

            System.IO.Directory.CreateDirectory(testPath);
            for (int i = 0; i < numCopies; i++)
            {
                const string fmt     = "_{0:0000}.mxd";
                string       mapName = Path.GetFileNameWithoutExtension(mxdPath) + string.Format(fmt, i + 1);
                string       mapPath = Path.Combine(testPath, mapName);
                System.IO.File.Copy(mxdPath, mapPath);
                maps.Add(mapPath);
            }

            return(maps.ToArray());
        }
        private void PrepareRename(Component component)
        {
            try
            {
                // Get file info
                string filePath    = component.FullFileName;
                string fileName    = Path.GetFileNameWithoutExtension(filePath);
                string extention   = Path.GetExtension(filePath);
                string partNumber  = component.PartNumber;
                string description = component.Description;
                string directory   = Path.GetDirectoryName(filePath);

                if (description != string.Empty)
                {
                    description = " " + description;
                }
                // Check whether the PartNumber+Description = filename
                string newFileName = partNumber + description;
                Library.CheckFileName(ref newFileName);
                if (fileName == newFileName)
                {
                    return;
                }
                else
                {
                    // Replace the references
                    ReplaceCheck(System.IO.Path.Combine(directory, fileName + extention), System.IO.Path.Combine(directory, newFileName + extention));
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name, MessageBoxButton.OK);
            }
        }
 private void CopyFromSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     CopyTo.Text = Path.Combine(
         Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
         Path.GetFileNameWithoutExtension((string)e.AddedItems[0])
         );
 }
Beispiel #14
0
            protected async Task <string> FindAvailableNumberedFileNameAsync(string desiredName)
            {
                var fileNameExtension        = IOPath.GetExtension(desiredName) ?? string.Empty;
                var fileNameWithoutExtension = IOPath.GetFileNameWithoutExtension(desiredName);

                return(await StorageItemNameGenerator.FindAvailableNumberedNameAsync(desiredName, Owner, number => $"{fileNameWithoutExtension} ({number}){fileNameExtension}"));
            }
        /// <summary>
        /// Constructs a file dictionary from the given path.
        /// </summary>
        /// <param name="path">The path to the data.</param>
        /// <param name="typeOfStore">The type T of <see cref="VirtualFile<T>" /> that was created.</param>
        /// <returns>The constructed <see cref="VirtualFile<T>" /> </returns>
        private VirtualFile CreateFileFromPath(string path, out Type typeOfStore)
        {
            // In order to construct a generic type from a Type variable, reflection
            // is needed.
            string unqualifiedTypeName = P.GetFileNameWithoutExtension(path);

            // Certain Unity data types don't play nice with serialization, so we
            // need to check for them explicitly.
            typeOfStore = DecideType(unqualifiedTypeName);

            // Get the "Base" generic type.
            Type baseType = typeof(VirtualFile <>);

            // Construct the concrete type using the type of data stored and the
            // base generic type.
            Type constructed = baseType.MakeGenericType(new Type[] { typeOfStore });

            // Create an instance of the concrete type equivalent to
            // calling new File<T>().
            VirtualFile file = (VirtualFile)Activator.CreateInstance(constructed);

            // Unfortunately, this method requires an empty constructor, so path
            // needs to be set separately.
            file.Path = path;

            return(file);
        }
Beispiel #16
0
        ICommandOutput SetupEnvironmentForAdd()
        {
            var directory = HostEnvironment.CurrentDirectory;

            var fromDirectory = string.IsNullOrEmpty(From) ? null : FileSystem.GetDirectory(From);

            if (fromDirectory != null && fromDirectory.Exists)
            {
                if (SysPath.GetExtension(Name).EqualsNoCase(".wrap") &&
                    SysPath.IsPathRooted(Name) &&
                    FileSystem.GetDirectory(SysPath.GetDirectoryName(Name)) != fromDirectory)
                {
                    return(new Error("You provided both -From and -Name, but -Name is a path. Try removing the -From parameter."));
                }
                directory = fromDirectory;
                _userSpecifiedRepository = new FolderRepository(directory, FolderRepositoryOptions.Default);
            }


            if (SysPath.GetExtension(Name).EqualsNoCase(".wrap") && directory.GetFile(SysPath.GetFileName(Name)).Exists)
            {
                var originalName = Name;
                Name    = PackageNameUtility.GetName(SysPath.GetFileNameWithoutExtension(Name));
                Version = PackageNameUtility.GetVersion(SysPath.GetFileNameWithoutExtension(originalName)).ToString();

                return(new Warning("The requested package contained '.wrap' in the name. Assuming you pointed to a file name and meant a package named '{0}' with version qualifier '{1}'.",
                                   Name,
                                   Version));
            }
            return(null);
        }
Beispiel #17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Cleans the name of the project given the project type. (e.g. For an XML type, this
        /// will ensure that the name is rooted and ends with the correct extension)
        /// </summary>
        /// <param name="type">The type of the project.</param>
        /// <param name="name">The name of the project.</param>
        /// <returns>The cleaned up name with the appropriate extension</returns>
        /// ------------------------------------------------------------------------------------
        private static string CleanUpNameForType(BackendProviderType type, string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            string ext;

            switch (type)
            {
            case BackendProviderType.kXML:
                ext = LcmFileHelper.ksFwDataXmlFileExtension;
                break;

            default:
                return(name);
            }

            if (!SysPath.IsPathRooted(name))
            {
                string sProjName = (SysPath.GetExtension(name) == ext) ? SysPath.GetFileNameWithoutExtension(name) : name;
                name = SysPath.Combine(SysPath.Combine(FwDirectoryFinder.ProjectsDirectory, sProjName), name);
            }
            // If the file doesn't have the expected extension and exists with the extension or
            // does not exist without it, we add the expected extension.
            if (SysPath.GetExtension(name) != ext && (FileUtils.SimilarFileExists(name + ext) || !FileUtils.SimilarFileExists(name)))
            {
                name += ext;
            }
            return(name);
        }
Beispiel #18
0
        internal static int IdFromTitle(string title, Type type)
        {
            string name = Path.GetFileNameWithoutExtension(title);
            int    id   = GetId(type, name);

            return(id);            // Resources.System.GetDrawable (Resource.Drawable.dashboard);
        }
Beispiel #19
0
            private IContentType SniffContentType(ITextBuffer diskBuffer)
            {
                // try and sniff the content type from a double extension, and if we can't
                // do that then default to HTML.
                IContentType  contentType = null;
                ITextDocument textDocument;

                if (diskBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDocument))
                {
                    if (Path.GetExtension(textDocument.FilePath).Equals(PhpConstants.PhpFileExtension, StringComparison.OrdinalIgnoreCase) ||
                        Path.GetExtension(textDocument.FilePath).Equals(PhpConstants.Php5FileExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        var path = Path.GetFileNameWithoutExtension(textDocument.FilePath);
                        if (path.IndexOf('.') != -1)
                        {
                            string subExt = Path.GetExtension(path).Substring(1);

                            var fileExtRegistry = _compModel.GetService <IFileExtensionRegistryService>();

                            contentType = fileExtRegistry.GetContentTypeForExtension(subExt);
                        }
                    }
                }
                return(contentType);
            }
Beispiel #20
0
        internal static int IdFromTitle(string title, Type type)
        {
            string name = Path.GetFileNameWithoutExtension(title);
            int    id   = GetId(type, name);

            return(id);
        }
Beispiel #21
0
        public override string LocalizationFileRemap(string outputFile)
        {
            var fileName = Path.GetFileNameWithoutExtension(outputFile);

            if (fileName.StartsWith("p_ai_tutorial"))
            {
                var mapName =
                    TutorialCategoryMap.Where(m => m.Value.Contains(fileName)).Select(m => m.Key).FirstOrDefault() ??
                    "xx_Unknown";

                return($"Tutorials/{mapName}/{fileName}.txt");
            }

            if (outputFile.StartsWith(@"GameInfoTables\HousingItems") && int.TryParse(fileName, out var categoryId))
            {
                var catNameLocalization = string.Empty;
#if LOCALIZE
                Singleton <Resources> .Instance.Localize.ConvertTranslateHousingCategory(categoryId,
                                                                                         ref catNameLocalization);
#endif
                if (!string.IsNullOrEmpty(catNameLocalization))
                {
                    return(CombinePaths(Path.GetDirectoryName(outputFile), $"{catNameLocalization}.txt"));
                }
            }

            return(base.LocalizationFileRemap(outputFile));
        }
Beispiel #22
0
        private string GenerateUniqueFileName(string path)
        {
            string fileNameNoExtension = Path.GetFileNameWithoutExtension(path);
            string fileExtension       = Path.GetExtension(path);
            int    numberToAppend      = 0;
            string regexPattern        = fileNameNoExtension + "\\d*\\" + fileExtension;

            foreach (SerializedProperty elementProperty in galleryImagesProp.FindPropertyRelative("value"))
            {
                var elementFileName = elementProperty.FindPropertyRelative("fileName").stringValue;
                if (System.Text.RegularExpressions.Regex.IsMatch(elementFileName, regexPattern))
                {
                    string numberString = elementFileName.Substring(fileNameNoExtension.Length);
                    numberString = numberString.Substring(0, numberString.Length - fileExtension.Length);
                    int number;
                    if (!Int32.TryParse(numberString, out number))
                    {
                        number = 0;
                    }

                    if (numberToAppend <= number)
                    {
                        numberToAppend = number + 1;
                    }
                }
            }

            if (numberToAppend > 0)
            {
                fileNameNoExtension += numberToAppend.ToString();
            }

            return(fileNameNoExtension + fileExtension);
        }
Beispiel #23
0
 /// <summary>
 /// Create a new <see cref="Font"/> from a path.
 /// </summary>
 /// <param name="path">The path of the font.</param>
 public Font(string path)
 {
     Slug   = Utility.ToSlug(PathIO.GetFileNameWithoutExtension(path));
     Path   = path;
     File   = PathIO.GetFileName(path);
     Format = PathIO.GetExtension(path).Replace(".", string.Empty);
 }
Beispiel #24
0
 public File(string path, FileInfoBase info, LocalFileSource source)
 {
     this.Path   = path;
     this.Name   = Paths.GetFileNameWithoutExtension(path);
     this.Type   = info;
     this.Source = source;
 }
        // Update function
        public void UpdateInformation()
        {
            // Check if active document is of type assembly or part
            if (!Utility.DocumentChecker(Utility.DataTypes.Assembly, this._inventorObject) && !Utility.DocumentChecker(Utility.DataTypes.Part, this._inventorObject))
            {
                MessageBox.Show("Kann nur in einer Baugruppe oder Bauteil ausgeführt werden.");
                return;
            }

            // Full path of part/assembly
            this.FullPath = this._inventorObject.ActiveDocument.FullFileName;
            // Directory
            this.Directory = Path.GetDirectoryName(this.FullPath);
            // Document name without type
            this.DocumentName = Path.GetFileNameWithoutExtension(this.FullPath);
            // Document name with path
            this.PathWithDocument = $@"{this.Directory}\{this.DocumentName}";

            // Check if drawing exists
            var drawingPath = this.PathWithDocument + ".idw";

            this.HasDrawing = File.Exists(@drawingPath);

            // Check if file has revision
            this.HasRevision = Utility.RevisionChecker(this.DocumentName);

            // Calculate next revision
            this.NextRevisionNumber = this.HasRevision ? Utility.NummericRevision(this.DocumentName).ToString() : "01";
        }
        private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper()
        {
            var wrapper = new AntlrClassGenerationTaskInternal();

            IList <string> sourceCodeFiles = null;

            if (this.SourceCodeFiles != null)
            {
                sourceCodeFiles = new List <string>(SourceCodeFiles.Length);
                foreach (ITaskItem taskItem in SourceCodeFiles)
                {
                    sourceCodeFiles.Add(taskItem.ItemSpec);
                }
            }

            if (this.TokensFiles != null && this.TokensFiles.Length > 0)
            {
                Directory.CreateDirectory(OutputPath);

                HashSet <string> copied = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem taskItem in TokensFiles)
                {
                    string fileName = taskItem.ItemSpec;
                    if (!File.Exists(fileName))
                    {
                        Log.LogError("The tokens file '{0}' does not exist.", fileName);
                        continue;
                    }

                    string vocabName = Path.GetFileNameWithoutExtension(fileName);
                    if (!copied.Add(vocabName))
                    {
                        Log.LogWarning("The tokens file '{0}' conflicts with another tokens file in the same project.", fileName);
                        continue;
                    }

                    string target = Path.Combine(OutputPath, Path.GetFileName(fileName));
                    if (!Path.GetExtension(target).Equals(".tokens", StringComparison.OrdinalIgnoreCase))
                    {
                        Log.LogError("The destination for the tokens file '{0}' did not have the correct extension '.tokens'.", target);
                        continue;
                    }

                    File.Copy(fileName, target, true);
                    File.SetAttributes(target, File.GetAttributes(target) & ~FileAttributes.ReadOnly);
                }
            }

            wrapper.AntlrToolPath            = AntlrToolPath;
            wrapper.SourceCodeFiles          = sourceCodeFiles;
            wrapper.TargetLanguage           = TargetLanguage;
            wrapper.OutputPath               = OutputPath;
            wrapper.RootNamespace            = RootNamespace;
            wrapper.GeneratedSourceExtension = GeneratedSourceExtension;
            wrapper.LanguageSourceExtensions = LanguageSourceExtensions;
            wrapper.DebugGrammar             = DebugGrammar;
            wrapper.ProfileGrammar           = ProfileGrammar;
            return(wrapper);
        }
Beispiel #27
0
 /// <summary>Generates the file path for a mod galley image.</summary>
 public static string GenerateModGalleryImageFilePath(int modId,
                                                      string imageFileName,
                                                      ModGalleryImageSize size)
 {
     return(IOUtilities.CombinePath(GenerateModMediaDirectoryPath(modId),
                                    "images_" + size.ToString(),
                                    Path.GetFileNameWithoutExtension(imageFileName) + ".png"));
 }
Beispiel #28
0
        protected IEnumerable <ITranslationDumper> GetUILocalizers(DefinePack definePack, string topLevelName)
        {
            //Logger.LogWarning($"GetUILocalizers({topLevelName})");
            var finished = new HashSet <string>();
            var props    = definePack.ABDirectories.GetType().GetProperties()
                           .Where(p => p.PropertyType == typeof(string) && p.Name == "PopupInfoList");

            foreach (var prop in props)
            {
                foreach (var redirectTable in GetRedirectTables((string)prop.GetValue(definePack.ABDirectories)))
                {
                    //Logger.LogWarning($"RedirectTable: name={redirectTable.name}, assetbundle={redirectTable.assetbundle}, asset={redirectTable.asset}, manifest={redirectTable.manifest}");
                    foreach (var assetTable in GetAssetTables(redirectTable))
                    {
                        //Logger.LogWarning($"AssetTable: name={assetTable.name}, assetbundle={assetTable.assetbundle}, asset={assetTable.asset}, manifest={assetTable.manifest}");
                        var objects          = GetAssetTableObjects(assetTable);
                        var assetNameForPath = Path.GetFileNameWithoutExtension(assetTable.asset);
                        foreach (var gameObject in objects)
                        {
                            var handled    = new HashSet <object>();
                            var outputName = $"UI/{topLevelName}/{assetNameForPath}/{gameObject.name}";
                            if (finished.Contains(outputName))
                            {
                                continue;
                            }
                            finished.Add(outputName);
                            var textList = EnumerateTexts(gameObject, handled).Select(t => t.Value).ToArray();
                            var before   = textList.Select(t => t.text).ToArray();

                            var binder = gameObject.Get <UIBinder>();
                            if (binder)
                            {
                                var binderLoad = Traverse.Create(binder).Method("Load");
                                if (binderLoad.MethodExists())
                                {
                                    binderLoad.GetValue();
                                }
                            }

                            Dictionary <string, string> Localizer()
                            {
                                var results = new Dictionary <string, string>();
                                var after   = textList.Select(t => t.text).ToArray();

                                for (var i = 1; i < before.Length; i++)
                                {
                                    AddLocalizationToResults(results, before[i], after[i]);
                                }

                                return(results);
                            }

                            yield return(new StringTranslationDumper(outputName, Localizer));
                        }
                    }
                }
            }
        }
        private View GetView(string filePath, string controllerName, string areaName, string templateKind = null)
        {
            var templateKindSegment = templateKind != null ? templateKind + "/" : null;
            var relativePath        = !string.IsNullOrEmpty(areaName)
                ? $"~/Areas/{areaName}/Views/{controllerName}/{templateKindSegment}{Path.GetFileName(filePath)}"
                : $"~/Views/{controllerName}/{templateKindSegment}{Path.GetFileName(filePath)}";

            return(new View(areaName, controllerName, Path.GetFileNameWithoutExtension(filePath), new Uri(relativePath, UriKind.Relative), templateKind));
        }
Beispiel #30
0
        public static string GetAssemblyNameWithoutExtension(string assemblyName)
        {
            if (AssetPath.GetExtension(assemblyName) == ".dll")
            {
                return(SystemPath.GetFileNameWithoutExtension(assemblyName.NormalizePath()));
            }

            return(SystemPath.GetFileName(assemblyName.NormalizePath()));
        }