コード例 #1
0
ファイル: MetaPopulationTest.cs プロジェクト: whesius/allors
        public void Composites()
        {
            var metaPopulation = new MetaPopulation();
            var domain = new Domain(metaPopulation, Guid.NewGuid());
            var superdomain = new Domain(metaPopulation, Guid.NewGuid());
            domain.AddDirectSuperdomain(superdomain);

            Assert.AreEqual(0, metaPopulation.Composites.Count());

            var @class = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("Class").WithPluralName("Classes").Build();

            Assert.AreEqual(1, metaPopulation.Composites.Count());

            var superclass = new ClassBuilder(superdomain, Guid.NewGuid()).WithSingularName("Superclass").WithPluralName("Superclasses").Build();

            Assert.AreEqual(2, metaPopulation.Composites.Count());

            var @interface = new InterfaceBuilder(domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();

            Assert.AreEqual(3, metaPopulation.Composites.Count());

            var superinterface = new InterfaceBuilder(superdomain, Guid.NewGuid()).WithSingularName("i2").WithPluralName("i2s").Build();

            Assert.AreEqual(4, metaPopulation.Composites.Count());

            var unit = new UnitBuilder(domain, UnitIds.StringId).WithSingularName("AllorsString").WithPluralName("AllorsStrings").WithUnitTag(UnitTags.AllorsString).Build();

            Assert.AreEqual(4, metaPopulation.Composites.Count());

            var superunit = new UnitBuilder(domain, UnitIds.IntegerId).WithSingularName("AllorsInteger").WithPluralName("AllorsIntegers").WithUnitTag(UnitTags.AllorsString).Build();

            Assert.AreEqual(4, metaPopulation.Composites.Count());
        }
コード例 #2
0
ファイル: ObjectTypeTest.cs プロジェクト: whesius/allors
        public void Associations()
        {
            this.Populate();

            var c1 = this.Population.C1;
            var c2 = this.Population.C2;
            var i1 = this.Population.I1;
            var i2 = this.Population.I2;

            Assert.AreEqual(0, c2.AssociationTypes.Count());

            var c1_c2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build();
            c1_c2.AssociationType.ObjectType = c1;
            c1_c2.RoleType.ObjectType = c2;

            Assert.AreEqual(1, c2.AssociationTypes.Count());

            var i1_i2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build();
            i1_i2.AssociationType.ObjectType = i1;
            i1_i2.RoleType.ObjectType = i2;

            Assert.AreEqual(2, c2.AssociationTypes.Count());

            var ix = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("ix").WithPluralName("ixs").Build();

            var c1_ix = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build();
            c1_ix.AssociationType.ObjectType = c1;
            c1_ix.RoleType.ObjectType = ix;

            Assert.AreEqual(2, c2.AssociationTypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c2).WithSupertype(ix).Build();

            Assert.AreEqual(3, c2.AssociationTypes.Count());
        }
コード例 #3
0
ファイル: InheritanceTest.cs プロジェクト: whesius/allors
        public void Validate()
        {
            var metaPopulation = new MetaPopulation();
            var domain = new Domain(metaPopulation, Guid.NewGuid()) { Name = "Domain" };

            var c1 = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("C1").WithPluralName("C1s").Build();

            var i1 = new InterfaceBuilder(domain, Guid.NewGuid()).WithSingularName("I1").WithPluralName("I1s").Build();
            var i2 = new InterfaceBuilder(domain, Guid.NewGuid()).WithSingularName("I2").WithPluralName("I2s").Build();

            Assert.IsTrue(metaPopulation.IsValid);

            // class with interface
            new InheritanceBuilder(domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i1).Build();

            var validation = metaPopulation.Validate();
            Assert.IsFalse(validation.ContainsErrors);

            // interface with interface
            new InheritanceBuilder(domain, Guid.NewGuid()).WithSubtype(i1).WithSupertype(i2).Build();

            validation = metaPopulation.Validate();
            Assert.IsFalse(validation.ContainsErrors);

            // Cyclic
            var cycle = new InheritanceBuilder(domain, Guid.NewGuid()).WithSubtype(i2).WithSupertype(i1).Build();

            validation = metaPopulation.Validate();
            Assert.IsTrue(validation.ContainsErrors);
            Assert.AreEqual(i1, validation.Errors[0].Source);
            Assert.AreEqual(1, validation.Errors[0].Members.Length);
            Assert.AreEqual("IComposite.Supertypes", validation.Errors[0].Members[0]);
            Assert.AreEqual(ValidationKind.Cyclic, validation.Errors[0].Kind);
        }
コード例 #4
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders){
            extenders.Add<IModelDetailView, IModelDetailViewXafLayoutControl>();
            var builder = new InterfaceBuilder(extenders);
            var assembly = builder.Build(CreateBuilderData(), GetPath(typeof(XafLayoutControl).Name));

            builder.ExtendInteface<IModelXafLayoutControl, XafLayoutControl>(assembly);

        }
コード例 #5
0
		public override void SetUp()
		{
			base.SetUp();
			root = CreateAndSaveItem("root", "root", null);
			engine.Host.DefaultSite.RootItemID = root.ID;
			item = CreateAndSaveItem("item", "item", root);
			engine.Host.DefaultSite.StartPageID = item.ID;
			builder = new InterfaceBuilder(engine);
		}
コード例 #6
0
        protected override void Build(InterfaceBuilder builder, IEnumerable<InterfaceBuilderData> interfaceBuilderDatas) {
            Type extenderType = typeof (ASPxScheduler);
            Assembly assembly = builder.Build(interfaceBuilderDatas, GetPath(extenderType.Name));

            builder.ExtendInteface(typeof (IModelOptionsSchedulerEx), extenderType, assembly);
            builder.ExtendInteface<IModelAppoitmentLabel, AppointmentLabel>(assembly);
            builder.ExtendInteface<ASPxAppointmentStorage, IAppoitmentStorageLabels>(assembly);
            builder.ExtendInteface<IModelAppoitmentStatus, AppointmentStatus>(assembly);
            builder.ExtendInteface<ASPxAppointmentStorage, IAppoitmentStorageStatuses>(assembly);
        }
コード例 #7
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelPivotSettings, IModelPivotSettingsEx>();
            extenders.Add<IModelListView, IModelListViewOptionsPivotGrid>();

            var builder = new InterfaceBuilder(extenders);
            var interfaceBuilderDatas = CreateBuilderData();
            var assembly = builder.Build(interfaceBuilderDatas, GetPath(typeof(PivotGridControl).Name));

            builder.ExtendInteface<IModelOptionsPivotGrid, PivotGridControl>(assembly);
        }
コード例 #8
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            var interfaceBuilder = new InterfaceBuilder(extenders);
            var componentType = typeof(DXMenuItem);
            var builderData = new InterfaceBuilderData(componentType) {
                Act = info => info.Name != "Id" && info.DXFilter()
            };
            var assembly = interfaceBuilder.Build(new List<InterfaceBuilderData> { builderData },GetPath(componentType.Name));

            interfaceBuilder.ExtendInteface<IModelSchedulerPopupMenuItem, DXMenuItem>(assembly);
        }
コード例 #9
0
        protected override void ExtendInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsGridView>();
            extenders.Add<IModelColumn, IModelColumnOptionsGridView>();

            var builder = new InterfaceBuilder(extenders);
            var assembly = BuildAssembly(builder, typeof(XafGridView), typeof(XafGridColumn));


            builder.ExtendInteface<IModelOptionsGridView, XafGridView>(assembly);
            builder.ExtendInteface<IModelOptionsColumnGridView, XafGridColumn>(assembly);
        }
コード例 #10
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsGridView>();
            extenders.Add<IModelColumn, IModelColumnOptionsGridView>();

            var builder = new InterfaceBuilder(extenders);

            var assembly = builder.Build(CreateBuilderData(), GetPath(typeof(ASPxGridView).Name));

            builder.ExtendInteface<IModelOptionsGridView, ASPxGridView>(assembly);
            builder.ExtendInteface<IModelOptionsColumnGridView, GridViewColumn>(assembly);
        }
コード例 #11
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders){
            extenders.Add<IModelSchedulerPopupMenuItem, IModelSchedulerPopupMenuItemEx>();
            var interfaceBuilder = new InterfaceBuilder(extenders);
            var builderData = new InterfaceBuilderData(typeof(SchedulerMenuItem)){Act = info =>{
                if (info.Name == "Id")
                    return false;
                return info.DXFilter();
            }
            };
            var assembly = interfaceBuilder.Build(new List<InterfaceBuilderData> { builderData }, GetPath(typeof(SchedulerMenuItem).Name));

            interfaceBuilder.ExtendInteface<IModelSchedulerPopupMenuItem,SchedulerMenuItem>(assembly);
        }
コード例 #12
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsScheduler>();

            var builder = new InterfaceBuilder(extenders);
            var interfaceBuilderDatas = CreateBuilderData();
            var assembly = builder.Build(interfaceBuilderDatas, GetPath(typeof(SchedulerControl).Name));

            builder.ExtendInteface<IModelOptionsSchedulerEx, SchedulerControl>(assembly);
            builder.ExtendInteface<IModelSchedulerPopupMenu, SchedulerPopupMenu>(assembly);
            builder.ExtendInteface<IModelAppoitmentLabel, AppointmentLabel>(assembly);
            builder.ExtendInteface<AppointmentStorage, IAppoitmentStorageLabels>(assembly);
            builder.ExtendInteface<IModelAppoitmentStatus, AppointmentStatus>(assembly);
            builder.ExtendInteface<AppointmentStorage, IAppoitmentStorageStatuses>(assembly);
        }
コード例 #13
0
        protected override void ExtendInterfaces(ModelInterfaceExtenders extenders) {

            extenders.Add<IModelListView, IModelListViewOptionsLayoutView>();
            extenders.Add<IModelColumn, IModelColumnOptionsLayoutView>();

            var builder = new InterfaceBuilder(extenders);
            var assembly = BuildAssembly(builder, typeof(XafLayoutView), typeof(LayoutViewColumn));


            builder.ExtendInteface<IModelOptionsLayoutView, XafLayoutView>(assembly);
            builder.ExtendInteface<IModelOptionsColumnLayoutView, LayoutViewColumn>(assembly);

            ExtendWithFont(extenders, builder, assembly);
        }
コード例 #14
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsTreeList>();
            extenders.Add<IModelRootNavigationItems, IModelListViewOptionsTreeListNavigation>();
            extenders.Add<IModelColumn, IModelColumnOptionsTreeListView>();


            var builder = new InterfaceBuilder(extenders);

            var assembly = builder.Build(CreateBuilderData(), GetPath(TreeListType().Name));

            builder.ExtendInteface(typeof(IModelOptionsTreeList), TreeListType(), assembly);
            builder.ExtendInteface(typeof(IModelOptionsColumnTreeListView), TreeListColumnType(), assembly);

            ExtendModelInterfaces(builder,assembly);
        }
コード例 #15
0
        protected override void ExtendInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsAdvBandedView>();
            extenders.Add<IModelColumn, IModelColumnOptionsAdvBandedView>();

            var builder = new InterfaceBuilder(extenders);

            var columnViewType = typeof(AdvBandedGridView);
            var interfaceBuilderDatas = GetInterfaceBuilderData(columnViewType, typeof(AdvBandedGridColumn)).ToList();
            interfaceBuilderDatas.Add(GetData(typeof(GridBand), typeof(DevExpress.XtraGrid.Views.BandedGrid.GridBand)));
            var assembly = builder.Build(interfaceBuilderDatas, GetPath(columnViewType.Name));

            builder.ExtendInteface<IModelOptionsAdvBandedView, AdvBandedGridView>(assembly);
            builder.ExtendInteface<IModelOptionsColumnAdvBandedView, AdvBandedGridColumn>(assembly);
            builder.ExtendInteface<IModelGridBand, GridBand>(assembly);
        }
コード例 #16
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            
            extenders.Add<IModelPropertyEditor, IModelPropertyHtmlEditor>();

            var builder = new InterfaceBuilder(extenders);
            var interfaceBuilderDatas = CreateBuilderData();
            var assembly = builder.Build(interfaceBuilderDatas, GetPath(typeof(ASPxHtmlEditor).Name));

            builder.ExtendInteface<IModelHtmlEditor, ASPxHtmlEditor>(assembly);
            builder.ExtendInteface<IModelHtmlEditorToolBar, HtmlEditorToolbar>(assembly);
            builder.ExtendInteface<IModelHtmlEditorShortcut, HtmlEditorShortcut>(assembly);
            builder.ExtendInteface<IModelHtmlEditorToolBarItem, HtmlEditorToolbarItem>(assembly);
            builder.ExtendInteface<IModelToolbarCustomDialogButton, ToolbarCustomDialogButton>(assembly);
            builder.ExtendInteface<IModelHtmlEditorCustomDialog, HtmlEditorCustomDialog>(assembly);
        }
コード例 #17
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelMemberViewItem, IModelMemberViewItemRepositoryItem>();

            var builder = new InterfaceBuilder(extenders);
            XafTypesInfo.Instance.LoadTypes(typeof(RepositoryItem).Assembly);
            var assembly = builder.Build(CreateBuilderData(), GetPath("RepositoryItem"));

            XafTypesInfo.Instance.LoadTypes(assembly);

            foreach (var typeInfo in RepositoryItemDescendants()) {
                string name = typeInfo.Name;
                var type = Type.GetType(typeof(IModelRepositoryItem).Namespace + ".IModel" + name, true);
                builder.ExtendInteface(type, typeInfo.Type, assembly);
            }

        }
コード例 #18
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsChart>();

            var builder = new InterfaceBuilder(extenders);
            XafTypesInfo.Instance.LoadTypes(typeof(Diagram).Assembly);

            var assembly = builder.Build(CreateBuilderData(), GetPath(typeof(ChartControl).Name));

            XafTypesInfo.Instance.LoadTypes(assembly);

            builder.ExtendInteface<IModelOptionsChart, ChartControl>(assembly);
            builder.ExtendInteface<IModelSeries, Series>(assembly);

            foreach (var typeInfo in DiagramDescendants()) {
                var type = Type.GetType(typeof(IModelChartDiargam).Namespace + ".IModelChart" + typeInfo.Name, true);
                builder.ExtendInteface(type, typeInfo.Type, assembly);
            }

        }
コード例 #19
0
ファイル: MetaPopulationTest.cs プロジェクト: whesius/allors
        public void Inheritances()
        {
            var domain = this.Domain;
            var superdomain = new Domain(this.MetaPopulation, Guid.NewGuid());
            domain.AddDirectSuperdomain(superdomain);

            var c1 = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("c1").WithPluralName("c1s").Build();
            var c2 = new ClassBuilder(superdomain, Guid.NewGuid()).WithSingularName("c2").WithPluralName("c2s").Build();

            var i1 = new InterfaceBuilder(domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();
            var i2 = new InterfaceBuilder(superdomain, Guid.NewGuid()).WithSingularName("i2").WithPluralName("i2s").Build();

            Assert.AreEqual(0, this.MetaPopulation.Inheritances.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i1).Build();

            Assert.AreEqual(1, this.MetaPopulation.Inheritances.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c2).WithSupertype(i2).Build();

            Assert.AreEqual(2, this.MetaPopulation.Inheritances.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i2).Build();

            Assert.AreEqual(3, this.MetaPopulation.Inheritances.Count());
        }
コード例 #20
0
        protected override void ExtendingModelInterfaces(InterfaceBuilder builder, Assembly assembly, ModelInterfaceExtenders extenders)
        {
            var calcType = builder.CalcType(typeof(LabelControlAppearanceObject), assembly);

            extenders.Add(calcType, typeof(IModelAppearanceFont));
        }
コード例 #21
0
        protected override void Generate(
            CodeWriter writer,
            DataTypeDescriptor descriptor,
            out string fileName)
        {
            fileName = descriptor.RuntimeType.Name;
            AbstractTypeBuilder typeBuilder;
            ConstructorBuilder? constructorBuilder = null;

            if (descriptor.IsInterface)
            {
                typeBuilder = InterfaceBuilder
                              .New()
                              .SetName(fileName);

                typeBuilder
                .AddProperty(__typename)
                .SetType(TypeNames.String);
            }
            else
            {
                ClassBuilder classBuilder = ClassBuilder
                                            .New()
                                            .SetName(fileName);

                typeBuilder = classBuilder;

                classBuilder
                .AddProperty(__typename)
                .SetPublic()
                .SetType(TypeNames.String);

                constructorBuilder = classBuilder
                                     .AddConstructor()
                                     .SetTypeName(fileName);

                constructorBuilder
                .AddParameter(_typename)
                .SetType(TypeNames.String)
                .SetName(_typename);

                constructorBuilder
                .AddCode(
                    AssignmentBuilder
                    .New()
                    .SetLefthandSide(__typename)
                    .SetRighthandSide(_typename)
                    .AssertNonNull());
            }

            // Add Properties to class
            foreach (PropertyDescriptor property in descriptor.Properties)
            {
                TypeReferenceBuilder propertyType = property.Type.Kind switch
                {
                    TypeKind.LeafType => property.Type.ToBuilder(),
                    TypeKind.DataType => property.Type.ToBuilder(property.Type.Name),
                    TypeKind.EntityType => property.Type.ToEntityIdBuilder(),
                    _ => throw new ArgumentOutOfRangeException()
                };

                typeBuilder
                .AddProperty(property.Name)
                .SetType(propertyType)
                .SetPublic();

                var parameterName = GetParameterName(property.Name);

                constructorBuilder?
                .AddParameter(parameterName)
                .SetType(propertyType)
                .SetDefault("null");

                constructorBuilder?
                .AddCode(AssignmentBuilder
                         .New()
                         .SetLefthandSide(property.Name)
                         .SetRighthandSide(parameterName));
            }

            // implement interfaces
            typeBuilder.AddImplementsRange(descriptor.Implements.Select(CreateDataTypeName));

            CodeFileBuilder
            .New()
            .SetNamespace(descriptor.RuntimeType.NamespaceWithoutGlobal)
            .AddType(typeBuilder)
            .Build(writer);
        }
    }
コード例 #22
0
 public void MustBeInterface()
 {
     Assert.Throws <ArgumentException>(() => InterfaceBuilder.CreateObject <Details>());
 }
コード例 #23
0
        public void IfAddPropertyIsCalledTwiceWithTheSamePropertyNameShouldThrowException()
        {
            var builder = new InterfaceBuilder(InterfaceName);

            builder.AddProperty <string>(FirstPropertyName).AddProperty <string>(FirstPropertyName).GetDeclaration();
        }
コード例 #24
0
ファイル: ObjectTypeTest.cs プロジェクト: whesius/allors
        public void DirectSupertypes()
        {
            var c1 = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("c1").WithPluralName("c1s").Build();
            var c2 = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("c2").WithPluralName("c2s").Build();

            var i1 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();
            var i2 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i2").WithPluralName("i2s").Build();

            Assert.AreEqual(0, c1.DirectSupertypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i1).Build();

            Assert.AreEqual(1, c1.DirectSupertypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i2).Build();

            Assert.AreEqual(2, c1.DirectSupertypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c2).WithSupertype(i1).Build();

            Assert.AreEqual(2, c1.DirectSupertypes.Count());
        }
コード例 #25
0
        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {
            extenders.Add<IModelListView, IModelListViewOptionsScheduler>();

            var builder = new InterfaceBuilder(extenders);
            var interfaceBuilderDatas = CreateBuilderData();
            
            Build(builder, interfaceBuilderDatas);
        }
コード例 #26
0
 private T CreateInstance <T>()
 {
     return(typeof(T).IsInterface
                 ? InterfaceBuilder.CreateObject <T>()
                 : _dependencyInjectionContainer.GetInstance <T>());
 }
コード例 #27
0
 protected override void ExtendModelInterfaces(InterfaceBuilder builder, Assembly assembly){
     base.ExtendModelInterfaces(builder, assembly);
     ExtendWithFont(builder.Extenders,builder, assembly );
 }
コード例 #28
0
		public StatisticsInterfaceModule(InterfaceBuilder builder, ConfigurationManagerWrapper config)
		{
			this.config = config;
			builder.InterfaceBuilt += builder_InterfaceBuilt;
		}
コード例 #29
0
 public static InterfaceBuilder Add(string name) => InterfaceBuilder.AddInterface(name);
コード例 #30
0
 protected virtual void ExtendModelInterfaces(InterfaceBuilder builder, Assembly assembly){
     
 }
コード例 #31
0
 protected string GeneratedEmptyInterfacesCode()
 {
     return(InterfaceBuilder.GeneratedEmptyInterfacesCode(RepositoryItemDescendants(),
                                                          typeof(IModelRepositoryItem), (info, type, arg3) =>
                                                          InterfaceBuilder.GeneratedDisplayNameCode(arg3.Replace("IModelRepositoryItem", ""))));
 }
コード例 #32
0
 protected virtual void ExtendModelInterfaces(InterfaceBuilder builder, Assembly assembly)
 {
 }
コード例 #33
0
ファイル: MetaPopulationTest.cs プロジェクト: whesius/allors
        public void Find()
        {
            var metapopulation = new MetaPopulation();

            var domain = new Domain(metapopulation, Guid.NewGuid());
            var superdomain = new Domain(metapopulation, Guid.NewGuid());
            domain.AddDirectSuperdomain(superdomain);

            var unitId = UnitIds.StringId;
            var interfaceId = Guid.NewGuid();
            var classId = Guid.NewGuid();
            var inheritanceId = Guid.NewGuid();
            var relationTypeId = Guid.NewGuid();
            var associationTypeId = Guid.NewGuid();
            var roleTypeId = Guid.NewGuid();

            var superunitId = UnitIds.IntegerId;
            var superinterfaceId = Guid.NewGuid();
            var superclassId = Guid.NewGuid();
            var superinheritanceId = Guid.NewGuid();
            var superrelationTypeId = Guid.NewGuid();
            var superassociationTypeId = Guid.NewGuid();
            var superroleTypeId = Guid.NewGuid();

            Assert.IsNull(metapopulation.Find(unitId));
            Assert.IsNull(metapopulation.Find(interfaceId));
            Assert.IsNull(metapopulation.Find(classId));
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new UnitBuilder(domain, unitId).WithSingularName("AllorsString").WithPluralName("AllorsStrings").WithUnitTag(UnitTags.AllorsString).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNull(metapopulation.Find(interfaceId));
            Assert.IsNull(metapopulation.Find(classId));
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @interface = new InterfaceBuilder(domain, interfaceId).WithSingularName("Interface").WithPluralName("Interfaces").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNull(metapopulation.Find(classId));
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @class = new ClassBuilder(domain, classId).WithSingularName("Class").WithPluralName("Classes").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new InheritanceBuilder(domain, inheritanceId).WithSubtype(@class).WithSupertype(@interface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new RelationTypeBuilder(domain, relationTypeId, associationTypeId, roleTypeId).WithObjectTypes(@class, @interface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new UnitBuilder(superdomain, superunitId).WithSingularName("AllorsInteger").WithPluralName("AllorsIntegers").WithUnitTag(UnitTags.AllorsInteger).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @superinterface = new InterfaceBuilder(superdomain, superinterfaceId).WithSingularName("SuperInterface").WithPluralName("SuperInterfaces").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @superclass = new ClassBuilder(superdomain, superclassId).WithSingularName("SuperClass").WithPluralName("SuperClasses").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(superclassId) as Class);
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new InheritanceBuilder(superdomain, superinheritanceId).WithSubtype(@superclass).WithSupertype(@superinterface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(superclassId) as Class);
            Assert.IsNotNull(metapopulation.Find(superinheritanceId) as Inheritance);
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new RelationTypeBuilder(superdomain, superrelationTypeId, superassociationTypeId, superroleTypeId).WithObjectTypes(@superclass, @superinterface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(superclassId) as Class);
            Assert.IsNotNull(metapopulation.Find(superinheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(superrelationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(superassociationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(superroleTypeId) as RoleType);
        }
コード例 #34
0
 public void SetUp()
 {
     _interfaceBuilder = new InterfaceBuilder("TestInterface", "MyNamespace");
 }
コード例 #35
0
 public TargetingModule(InterfaceBuilder builder, ConfigurationManagerWrapper config, DetectorBase[] detectors)
 {
     this.config             = config;
     this.detectors          = detectors;
     builder.InterfaceBuilt += builder_InterfaceBuilt;
 }
コード例 #36
0
        protected override void Generate(
            CodeWriter writer,
            DataTypeDescriptor descriptor,
            out string fileName,
            out string?path)
        {
            fileName = descriptor.RuntimeType.Name;
            path     = State;

            AbstractTypeBuilder typeBuilder;
            ConstructorBuilder? constructorBuilder = null;

            if (descriptor.IsInterface)
            {
                typeBuilder = InterfaceBuilder
                              .New()
                              .SetComment(descriptor.Documentation)
                              .SetName(fileName);

                typeBuilder
                .AddProperty(WellKnownNames.TypeName)
                .SetType(TypeNames.String);
            }
            else
            {
                ClassBuilder classBuilder = ClassBuilder
                                            .New()
                                            .SetComment(descriptor.Documentation)
                                            .SetName(fileName);

                typeBuilder = classBuilder;

                classBuilder
                .AddProperty(WellKnownNames.TypeName)
                .SetPublic()
                .SetType(TypeNames.String);

                constructorBuilder = classBuilder
                                     .AddConstructor()
                                     .SetTypeName(fileName);

                constructorBuilder
                .AddParameter(WellKnownNames.TypeName)
                .SetType(TypeNames.String)
                .SetName(WellKnownNames.TypeName);

                constructorBuilder
                .AddCode(
                    AssignmentBuilder
                    .New()
                    .SetLefthandSide("this." + WellKnownNames.TypeName)
                    .SetRighthandSide(WellKnownNames.TypeName)
                    .AssertNonNull());
            }

            // Add Properties to class
            foreach (PropertyDescriptor property in descriptor.Properties)
            {
                if (property.Name.Value.EqualsOrdinal(WellKnownNames.TypeName))
                {
                    continue;
                }

                TypeReferenceBuilder propertyType = property.Type.ToStateTypeReference();

                typeBuilder
                .AddProperty(property.Name)
                .SetComment(property.Description)
                .SetType(propertyType)
                .SetPublic();

                var parameterName = GetParameterName(property.Name);

                constructorBuilder?
                .AddParameter(parameterName)
                .SetType(propertyType)
                .SetDefault("null");

                constructorBuilder?
                .AddCode(AssignmentBuilder
                         .New()
                         .SetLefthandSide(property.Name)
                         .SetRighthandSide(parameterName));
            }

            // implement interfaces
            typeBuilder.AddImplementsRange(descriptor.Implements.Select(CreateDataTypeName));

            CodeFileBuilder
            .New()
            .SetNamespace(descriptor.RuntimeType.NamespaceWithoutGlobal)
            .AddType(typeBuilder)
            .Build(writer);
        }
コード例 #37
0
 protected Assembly BuildAssembly(InterfaceBuilder builder, Type columnViewType, Type gridColumnType) {
     var interfaceBuilderDatas = GetInterfaceBuilderData(columnViewType, gridColumnType);
     return builder.Build(interfaceBuilderDatas, GetPath(columnViewType.Name));
 }
コード例 #38
0
        public MessageDistributor(
            NsqBus bus,
            IObjectBuilder objectBuilder,
            ILogger logger,
            MessageHandlerMetadata messageHandlerMetadata
            )
        {
            if (bus == null)
            {
                throw new ArgumentNullException("bus");
            }
            if (objectBuilder == null)
            {
                throw new ArgumentNullException("objectBuilder");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (messageHandlerMetadata == null)
            {
                throw new ArgumentNullException("messageHandlerMetadata");
            }

            _bus           = bus;
            _objectBuilder = objectBuilder;
            _logger        = logger;

            _serializer     = messageHandlerMetadata.Serializer;
            _handlerType    = messageHandlerMetadata.HandlerType;
            _messageType    = messageHandlerMetadata.MessageType;
            _messageAuditor = messageHandlerMetadata.MessageAuditor;
            _topic          = messageHandlerMetadata.Topic;
            _channel        = messageHandlerMetadata.Channel;

            var possibleMethods = _handlerType.GetMethods().Where(p => p.Name == "Handle" && !p.IsGenericMethod);

            foreach (var possibleMethod in possibleMethods)
            {
                var parameters = possibleMethod.GetParameters();
                if (parameters.Length == 1 && parameters[0].ParameterType == _messageType)
                {
                    _handleMethod = possibleMethod;
                    break;
                }
            }

            if (_handleMethod == null)
            {
                throw new Exception(string.Format("Handle({0}) not found on {1}", _messageType, _handlerType));
            }

            if (!_messageType.IsInterface)
            {
                _concreteMessageType = _messageType;
            }
            else
            {
                _concreteMessageType = InterfaceBuilder.CreateType(_messageType);
            }
        }
コード例 #39
0
 protected abstract void Build(InterfaceBuilder builder, IEnumerable<InterfaceBuilderData> interfaceBuilderDatas);
コード例 #40
0
        public void Find()
        {
            var metapopulation = new MetaPopulation();

            var domain      = new Domain(metapopulation, Guid.NewGuid());
            var superdomain = new Domain(metapopulation, Guid.NewGuid());

            domain.AddDirectSuperdomain(superdomain);

            var unitId            = UnitIds.StringId;
            var interfaceId       = Guid.NewGuid();
            var classId           = Guid.NewGuid();
            var inheritanceId     = Guid.NewGuid();
            var relationTypeId    = Guid.NewGuid();
            var associationTypeId = Guid.NewGuid();
            var roleTypeId        = Guid.NewGuid();

            var superunitId            = UnitIds.IntegerId;
            var superinterfaceId       = Guid.NewGuid();
            var superclassId           = Guid.NewGuid();
            var superinheritanceId     = Guid.NewGuid();
            var superrelationTypeId    = Guid.NewGuid();
            var superassociationTypeId = Guid.NewGuid();
            var superroleTypeId        = Guid.NewGuid();

            Assert.IsNull(metapopulation.Find(unitId));
            Assert.IsNull(metapopulation.Find(interfaceId));
            Assert.IsNull(metapopulation.Find(classId));
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new UnitBuilder(domain, unitId).WithSingularName("AllorsString").WithPluralName("AllorsStrings").WithUnitTag(UnitTags.AllorsString).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNull(metapopulation.Find(interfaceId));
            Assert.IsNull(metapopulation.Find(classId));
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @interface = new InterfaceBuilder(domain, interfaceId).WithSingularName("Interface").WithPluralName("Interfaces").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNull(metapopulation.Find(classId));
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @class = new ClassBuilder(domain, classId).WithSingularName("Class").WithPluralName("Classes").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNull(metapopulation.Find(inheritanceId));
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new InheritanceBuilder(domain, inheritanceId).WithSubtype(@class).WithSupertype(@interface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNull(metapopulation.Find(relationTypeId));
            Assert.IsNull(metapopulation.Find(associationTypeId));
            Assert.IsNull(metapopulation.Find(roleTypeId));

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new RelationTypeBuilder(domain, relationTypeId, associationTypeId, roleTypeId).WithObjectTypes(@class, @interface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNull(metapopulation.Find(superunitId));
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new UnitBuilder(superdomain, superunitId).WithSingularName("AllorsInteger").WithPluralName("AllorsIntegers").WithUnitTag(UnitTags.AllorsInteger).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNull(metapopulation.Find(superinterfaceId));
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @superinterface = new InterfaceBuilder(superdomain, superinterfaceId).WithSingularName("SuperInterface").WithPluralName("SuperInterfaces").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNull(metapopulation.Find(superclassId));
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            var @superclass = new ClassBuilder(superdomain, superclassId).WithSingularName("SuperClass").WithPluralName("SuperClasses").Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(superclassId) as Class);
            Assert.IsNull(metapopulation.Find(superinheritanceId));
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new InheritanceBuilder(superdomain, superinheritanceId).WithSubtype(@superclass).WithSupertype(@superinterface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(superclassId) as Class);
            Assert.IsNotNull(metapopulation.Find(superinheritanceId) as Inheritance);
            Assert.IsNull(metapopulation.Find(superrelationTypeId));
            Assert.IsNull(metapopulation.Find(superassociationTypeId));
            Assert.IsNull(metapopulation.Find(superroleTypeId));

            new RelationTypeBuilder(superdomain, superrelationTypeId, superassociationTypeId, superroleTypeId).WithObjectTypes(@superclass, @superinterface).Build();

            Assert.IsNotNull(metapopulation.Find(unitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(interfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(classId) as Class);
            Assert.IsNotNull(metapopulation.Find(inheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(relationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(associationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(roleTypeId) as RoleType);

            Assert.IsNotNull(metapopulation.Find(superunitId) as Unit);
            Assert.IsNotNull(metapopulation.Find(superinterfaceId) as Interface);
            Assert.IsNotNull(metapopulation.Find(superclassId) as Class);
            Assert.IsNotNull(metapopulation.Find(superinheritanceId) as Inheritance);
            Assert.IsNotNull(metapopulation.Find(superrelationTypeId) as RelationType);
            Assert.IsNotNull(metapopulation.Find(superassociationTypeId) as AssociationType);
            Assert.IsNotNull(metapopulation.Find(superroleTypeId) as RoleType);
        }
コード例 #41
0
        public void IfAddVoidMethodIsCalledTwiceWithTheSameNameAnExceptionShouldBeenThrown()
        {
            var builder = new InterfaceBuilder(InterfaceName);

            builder.AddVoidMethod(FunctionName, new ParameterItem[] { }).AddVoidMethod(FunctionName, new ParameterItem[] { }).GetDeclaration();
        }
コード例 #42
0
ファイル: ObjectTypeTest.cs プロジェクト: whesius/allors
        public void Supertypes()
        {
            var c1 = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("c1").WithPluralName("c1s").Build();
            var c2 = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("c1").WithPluralName("c1s").Build();

            var i1 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();
            var i2 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i2").WithPluralName("i2s").Build();

            var i12 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();

            Assert.AreEqual(0, c1.Supertypes.Count());
            Assert.AreEqual(0, c2.Supertypes.Count());
            Assert.AreEqual(0, i1.Supertypes.Count());
            Assert.AreEqual(0, i2.Supertypes.Count());
            Assert.AreEqual(0, i12.Supertypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i1).Build();

            Assert.AreEqual(1, c1.Supertypes.Count());
            Assert.Contains(i1, c1.Supertypes.ToList());
            Assert.AreEqual(0, c2.Supertypes.Count());
            Assert.AreEqual(0, i1.Supertypes.Count());
            Assert.AreEqual(0, i2.Supertypes.Count());
            Assert.AreEqual(0, i12.Supertypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(i1).WithSupertype(i12).Build();

            Assert.AreEqual(2, c1.Supertypes.Count());
            Assert.Contains(i1, c1.Supertypes.ToList());
            Assert.Contains(i12, c1.Supertypes.ToList());
            Assert.AreEqual(0, c2.Supertypes.Count());
            Assert.AreEqual(1, i1.Supertypes.Count());
            Assert.Contains(i12, i1.Supertypes.ToList());
            Assert.AreEqual(0, i2.Supertypes.Count());
            Assert.AreEqual(0, i12.Supertypes.Count());

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(i2).WithSupertype(i12).Build();

            Assert.AreEqual(2, c1.Supertypes.Count());
            Assert.Contains(i1, c1.Supertypes.ToList());
            Assert.Contains(i12, c1.Supertypes.ToList());
            Assert.AreEqual(0, c2.Supertypes.Count());
            Assert.AreEqual(1, i1.Supertypes.Count());
            Assert.Contains(i12, i1.Supertypes.ToList());
            Assert.AreEqual(1, i2.Supertypes.Count());
            Assert.Contains(i12, i2.Supertypes.ToList());
            Assert.AreEqual(0, i12.Supertypes.Count());
        }
コード例 #43
0
        protected Assembly BuildAssembly(InterfaceBuilder builder, Type columnViewType, Type gridColumnType)
        {
            var interfaceBuilderDatas = GetInterfaceBuilderData(columnViewType, gridColumnType);

            return(builder.Build(interfaceBuilderDatas, GetPath(columnViewType.Name)));
        }
コード例 #44
0
        protected override void Generate(
            CodeWriter writer,
            DataTypeDescriptor descriptor,
            out string fileName)
        {
            // Setup class
            fileName = descriptor.RuntimeType.Name;
            AbstractTypeBuilder typeBuilder;
            ConstructorBuilder? constructorBuilder = null;

            var typenamePropName = "__typename";

            if (descriptor.IsInterface)
            {
                typeBuilder = new InterfaceBuilder()
                              .SetName(fileName);

                typeBuilder.AddProperty(PropertyBuilder.New()
                                        .SetName(typenamePropName)
                                        .SetType(TypeNames.String));
            }
            else
            {
                var(classBuilder, constructorBuilder2) = CreateClassBuilder();
                constructorBuilder2
                .SetTypeName(fileName)
                .SetAccessModifier(AccessModifier.Public);

                constructorBuilder = constructorBuilder2;

                classBuilder.AddProperty(
                    PropertyBuilder
                    .New()
                    .SetAccessModifier(AccessModifier.Public)
                    .SetName(typenamePropName)
                    .SetType(TypeNames.String));

                var paramName  = "typename";
                var assignment = AssignmentBuilder
                                 .New()
                                 .SetLefthandSide(typenamePropName)
                                 .SetRighthandSide(paramName)
                                 .AssertNonNull();

                constructorBuilder.AddParameter(
                    ParameterBuilder
                    .New()
                    .SetType(TypeNames.String)
                    .SetName(paramName))
                .AddCode(assignment);

                classBuilder.SetName(fileName);
                typeBuilder = classBuilder;
            }

            // Add Properties to class
            foreach (PropertyDescriptor item in descriptor.Properties)
            {
                var itemParamName = GetParameterName(item.Name);
                var assignment    = AssignmentBuilder
                                    .New()
                                    .SetLefthandSide(item.Name)
                                    .SetRighthandSide(itemParamName);

                var paramType = item.Type.IsEntityType()
                    ? item.Type.ToEntityIdBuilder()
                    : item.Type.ToBuilder();
                constructorBuilder?.AddParameter(
                    ParameterBuilder
                    .New()
                    .SetType(paramType)
                    .SetName(itemParamName)
                    .SetDefault("null"))
                .AddCode(assignment);

                switch (item.Type.Kind)
                {
                case TypeKind.LeafType:
                    typeBuilder.AddProperty(item.Name)
                    .SetType(item.Type.ToBuilder())
                    .SetAccessModifier(AccessModifier.Public);
                    break;

                case TypeKind.DataType:
                    typeBuilder.AddProperty(item.Name)
                    // TODO this looks wrong. We should avoid nameoverride and delete it
                    .SetType(item.Type.ToBuilder(item.Type.Name))
                    .SetAccessModifier(AccessModifier.Public);
                    break;

                case TypeKind.EntityType:
                    typeBuilder.AddProperty(item.Name)
                    .SetType(item.Type.ToBuilder().SetName(TypeNames.EntityId))
                    .SetAccessModifier(AccessModifier.Public);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            foreach (NameString superType in descriptor.Implements)
            {
                typeBuilder.AddImplements(CreateDataTypeName(superType));
            }

            CodeFileBuilder
            .New()
            .SetNamespace(descriptor.RuntimeType.NamespaceWithoutGlobal)
            .AddType(typeBuilder)
            .Build(writer);
        }
コード例 #45
0
 /// <summary>
 /// 加入成员
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public virtual TBuilder With(InterfaceBuilder builder)
 {
     return(_TBuilder);
 }
コード例 #46
0
ファイル: ObjectTypeTest.cs プロジェクト: whesius/allors
        public void ExclusiveLeafClass()
        {
            var c1 = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("c1").WithPluralName("c1s").Build();
            var c2 = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("c2").WithPluralName("c2s").Build();

            var i1 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();
            var i2 = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("i2").WithPluralName("i2s").Build();

            Assert.AreEqual(c1, c1.ExclusiveLeafClass);
            Assert.AreEqual(c2, c2.ExclusiveLeafClass);
            Assert.IsNull(i1.ExclusiveLeafClass);
            Assert.IsNull(i2.ExclusiveLeafClass);

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i1).Build();

            Assert.AreEqual(c1, c1.ExclusiveLeafClass);
            Assert.AreEqual(c2, c2.ExclusiveLeafClass);
            Assert.AreEqual(c1, i1.ExclusiveLeafClass);
            Assert.IsNull(i2.ExclusiveLeafClass);

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c2).WithSupertype(i2).Build();

            Assert.AreEqual(c1, c1.ExclusiveLeafClass);
            Assert.AreEqual(c2, c2.ExclusiveLeafClass);
            Assert.AreEqual(c1, i1.ExclusiveLeafClass);
            Assert.AreEqual(c2, i2.ExclusiveLeafClass);

            new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(i2).Build();

            Assert.AreEqual(c1, c1.ExclusiveLeafClass);
            Assert.AreEqual(c2, c2.ExclusiveLeafClass);
            Assert.AreEqual(c1, i1.ExclusiveLeafClass);
            Assert.IsNull(i2.ExclusiveLeafClass);
        }
コード例 #47
0
 public CollaborationInterfaceModule(InterfaceBuilder builder, ConfigurationManagerWrapper config)
 {
     this.config             = config;
     builder.InterfaceBuilt += builder_InterfaceBuilt;
 }
コード例 #48
0
ファイル: Proxy.cs プロジェクト: Const-me/ComLightInterop
        /// <summary>Build class factory function for a proxy type which does use custom marshallers.</summary>
        static Func <IntPtr, IntPtr[], Delegate[], object> buildCustomFactory(Type tProxy, Expression[] baseCtorArgs, InterfaceBuilder ib)
        {
            ConstructorInfo     ci          = tProxy.GetConstructor(ib.constructorArgumentTypes);
            ParameterExpression peVtbl      = Expression.Parameter(typeof(IntPtr[]), "vtable");
            ParameterExpression peDelegates = Expression.Parameter(typeof(Delegate[]), "delegates");

            CustomMarshallerMethod[] customMethods = ib.customMethods;
            Expression[]             ctorArgs      = new Expression[baseCtorArgs.Length + customMethods.Length];
            Array.Copy(baseCtorArgs, ctorArgs, baseCtorArgs.Length);
            for (int i = 0; i < customMethods.Length; i++)
            {
                Expression eItem = Expression.ArrayIndex(peDelegates, Expression.Constant(i));
                eItem = Expression.Convert(eItem, customMethods[i].tManagedDelegate);
                ctorArgs[baseCtorArgs.Length + i] = eItem;
            }
            var        eNew   = Expression.New(ci, ctorArgs);
            Expression eCast  = Expression.Convert(eNew, typeof(object));
            var        lambda = Expression.Lambda <Func <IntPtr, IntPtr[], Delegate[], object> >(eCast, paramNativeObject, peVtbl, peDelegates);

            return(lambda.Compile());
        }
コード例 #49
0
ファイル: MetaPopulationTest.cs プロジェクト: whesius/allors
        public void RelationTypes()
        {
            var metaPopulation = new MetaPopulation();
            var domain = new Domain(metaPopulation, Guid.NewGuid());
            var superdomain = new Domain(metaPopulation, Guid.NewGuid());
            domain.AddDirectSuperdomain(superdomain);

            var c1 = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("c1").WithPluralName("c1s").Build();
            var c2 = new ClassBuilder(superdomain, Guid.NewGuid()).WithSingularName("c2").WithPluralName("c2s").Build();

            var i1 = new InterfaceBuilder(domain, Guid.NewGuid()).WithSingularName("i1").WithPluralName("i1s").Build();
            var i2 = new InterfaceBuilder(superdomain, Guid.NewGuid()).WithSingularName("i2").WithPluralName("i2s").Build();

            Assert.AreEqual(0, metaPopulation.RelationTypes.Count());

            new RelationTypeBuilder(domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).WithObjectTypes(c1, i1).Build();

            Assert.AreEqual(1, metaPopulation.RelationTypes.Count());

            new RelationTypeBuilder(superdomain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).WithObjectTypes(c1, i2).Build();

            Assert.AreEqual(2, metaPopulation.RelationTypes.Count());

            new RelationTypeBuilder(domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).WithObjectTypes(c1, c2).Build();

            Assert.AreEqual(3, metaPopulation.RelationTypes.Count());

            new MethodTypeBuilder(domain, Guid.NewGuid()).WithName("Method1").Build();

            Assert.AreEqual(3, metaPopulation.RelationTypes.Count());

            new MethodTypeBuilder(superdomain, Guid.NewGuid()).WithName("Method2").Build();

            Assert.AreEqual(3, metaPopulation.RelationTypes.Count());
        }
コード例 #50
0
 protected abstract void Build(InterfaceBuilder builder, IEnumerable <InterfaceBuilderData> interfaceBuilderDatas);
コード例 #51
0
 protected override void ExtendModelInterfaces(InterfaceBuilder builder, Assembly assembly)
 {
     base.ExtendModelInterfaces(builder, assembly);
     ExtendWithFont(builder.Extenders, builder, assembly);
 }
コード例 #52
0
 public BuilderType AddInnerInterface(InterfaceBuilder builder)
 {
     _members.Add(builder);
     return((BuilderType)this);
 }