/// <summary> /// Configures the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="config">The config.</param> /// <exception cref="Glass.Mapper.Configuration.ConfigurationException">Type configuration is not of type {0}.Formatted(typeof (SitecoreTypeConfiguration).FullName)</exception> public override AbstractTypeConfiguration Configure(Type type) { var scConfig = new SitecoreTypeConfiguration(); if (scConfig == null) throw new ConfigurationException( "Type configuration is not of type {0}".Formatted(typeof (SitecoreTypeConfiguration).FullName)); if (BranchId.IsNotNullOrEmpty()) scConfig.BranchId = new ID(this.BranchId); else scConfig.BranchId = ID.Null; if (TemplateId.IsNotNullOrEmpty()) scConfig.TemplateId = new ID(this.TemplateId); else scConfig.TemplateId = ID.Null; scConfig.CodeFirst = this.CodeFirst; scConfig.TemplateName = this.TemplateName; base.Configure(type, scConfig); return scConfig; }
/// <summary> /// Configures the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="config">The config.</param> /// <exception cref="Glass.Mapper.Configuration.ConfigurationException">Type configuration is not of type {0}.Formatted(typeof (SitecoreTypeConfiguration).FullName)</exception> public override AbstractTypeConfiguration Configure(Type type) { var scConfig = new SitecoreTypeConfiguration(); if (scConfig == null) throw new ConfigurationException( "Type configuration is not of type {0}".Formatted(typeof(SitecoreTypeConfiguration).FullName)); try { if (BranchId.IsNotNullOrEmpty()) scConfig.BranchId = new ID(this.BranchId); else scConfig.BranchId = ID.Null; } catch (Exception ex) { throw new MapperException("Failed to convert BranchId for type {0}. Value was {1}".Formatted(type.FullName, this.TemplateId), ex); } try { if (TemplateId.IsNotNullOrEmpty()) scConfig.TemplateId = new ID(this.TemplateId); else scConfig.TemplateId = ID.Null; } catch (Exception ex) { throw new MapperException("Failed to convert TemplateId for type {0}. Value was {1}".Formatted(type.FullName, this.TemplateId), ex); } if (TemplateId.IsNullOrEmpty() && this.EnforceTemplate != SitecoreEnforceTemplate.No) { throw new ConfigurationException( "The type {0} has EnforceTemplate set to true but no TemplateId".Formatted(type.FullName)); } scConfig.EnforceTemplate = this.EnforceTemplate; scConfig.CodeFirst = this.CodeFirst; scConfig.TemplateName = this.TemplateName; base.Configure(type, scConfig); return scConfig; }