Пример #1
0
        internal static void LogSettings(OpenIdConnectAuthenticationOptions openIdOptions, string folder = null)
        {
            folder = folder ?? Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            var props = openIdOptions.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).OrderBy(o => o.Name);
            var dics  = new Dictionary <string, string>();

            foreach (var prop in props)
            {
                if (dics.ContainsKey(prop.Name))
                {
                    continue;
                }
                try
                {
                    dics.Add(prop.Name, prop.GetValue(openIdOptions)?.ToString() ?? "");
                }
                catch
                {
                    dics.Add(prop.Name, "");
                }
            }
            JsonSerializer serializer = new JsonSerializer();

#if Okta
            using (StreamWriter sw = new StreamWriter($@"{folder}\\Okta.json"))
#else
            using (StreamWriter sw = new StreamWriter($@"{folder}\\AzureAD.json"))
#endif
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, dics);
                }
        }