Exemple #1
0
        private static void BuildTreeFromSuites(this HtmlTextWriter writer, IEnumerable<NunitGoSuite> suites)
        {
            foreach (var suite in suites)
            {
                var tests = suite.Tests;
                var allSuiteTests = suite.GetTests();
                var count = allSuiteTests.Count;
                var passedCount = allSuiteTests.Count(x => x.IsSuccess());
                var suiteName = suite.Name + " (Tests: " + passedCount + @"/" + count + ")";

                writer
                    .TreeItem(suiteName, () => writer
                        .Css(HtmlTextWriterStyle.PaddingLeft, "1em")
                        .Ul(() => writer
                            .ForEach(tests, test => writer
                                .Id(test.Guid.ToString())
                                .Class("border-bottom")
                                .Li(() => writer
                                    .Text("Test: ")
                                    .TooltippedSpan("Test result: " + Environment.NewLine + test.Result, () => writer
                                            .Class("octicon octicon-primitive-square")
                                            .Color(test.GetColor())
                                            .Span()
                                        )
                                    .Text(" ")
                                    .Href(test.TestHrefRelative)
                                        .A(() => writer
                                            .TooltippedSpan("View test page", () => writer
                                                .Class("octicon octicon-eye")
                                                .Color("black")
                                                .Span()
                                            )
                                        )
                                    .Span("  " + test.Name + " (" + test.DateTimeStart.ToString("dd.MM.yy HH:mm:ss") + " - " +
                                        test.DateTimeFinish.ToString("dd.MM.yy HH:mm:ss") + ")")
                                    .Float("right")
                                    .Class("border-left border-right px-3")
                                    .BackgroundColor(test.GetColor())
                                    .Width("15%")
                                    .B(test.Result)
                                    .Float("right")
                                    .Class("border-left px-3")
                                    .B("Result: ")
                                )
                            )
                            .If(suite.Suites.Any(), () => writer
                                .BuildTreeFromSuites(suite.Suites)
                            )
                        )
                    );
            }
        }
 internal static ICodeBlock Class(this ICodeBlock pCodeBlock, string pName, 
     bool Public = false, 
     bool Private = false, 
     bool Protected = false, 
     bool Internal = false, 
     bool ProtectedInternal = false, 
     bool Static = false, 
     bool Partial = false, 
     bool Abstract = false, 
     bool Sealed = false)
 {
     return pCodeBlock.Class(
         StringHelper.Modifiers(
         Public: Public, 
         Private: Private, 
         Protected: Protected, 
         Internal: Internal, 
         ProtectedInternal: ProtectedInternal, 
         Static: Static,
         Partial: Partial,
         Abstract: Abstract,
         Sealed: Sealed
         )
         , pName
         ,"");
 }
        public static CodeTypeDeclaration TinyMceSettingsAttribute(
            this AssemblyDefinition assembly,
            string updateSettingsImplementation,
            string matchMethodBody,
            string className = "TinyMceSettingsAttribute",
            bool overwriteExistingSettings = true)
        {
            var type = assembly.Class(className)
                .Inheriting<Attribute>()
                .Implementing<IUpdatePropertySettings<TinyMCESettings>>()
                .PublicMethod(x =>
                        x.Named("UpdateSettings")
                            .Parameter<TinyMCESettings>("settings")
                            .Body(updateSettingsImplementation))
                .PublicMethod<bool>(x =>
                              x.Named("MatchesUpdatedSettings")
                                  .Parameter<TinyMCESettings>("settings")
                                  .Body(matchMethodBody))
                .PublicMethod<int>(x =>
                             x.Named("GetSettingsHashCode")
                                 .Parameter<TinyMCESettings>("settings")
                                 .Body("return settings.Width;"))
                .Property<bool>(x =>
                                x.Named("OverWriteExistingSettings")
                                    .Returning(overwriteExistingSettings));

            return type;
        }
 public static CodeTypeDeclaration MigrationClass(this AssemblyDefinition assembly)
 {
     return assembly.Class(DefaultMigrationName)
         .Inheriting<Migration>()
         .Constructor(x =>
                      x.Parameter<IMigrationContext>("context")
                          .PassToBase("context"));
 }
Exemple #5
0
        public static void WithMappings(this ModelMapper mapper, Configuration configuration)
        {
            // Initially the Product table had a FK to Category
            // and Category table had a FK to Product.
            mapper.Class<Product>(map => map.Set(x => x.Categories,
                                                 set =>  {
                                                             set.Key(key =>
                                                             {
                                                                 key.Column("CategoryId");
                                                                 key.ForeignKey("FK_Product_Category_CategoryId");
                                                             });
                                                             set.Table("Product_Category");
                                                         },
                                                         ce => ce.ManyToMany(m => m.Column("ProductId"))));

            mapper.Class<Category>(map => map.Set(x => x.Products,
                                                set =>  {   set.Key(key =>
                                                            {
                                                                key.Column("ProductId");
                                                                key.ForeignKey(
                                                                    "FK_Product_Category_ProductId");
                                                            });
                                                            set.Table("Product_Category");
                                                        },
                                                  ce => ce.ManyToMany(m => m.Column("CategoryId"))));

            // Initially the SubCategories and Parent were NOT mapped.
            mapper.Class<Category>(map => map.Set(x => x.SubCategories,
                                            set =>  {   set.Key(k => k.Column("ParentCategoryId"));
                                                        set.Inverse(true);
                                                    },
                                                    ce => ce.OneToMany()));

            mapper.Class<Category>(map => map.ManyToOne(x => x.Parent,
                                            manyToOne =>    {
                                                                manyToOne.Column("ParentCategoryId");
                                                                manyToOne.Lazy(LazyRelation.NoLazy);
                                                                manyToOne.NotNullable(false);
                                                            }));

            var mapping = mapper.CompileMappingFor(typeof(Entity).Assembly.GetExportedTypes());
            configuration.AddDeserializedMapping(mapping, "l337");
        }
        public static CodeTypeDeclaration GlobalPropertySettingsClass(
            this AssemblyDefinition assembly,
            string className = "MySettings",
            string displayName = "Settings display name",
            string description = "Description",
            bool? isDefault = null,
            bool overwriteExistingSettings = true,
            string updateSettingsImplementation = "",
            string matchMethodBody = "return DisplayName.Equals(wrapper.DisplayName);")
        {
            var isDefaultString = isDefault.ToString().ToLower();
            if(isDefault == null)
            {
                isDefaultString = "null";
            }

            var type = assembly.Class(className)
                .Implementing<IUpdateGlobalPropertySettings<TinyMCESettings>>()
                .PublicMethod(x =>
                        x.Named("UpdateSettings")
                            .Parameter<TinyMCESettings>("settings")
                            .Body(updateSettingsImplementation))
                .Property<string>(x =>
                                  x.Named("DisplayName")
                                      .Returning(displayName))
                .Property<bool?>(x =>
                                 x.Named("IsDefault")
                                     .GetterBody("return {0};", isDefaultString))
                .Property<string>(x => 
                                  x.Named("Description")
                                      .Returning(description))
                .PublicMethod<bool>(x =>
                              x.Named("Match")
                                  .Parameter<PropertySettingsWrapper>("wrapper")
                                  .Body(matchMethodBody))
                .PublicMethod<int>(x =>
                             x.Named("GetSettingsHashCode")
                                 .Parameter<TinyMCESettings>("settings")
                                 .Body("return settings.Width;"))
                .Property<bool>(x =>
                                x.Named("OverWriteExistingSettings")
                                    .Returning(overwriteExistingSettings));

            return type;
        }
        public static void WithConventions(this ConventionModelMapper mapper)
        {
            var baseEntityType = typeof (Entity);
            mapper.IsEntity((type, declared) => baseEntityType.IsAssignableFrom(type) && baseEntityType != type && !type.IsInterface);
            mapper.IsRootEntity((type, declared) => baseEntityType.Equals(type.BaseType));

            mapper.BeforeMapManyToOne += (modelInspector, propertyPath, map) => map.Column(propertyPath.LocalMember.GetPropertyOrFieldType().Name + "Id");
            //mapper.BeforeMapManyToOne += (modelInspector, propertyPath, map) => map.Cascade(Cascade.Persist);
            mapper.BeforeMapBag += (modelInspector, propertyPath, map) => map.Key(keyMapper => keyMapper.Column(propertyPath.GetContainerEntity(modelInspector).Name + "Id"));
            //mapper.BeforeMapBag += (modelInspector, propertyPath, map) => map.Cascade(Cascade.All);

            mapper.BeforeMapClass += (modelInspector, type, classCustomizer) =>
                                         {
                                             classCustomizer.Id(c => c.Column(type.Name + "Id"));
                                             classCustomizer.Id(c => c.Generator(Generators.GuidComb));
                                             classCustomizer.Table(ReservedTableNameHandler(type));
                                         };

            mapper.Class<Entity>(map =>  {
                                             map.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
                                             map.Version(x => x.Version, m => m.Generated(VersionGeneration.Always));
                                         });
        }
 public static string Generic(this string text, string type)
 {
     return type.Class(Constants.TrailingSpace.False) + "<" + text.Class(Constants.TrailingSpace.False) + ">";
 }
 public static string Class(this string text, string baseClass, string interface1)
 {
     return text.Class() + ": " + baseClass.Class() + ", " + interface1.Interface();
 }
 public static string Class(this string text, string baseClass)
 {
     return text.Class() + ": " + baseClass.Class(Constants.TrailingSpace.False);
 }
Exemple #11
0
 public static string WrapWithClass(this string content, string type = "Class1", string nameSpace = "ConsoleApplication", IEnumerable<string> usings = null)
 {
     return content.Class(type).WrapWithNamespace(nameSpace: nameSpace, usings: usings);
 }