Exemplo n.º 1
0
        public AddRelationDialog(ActiveRecordDescriptor descriptor, Project project) : this()
        {
            _descriptor = descriptor;
            _project    = project;

            _relationBuilder = (IRelationshipBuilder)ServiceRegistry.Instance[typeof(IRelationshipBuilder)];

            className.Text = _descriptor.ClassName;

            targetTableList.ValueMember = "ClassName";

            foreach (IActiveRecordDescriptor desc in _project.Descriptors)
            {
                if (desc is ActiveRecordBaseDescriptor)
                {
                    continue;
                }
                if (desc.ClassName == null)
                {
                    continue;
                }

                targetTableList.Items.Add(desc);
            }
        }
        public void HasMany()
        {
            InitKernel();
            IRelationshipBuilder relService = ObtainService();

            TableDefinition blogTable;
            TableDefinition postTable;

            BuildBlogPostsStructure(out blogTable, out postTable);

            ActiveRecordDescriptor desc       = new ActiveRecordDescriptor("Blog");
            ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Post");

            RelationshipInfo info = new RelationshipInfo(AssociationEnum.HasMany, desc, targetDesc);

            info.ChildCol = new ColumnDefinition("blog_id", false, true, true, false, OleDbType.Numeric);

            ActiveRecordPropertyRelationDescriptor propDesc = relService.Build(info);

            Assert.IsNotNull(propDesc);
            Assert.IsNotNull(propDesc as ActiveRecordHasManyDescriptor);
            Assert.AreEqual("Posts", propDesc.PropertyName);
            Assert.AreEqual(targetDesc, propDesc.TargetType);
            Assert.AreEqual("blog_id", propDesc.ColumnName);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TwoWayRelationshipInterrogator"/> class.
        /// </summary>
        /// <param name="relationshipBuilder">The builder helper.</param>
        protected TwoWayRelationshipInterrogator(IRelationshipBuilder relationshipBuilder)
        {
            if (relationshipBuilder == null)
            {
                throw new ArgumentNullException("relationshipBuilder");
            }

            _relationshipBuilder = relationshipBuilder;
        }
Exemplo n.º 4
0
		public AddRelationDialog(ActiveRecordDescriptor descriptor, Project project) : this()
		{
			_descriptor = descriptor;
			_project = project;

			_relationBuilder = (IRelationshipBuilder) ServiceRegistry.Instance[ typeof(IRelationshipBuilder) ];

			className.Text = _descriptor.ClassName;

			targetTableList.ValueMember = "ClassName";

			foreach(IActiveRecordDescriptor desc in _project.Descriptors)
			{
				if (desc is ActiveRecordBaseDescriptor) continue;
				if (desc.ClassName == null) continue;

				targetTableList.Items.Add( desc );
			}
		}
        public void HasÁndBelongsToMany()
        {
            InitKernel();
            IRelationshipBuilder relService = ObtainService();

            DatabaseDefinition dbdef = new DatabaseDefinition("alias");

            TableDefinition compTable = new TableDefinition("companies", dbdef);

            compTable.AddColumn(new ColumnDefinition("id", true, false, true, false, OleDbType.Integer));
            compTable.AddColumn(new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar));

            TableDefinition peopleTable = new TableDefinition("people", dbdef);

            peopleTable.AddColumn(new ColumnDefinition("id", true, false, true, false, OleDbType.Integer));
            peopleTable.AddColumn(new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar));

            TableDefinition assocTable = new TableDefinition("companiespeople", dbdef);

            assocTable.AddColumn(new ColumnDefinition("comp_id", true, true, true, false, OleDbType.Integer));
            assocTable.AddColumn(new ColumnDefinition("person_id", true, true, false, false, OleDbType.Integer));

            ActiveRecordDescriptor desc       = new ActiveRecordDescriptor("Company");
            ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Person");

            RelationshipInfo info = new RelationshipInfo(AssociationEnum.HasAndBelongsToMany, desc, targetDesc);

            info.AssociationTable = assocTable;
            info.ParentCol        = new ColumnDefinition("comp_id", false, true, false, true, OleDbType.Integer);
            info.ChildCol         = new ColumnDefinition("person_id", false, true, false, true, OleDbType.Integer);

            ActiveRecordPropertyRelationDescriptor propDesc = relService.Build(info);

            Assert.IsNotNull(propDesc as ActiveRecordHasAndBelongsToManyDescriptor);
            Assert.IsNotNull(propDesc);
            Assert.AreEqual("People", propDesc.PropertyName);
            Assert.AreEqual(targetDesc, propDesc.TargetType);
            Assert.AreEqual("person_id", propDesc.ColumnName);
            Assert.AreEqual("comp_id", (propDesc as ActiveRecordHasAndBelongsToManyDescriptor).ColumnKey);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FracterVsBarrierInterrogator"/> class.
 /// </summary>
 /// <param name="relationshipBuilder">The builder helper.</param>
 public FracterVsBarrierInterrogator(IRelationshipBuilder relationshipBuilder)
     : base(relationshipBuilder)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DecoderVsCodeGateInterrogator"/> class.
 /// </summary>
 /// <param name="relationshipBuilder">The builder helper.</param>
 public DecoderVsCodeGateInterrogator(IRelationshipBuilder relationshipBuilder)
     : base(relationshipBuilder)
 {
 }
Exemplo n.º 8
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Extension Methods
        public static IRelationshipBuilder <TParentBuilder, TResource> SetMeta <TParentBuilder, TResource>(this IRelationshipBuilder <TParentBuilder, TResource> relationshipBuilder, params Meta[] metaCollection)
            where TParentBuilder : class
            where TResource : class, IResource
        {
            Contract.Requires(relationshipBuilder != null);

            return(relationshipBuilder.SetMeta(metaCollection.AsEnumerable()));
        }
 protected IcebreakerVsRelationshipInterrogator(IRelationshipBuilder relationshipBuilder)
     : base(relationshipBuilder)
 {
 }
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Extension Methods
        public static IRelationshipBuilder<TParentBuilder, TResource> SetId<TParentBuilder, TResource, TResourceId>(this IRelationshipBuilder<TParentBuilder, TResource> relationshipBuilder, params TResourceId[] clrResourceIdCollection)
            where TParentBuilder : class
            where TResource : class, IResource
            where TResourceId : IEquatable<TResourceId>
        {
            Contract.Requires(relationshipBuilder != null);
            Contract.Requires(clrResourceIdCollection != null);

            return relationshipBuilder.SetId(clrResourceIdCollection.AsEnumerable());
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KillerVsSentryInterrogator"/> class.
 /// </summary>
 /// <param name="relationshipBuilder">The builder helper.</param>
 public KillerVsSentryInterrogator(IRelationshipBuilder relationshipBuilder)
     : base(relationshipBuilder)
 {
 }