Example #1
0
        public Runner(
            ISchemaCollection schemaCollection,
            IXmlElementParser xmlElementParser,
            IDesignModelParser designModelParser,
            IDesignModelCollection designModelCollection,
            IOutputModelCollection outputModelCollection,
            IStageHandlerRegistry stageHandlers,
            IDataTypeRegistry dataTypeRegistry,
            IEnumerable <IClassNamingConvention> classNamingConventions
            )
        {
            this._schemaCollection  = schemaCollection;
            this._xmlElementParser  = xmlElementParser;
            this._designModelParser = designModelParser;

            this._context = new Context
            {
                Schemas                 = schemaCollection,
                DesignModels            = designModelCollection,
                OutputModels            = outputModelCollection,
                DataTypeRegistry        = dataTypeRegistry,
                MainOutputConfiguration = designModelCollection.RootNamespace.OutputConfiguration,
                StageHandlers           = stageHandlers
            };
        }
Example #2
0
        private static void RegisterDataTypes(IDataTypeRegistry registry, IODataObjectFactory oDataObjectFactory, IMetadataService metadataService)
        {
            // FACTON domain types with their own, complex domain values
            registry.Register <IUnitValueDomainType>(new UnitValueDataType(oDataObjectFactory));
            registry.Register <ILocalizedLongTextDomainType>(new LocalizedTextDataType(oDataObjectFactory));

            // FACTON domain types whose domain values can be mapped to CLR types
            registry.Register <AbstractDateTimeDomainType>(new ClrTypeReferencingDataType <DateValue, DateTimeOffset>(
                                                               v => new DateTimeOffset(v.Date), v => new DateValue(v.DateTime.ToUniversalTime())));

            registry.Register("Boolean", new ClrTypeReferencingDataType <BooleanValue, bool>(v => v.Value, v => v.ToBooleanValue()));
            registry.Register("Number", new ClrTypeReferencingDataType <NumberValue, decimal>(v => v.InternalNumber, v => new NumberValue(v)));
            registry.Register(
                new object[] { "Integer", "AutoIncrement" },
                new ClrTypeReferencingDataType <IntegerValue, long>(v => v.Value, v => new IntegerValue(v)));
            registry.Register(
                new object[] { "Id", "ContextBoundId" },
                new ClrTypeReferencingDataType <IId, string>(IdConverter.ConvertToString, IdConverter.ConvertToId));
            registry.Register <IMetadataItemDomainType>(new MetadataItemDataType(metadataService));

            // FACTON domain types whose values _are_ CLR types
            registry.Register("TimeSpan", ClrDataTypes.Duration);
            registry.Register("SimpleBoolean", ClrDataTypes.Boolean);
            registry.Register("SimpleInteger", ClrDataTypes.Int32);
            registry.Register("SimpleDecimal", ClrDataTypes.Decimal);
            registry.Register("SimpleLong", ClrDataTypes.Int64);
            registry.Register("SimpleString", ClrDataTypes.String);
            registry.Register("SimpleLongString", ClrDataTypes.String);

            // FACTON domain types whose values can be serialized/deserialized to strings, using the DomainType itself
            registry.Register <ILongTextDomainType, ICurrencyDomainType>(new SerializableDomainTypeDataType());

            // other, non-domain types
            registry.Register <IId>(new ClrTypeReferencingDataType <IId, string>(IdConverter.ConvertToString, IdConverter.ConvertToId));
        }
        public MongoTransitionRepository(IDataTypeRegistry dataTypeRegistry, string connectionString)
        {
            _dataTypeRegistry = dataTypeRegistry;
            _serializer       = new MongoTransitionSerializer(dataTypeRegistry);
            _transitionServer = new MongoTransitionServer(connectionString);

            EnsureIndexes();
        }
        public MongoTransitionRepository(IDataTypeRegistry dataTypeRegistry, String connectionString, String collectionName = "transitions")
        {
            _dataTypeRegistry = dataTypeRegistry;
            _serializer = new MongoTransitionSerializer(dataTypeRegistry);
            _server = new MongoTransitionServer(connectionString, collectionName);

            EnsureIndexes();
        }
        public MongoTransitionRepository(IDataTypeRegistry dataTypeRegistry, String connectionString, String collectionName = "transitions")
        {
            _dataTypeRegistry = dataTypeRegistry;
            _serializer       = new MongoTransitionSerializer(dataTypeRegistry);
            _server           = new MongoTransitionServer(connectionString, collectionName);

            EnsureIndexes();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public Repository(ITransitionStorage transitionStorage,
                   IEventBus eventBus,
                   IDataTypeRegistry dataTypeRegistry, ISnapshotRepository snapshotRepository = null)
 {
     _transitionStorage  = transitionStorage;
     _eventBus           = eventBus;
     _dataTypeRegistry   = dataTypeRegistry;
     _snapshotRepository = snapshotRepository;
 }
        /// <summary>
        /// Creates a schema definition for Mapping element for mapping desing model attributes and relations.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="designModelTypeName"></param>
        /// <param name="addAttributes"></param>
        /// <param name="addRelations"></param>
        /// <param name="dataTypeRegistry"></param>
        /// <returns></returns>
        public static ISchemaElementBuilder AddClassMappingSchema(
            this ISchemaElementBuilder builder,
            string designModelTypeName,
            bool addAttributes,
            bool addRelations,
            IDataTypeRegistry dataTypeRegistry
            )
        {
            // Define the schema elements.
            var stringType = dataTypeRegistry.Get(BasePluginConstants.DataType_string);
            var boolType   = dataTypeRegistry.Get(BasePluginConstants.DataType_bool);

            builder = builder
                      .CreateElement("Mapping", $"Defines a mapping from the source {designModelTypeName}")
                      .CreateAttribute("src", stringType, $"Source {designModelTypeName} name", c => c.IsMandatory = true)
                      .CreateAttribute("name", stringType, $"Mapping name. Needed if multiple mappings to the same design models are defined.")
                      .CreateAttribute("dest", stringType, $"Destination {designModelTypeName} name", c => c.IsMandatory = true)
                      .CreateAttribute("attributes", boolType, "Whether to map attributes")
                      .CreateAttribute("relations", boolType, "Whether to map relations")
                      .CreateAttribute("two-way", boolType, "Whether to to create a mapping for both directions.")
                      .CreateAttribute("add-missing", boolType, "Whether to all attributes and relations which exists at the source and not at the destination.");

            if (addAttributes)
            {
                builder
                .CreateElement("Attribute", "Specifies how a specific attribute will be mapped")
                .CreateAttribute("src", stringType, "Source design model attribute name", c => c.IsMandatory       = true)
                .CreateAttribute("dest", stringType, "Destination design model attribute name", c => c.IsMandatory = true)
                .Parent()
                .CreateElement("SkipAttribute", "Specifies that the specific attribute will not be mapped")
                .CreateAttribute("name", stringType, "Name of the attribute to skip", c => c.IsMandatory = true);
            }

            if (addRelations)
            {
                builder
                .CreateElement("Relation", "Specifies how a specific attribute will be mapped")
                .CreateAttribute("src", stringType, "Source design model relation name", c => c.IsMandatory       = true)
                .CreateAttribute("dest", stringType, "Destination design model relation name", c => c.IsMandatory = true)
                .CreateAttribute("attributes", boolType, "Whether to map attributes")
                .CreateAttribute("add-missing", boolType, "Whether to all attributes which exists at the source and not at the destination.")
                .CreateAttribute("two-way", boolType, "Whether to to create a mapping for both directions.")
                .Parent()
                .CreateElement("SkipRelation", "Specifies that the specific relation will not be mapped")
                .CreateAttribute("name", stringType, "Name of the attribute to skip", c => c.IsMandatory = true);
            }

            return(builder.Parent());
        }
        /// <summary>
        /// Create changeset. Used to persist changes in aggregate
        /// </summary>
        /// <returns></returns>
        public Transition CreateTransition(IDataTypeRegistry dataTypeRegistry)
        {
            if (String.IsNullOrEmpty(_id))
                throw new Exception(String.Format("ID was not specified for domain object. AggregateRoot [{0}] doesn't have correct ID. Maybe you forgot to set an _id field?", this.GetType().FullName));

            var transitionEvents = new List<TransitionEvent>();
            foreach (var e in _changes)
            {
                e.Metadata.StoredDate = DateTime.UtcNow;
                e.Metadata.TypeName = e.GetType().Name;
                transitionEvents.Add(new TransitionEvent(dataTypeRegistry.GetTypeId(e.GetType()), e, null));
            }

            return new Transition(new TransitionId(_id, _version + 1), DateTime.UtcNow, transitionEvents, null);
        }
        /// <summary>
        /// Create changeset. Used to persist changes in aggregate
        /// </summary>
        /// <returns></returns>
        public Transition CreateTransition(IDataTypeRegistry dataTypeRegistry)
        {
            if (String.IsNullOrEmpty(_id))
            {
                throw new Exception(String.Format("ID was not specified for domain object. AggregateRoot [{0}] doesn't have correct ID. Maybe you forgot to set an _id field?", this.GetType().FullName));
            }

            var transitionEvents = new List <TransitionEvent>();

            foreach (var e in _changes)
            {
                e.Metadata.StoredDate = DateTime.UtcNow;
                e.Metadata.TypeName   = e.GetType().Name;
                transitionEvents.Add(new TransitionEvent(dataTypeRegistry.GetTypeId(e.GetType()), e, null));
            }

            return(new Transition(new TransitionId(_id, _version + 1), DateTime.UtcNow, transitionEvents, null));
        }
Example #10
0
 public TestRunner(
     ISchemaCollection schemaCollection,
     IXmlElementParser designModelElementParser,
     IDesignModelParser designModelParser,
     IDesignModelCollection designModelCollection,
     IOutputModelCollection outputModelCollection,
     IStageHandlerRegistry stageHandlers,
     IDataTypeRegistry dataTypeRegistry,
     IEnumerable <IClassNamingConvention> classNamingConventions
     ) : base(
         schemaCollection,
         designModelElementParser,
         designModelParser,
         designModelCollection,
         outputModelCollection,
         stageHandlers,
         dataTypeRegistry,
         classNamingConventions
         )
 {
 }
 public MongoTransitionSerializer(IDataTypeRegistry dataTypeRegistry)
 {
     _dataTypeRegistry = dataTypeRegistry;
     _dataSerializer = new MongoTransitionDataSerializer();
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public Repository(ITransitionStorage transitionStorage, IEventBus eventBus, IDataTypeRegistry _dataTypeRegistry)
 {
     _transitionStorage     = transitionStorage;
     _eventBus              = eventBus;
     this._dataTypeRegistry = _dataTypeRegistry;
 }
 public static void Register <T>(this IDataTypeRegistry registry, IDataType dataType)
 {
     registry.Register(typeof(T), dataType);
 }
 public static void Register <T1, T2>(this IDataTypeRegistry registry, IDataType dataType)
 {
     registry.Register(new object[] { typeof(T1), typeof(T2) }, dataType);
 }
Example #15
0
 public static void AddDataTypes(IDataTypeRegistry registry)
 {
 }
 public MongoTransitionSerializer(IDataTypeRegistry dataTypeRegistry)
 {
     _dataTypeRegistry = dataTypeRegistry;
     _dataSerializer   = new MongoTransitionDataSerializer();
 }
Example #17
0
 public EntityAttributeParser(IDataTypeRegistry dataTypeRegistry)
 {
     _dataTypeRegistry = dataTypeRegistry;
 }