コード例 #1
0
        private static void ConfigureIdProperty(ConnectionSettings settings)
        {
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            var types = new List<Type>();

            foreach (var assembly in assemblies) {
                try {
                    types.AddRange(assembly.GetTypes());
                }
                catch (ReflectionTypeLoadException exception) {
                    Logger.WriteToLog($"ConfigureIdProperty partialy failed. Assembly={assembly.FullName}",Level.Information,exception);
                }
            }

            types = types.Where(x => typeof(IContent).IsAssignableFrom(x) && !x.IsInterface).ToList();
            settings.MapIdPropertyFor<IContent>(x => x.ContentLink);
            var idProperties = ((IConnectionSettingsValues)settings).IdProperties;

            var name = idProperties[typeof(IContent)];

            foreach (var contentType in types)
            {
                if (!idProperties.ContainsKey(contentType))
                {
                    ((IConnectionSettingsValues)settings).IdProperties.Add(contentType, name);
                }
            }
        }