/// <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.HasValue()) { 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.HasValue()) { 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.IsEnabled()) { throw new ConfigurationException( "The type {0} has EnforceTemplate set to true but no TemplateId".Formatted(type.FullName)); } scConfig.EnforceTemplate = this.EnforceTemplate; scConfig.TemplateName = this.TemplateName; scConfig.Cache = this.Cache; base.Configure(type, scConfig); return(scConfig); }
/// <summary> /// Configures the specified property info. /// </summary> /// <param name="propertyInfo">The property info.</param> /// <param name="config">The config.</param> public void Configure(PropertyInfo propertyInfo, SitecoreLinkedConfiguration config) { config.Option = this.Option; if (TemplateId.HasValue()) { config.TemplateId = new ID(TemplateId); } config.EnforceTemplate = EnforceTemplate; base.Configure(propertyInfo, config); }
/// <summary> /// Configures the specified property info. /// </summary> /// <param name="propertyInfo">The property info.</param> /// <returns>AbstractPropertyConfiguration.</returns> public override Mapper.Configuration.AbstractPropertyConfiguration Configure(System.Reflection.PropertyInfo propertyInfo) { var config = new SitecoreParentConfiguration(); if (TemplateId.HasValue()) { config.TemplateId = new ID(TemplateId); } config.EnforceTemplate = EnforceTemplate; Configure(propertyInfo, config); return(config); }
//<< Fields public override void WriteInitializationScript(TextWriter writer) { var json = new Dictionary <string, object>(Events); if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url) || DataSource.Type == DataSourceType.Custom) { json["dataSource"] = DataSource.ToJson(); } else if (DataSource.Data != null) { json["dataSource"] = DataSource.Data; } //>> Serialization if (AutoBind.HasValue) { json["autoBind"] = AutoBind; } if (ZoomRate.HasValue) { json["zoomRate"] = ZoomRate; } if (Draggable.HasValue) { json["draggable"] = Draggable; } var layout = Layout.ToJson(); if (layout.Any()) { json["layout"] = layout; } if (TemplateId.HasValue()) { json["template"] = TemplateId; } if (Resizable.HasValue) { json["resizable"] = Resizable; } if (Rotatable.HasValue) { json["rotatable"] = Rotatable; } var connectionDefaults = ConnectionDefaults.ToJson(); if (connectionDefaults.Any()) { json["connectionDefaults"] = connectionDefaults; } var connections = Connections.ToJson(); if (connections.Any()) { json["connections"] = connections; } var shapeDefaults = ShapeDefaults.ToJson(); if (shapeDefaults.Any()) { json["shapeDefaults"] = shapeDefaults; } var shapes = Shapes.ToJson(); if (shapes.Any()) { json["shapes"] = shapes; } //<< Serialization writer.Write(Initializer.Initialize(Selector, "Diagram", json)); base.WriteInitializationScript(writer); }