public List <string> GetOptionSetList(string connectionstring)
        {
            var client   = Connection.CrmConnection.GetClientByConnectionString(connectionstring);
            var metadata = new Utility.XrmMetaData(client);

            return(metadata.GetGlobalOptionSets());
        }
        public void GenerateOptionSetMetaDataStruct(string connectionstring, string filepath)
        {
            var client     = Connection.CrmConnection.GetClientByConnectionString(connectionstring);
            var metadata   = new Utility.XrmMetaData(client);
            var optionsets = metadata.GetGlobalOptionSets();

            //string filePath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
            //var outpath = Path.GetFullPath($"{System.IO.Path.GetDirectoryName(filePath)}\\{filepath}");
            var outpath = GetPath(filepath);

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(outpath))
            {
                file.WriteLine("public struct XrmOptionSets");
                file.WriteLine("{");
                foreach (var x in optionsets)
                {
                    file.WriteLine($"\tpublic static readonly string {x} = \"{x}\";");
                }
                file.WriteLine("}");
            }
            Log($"Struct generated to {outpath}");
        }