Example #1
0
        private List <WorkspaceInfoViewModel> LoadWorkspaceInfosFromArcMap()
        {
            var result = new List <WorkspaceInfoViewModel>();

            var workspaces = ArcmapUtils.EnumerateAllWorkspaces(Ioc.GetOrCreate <IApplication>());

            foreach (IWorkspace workspace in workspaces)
            {
                WorkspaceInfoViewModel info = new WorkspaceInfoViewModel();
                info.Path = workspace.PathName;
                info.Name = Path.GetFileNameWithoutExtension(info.Path);

                ISQLSyntax sqlSyntax = workspace as ISQLSyntax;
                if (sqlSyntax != null)
                {
                    info.StringComparisonCaseSensitive   = sqlSyntax.GetStringComparisonCase();
                    info.IdentifierCaseSensitive         = sqlSyntax.GetIdentifierCase();
                    info.QuotedIdentifierCaseSensitive   = sqlSyntax.GetDelimitedIdentifierCase();
                    info.InvalidCharactersForIdentifiers = sqlSyntax.GetInvalidCharacters();

                    foreach (var enumName in Enum.GetValues(typeof(esriSQLFunctionName)))
                    {
                        string enumValue = sqlSyntax.GetFunctionName((esriSQLFunctionName)enumName);
                        if (string.IsNullOrEmpty(enumValue))
                        {
                            enumValue = NotAvailable;
                        }
                        info.SqlFunctions.AddOrReplace(enumName.ToString(), enumValue);
                    }
                    info.SqlFunctions.Sort((x, y) => string.Compare(x.Key, y.Key, StringComparison.InvariantCultureIgnoreCase));

                    foreach (var enumName in Enum.GetValues(typeof(esriSQLSpecialCharacters)))
                    {
                        string enumValue = sqlSyntax.GetSpecialCharacter((esriSQLSpecialCharacters)enumName);
                        if (string.IsNullOrEmpty(enumValue))
                        {
                            enumValue = string.Empty;
                        }
                        info.SpecialCharacters.AddOrReplace(enumName.ToString(), enumValue);
                    }
                    info.SpecialCharacters.Sort((x, y) => string.Compare(x.Key, y.Key, StringComparison.InvariantCultureIgnoreCase));

                    foreach (string keyword in sqlSyntax.GetKeywords().Enumerate())
                    {
                        info.ReservedWords.Add(keyword);
                    }
                    info.ReservedWords.Sort(StringComparer.InvariantCultureIgnoreCase);
                }

                result.Add(info);
            }
            return(result);
        }