Rock.Model.FieldTypeService.RegisterFieldTypes C# (CSharp) Method

RegisterFieldTypes() public static method

Gets a list of all Rock.Model.FieldType">FieldTypes (all items that implement the FieldTypes that have not been previously registered.
public static RegisterFieldTypes ( string physWebAppPath ) : void
physWebAppPath string A representing the physical path of the web application.
return void
        public static void RegisterFieldTypes( string physWebAppPath )
        {
            var fieldTypes = new Dictionary<string, EntityType>();

            using ( var rockContext = new RockContext() )
            {
                var fieldTypeService = new FieldTypeService( rockContext );

                var existingFieldTypes = fieldTypeService.Queryable().ToList();

                foreach ( var type in Rock.Reflection.FindTypes( typeof( Rock.Field.IFieldType ) ) )
                {
                    string assemblyName = type.Value.Assembly.GetName().Name;
                    string className = type.Value.FullName;

                    if ( !existingFieldTypes.Where( f =>
                        f.Assembly == assemblyName &&
                        f.Class == className ).Any() )
                    {
                        string fieldTypeName = type.Value.Name.SplitCase();
                        if ( fieldTypeName.EndsWith( " Field Type" ) )
                        {
                            fieldTypeName = fieldTypeName.Substring( 0, fieldTypeName.Length - 11 );
                        }
                        var fieldType = new FieldType();
                        fieldType.Name = fieldTypeName;
                        fieldType.Assembly = assemblyName;
                        fieldType.Class = className;
                        fieldType.IsSystem = false;
                        fieldTypeService.Add( fieldType );
                    }
                }

                rockContext.SaveChanges();
            }
        }