///------------------------------------------------------------------------------------------------- /// <summary> /// Defines the property. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="metadata"> /// The metadata. /// </param> /// <param name="kind"> /// (Optional) the kind. /// </param> /// <param name="defaultValue"> /// (Optional) The default value. /// </param> /// <returns> /// An ISchemaProperty. /// </returns> ///------------------------------------------------------------------------------------------------- protected ISchemaProperty DefineProperty(string name, ISchemaValueObject metadata, PropertyKind kind = PropertyKind.Normal, object defaultValue = null) { Contract.RequiresNotEmpty(name, "name"); Contract.Requires(metadata, "metadata"); var prop = new SchemaProperty(this, name, metadata, kind, defaultValue); return(DefineProperty(prop)); }
///------------------------------------------------------------------------------------------------- /// <summary> /// Constructor. /// </summary> /// <param name="domainModel"> /// The domain model. /// </param> /// <param name="id"> /// The identifier. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="metadata"> /// The metadata. /// </param> ///------------------------------------------------------------------------------------------------- public PrimitiveMetaProperty(PrimitivesSchema domainModel, Identity id, string name, ISchemaValueObject metadata) : base(domainModel, typeof(SchemaProperty), domainModel.SchemaEntitySchema, name: name, id: id) { DebugContract.Requires(domainModel, "domainModel"); DebugContract.RequiresNotEmpty(name); DebugContract.Requires(metadata, "metadata"); DebugContract.Requires(id, "id"); _metadata = metadata; ((PrimitivesSchema)domainModel).RegisterMetadata(this); }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="SchemaProperty" /> class. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="propertyName"> /// Name of the property. /// </param> /// <param name="propertyMetaclass"> /// The property metaclass. /// </param> /// <param name="kind"> /// (Optional) the kind. /// </param> /// <param name="defaultValue"> /// (Optional) /// </param> /// <param name="implementedType"> /// (Optional) Type of the implemented. /// </param> ///------------------------------------------------------------------------------------------------- public SchemaProperty(ISchemaInfo owner, string propertyName, ISchemaValueObject propertyMetaclass, PropertyKind kind = PropertyKind.Normal, object defaultValue = null, Type implementedType = null) { Contract.Requires(owner, "owner"); Contract.RequiresNotEmpty(propertyName, "propertyName"); _owner = owner; //if (InvalidPropertyNames.Any(p => String.Compare(p, propertyName, StringComparison.OrdinalIgnoreCase) == 0)) // throw new Exception(ExceptionMessages.InvalidPropertyNameCantBeAPropertyOfIModelElement); ConstructInternal(owner.Schema, implementedType ?? typeof(SchemaProperty), owner.Id.CreateMetaPropertyIdentity(propertyName), propertyName, null, owner.Schema.Store.PrimitivesSchema.SchemaPropertySchema, (dm, melId, m) => new AddSchemaPropertyCommand(dm as ISchema, melId, (ISchemaEntity)m)); // Attention ici toutes les propriétés doivent avoir été déclarées sous peine de rentrer dans une bouble infini // au niveau GetOrCreateProperty de ModelElement PropertySchema = propertyMetaclass; if (defaultValue != null) { DefaultValue = defaultValue; } Kind = kind; }
ISchemaProperty ISchemaElement.DefineProperty(string name, ISchemaValueObject property, object defaultValue, PropertyKind kind) { return(DefineProperty(name, property, kind, defaultValue)); }
public SerializationContext(ISchemaValueObject schemaValueObject, object value) { Contract.Requires(schemaValueObject, "schemaValueObject"); Schema = schemaValueObject; Value = value; }