コード例 #1
0
 public ConventionSet()
 {
     ConfigurationConventions = new IConvention[0];
     ConceptualModelConventions = new IConvention[0];
     ConceptualToStoreMappingConventions = new IConvention[0];
     StoreModelConventions = new IConvention[0];
 }
コード例 #2
0
 public DefaultConfiguration(ConnectionStringSettings connectionStringSettings, IConvention mappingConvention, IEngine engine)
     : base(
         engine,
         connectionStringSettings,
         DbProviderFactories.GetFactory(connectionStringSettings.ProviderName),
         new DefaultMapper(mappingConvention),
         new DefaultSessionFactory()) {
 }
コード例 #3
0
        public TeamFoundationService(ITeamFoundationVersionControlAdapter versoControlAdapterAdapter, IConvention convention, ITextOutputService textOutputService)
        {
            if(convention == null) throw new ArgumentNullException("convention");

            this.VersionControlAdapter = versoControlAdapterAdapter;
            this.Convention = convention;
            this.TextOutput = textOutputService;
        }
コード例 #4
0
        public MergeBugfixController(IVersionControlService versionControlService, IUserInputService userInputService, IConvention convention)
        {
            if(versionControlService == null) throw new ArgumentNullException("versionControlService");
            if(convention == null) throw new ArgumentNullException("convention");

            this.VersionControl = versionControlService;
            this.UserInput = userInputService;
            this.Convention = convention;
        }
コード例 #5
0
        public EnvironmentService(IFileExecutionService fileExecutionService, IFileSystemAdapter fileSystemAdapter, IConvention convention)
        {
            if(fileExecutionService == null) throw new ArgumentNullException("fileExecutionService");
            if(convention == null) throw new ArgumentNullException("convention");

            this.FileExecution = fileExecutionService;
            this.FileSystemAdapter = fileSystemAdapter;
            this.Convention = convention;
        }
コード例 #6
0
        public MsBuildService(IFileExecutionService fileExecutionService, IConvention convention, ISettings settings)
        {
            if(convention == null) throw new ArgumentNullException("convention");
            if(settings == null) throw new ArgumentNullException("settings");

            this.FileExecution = fileExecutionService;
            this.Convention = convention;
            this.Settings = settings;
        }
コード例 #7
0
        public AdeNetService(IFileExecutionService fileExecutionService, IConvention convention, ISettings settings, ITextOutputService textOutputService)
        {
            if(convention == null) throw new ArgumentNullException("convention");
            if(settings == null) throw new ArgumentNullException("settings");

            this.FileExecution = fileExecutionService;
            this.Convention = convention;
            this.Settings = settings;
            this.TextOutput = textOutputService;
        }
コード例 #8
0
        public RemoveReleasebranchController(IVersionControlService versionControlService, IFileSystemAdapter fileSystemAdapter, IConvention convention, ITextOutputService textOutputService)
        {
            if(versionControlService == null) throw new ArgumentNullException("versionControlService");
            if(textOutputService == null) throw new ArgumentNullException("textOutputService");

            this.VersionControl = versionControlService;
            this.FileSystem = fileSystemAdapter;
            this.Convention = convention;
            this.TextOutput = textOutputService;
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardFluentMapper"/> class.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        public StandardFluentMapper(Assembly assembly)
        {
            Assembly = assembly;

            Conventions = new IConvention[]
                              {
                                  new TableConvention(),
                                  new PrimaryKeyConvention(),
                                  new ForeignKeyConvention()
                              };
        }
コード例 #10
0
        public void Configure(MappingConfiguration mappingConfig)
        {
            var assemblies = Assembly.GetAssembly(typeof (Entity));
            var conventions = new IConvention[]
                                  {
                                      DefaultCascade.All(),
                                      ConventionBuilder.Id.Always(m => m.GeneratedBy.HiLo("1000")),
                                      ConventionBuilder.HasMany.Always(m => m.Inverse())
                                  };

            mappingConfig.AutoMappings.Add(
                AutoMap.Assemblies(new AutoMapConfig(), assemblies)
                    .Conventions.Add(conventions));
        }
コード例 #11
0
        public GetLatestController(IVersionControlService versionControlService, IAdeNetExeAdaper adeNetExeAdapter, IBuildEngineService buildEngineService, IDatabaseService databaseService, IEnvironmentService environmentService, IConvention convention, ITextOutputService textOutputService)
        {
            if(versionControlService == null) throw new ArgumentNullException("versionControlService");
            if(adeNetExeAdapter == null) throw new ArgumentNullException("adeNetExeAdapter");
            if(buildEngineService == null) throw new ArgumentNullException("buildEngineService");
            if(databaseService == null) throw new ArgumentNullException("databaseService");
            if(environmentService == null) throw new ArgumentNullException("environmentService");

            this.VersionControl = versionControlService;
            this.AdeNet = adeNetExeAdapter;
            this.BuildEngine = buildEngineService;
            this.Database = databaseService;
            this.Environment = environmentService;
            this.Convention = convention;
            this.TextOutput = textOutputService;
        }
コード例 #12
0
 public static IConvention[] Get()
 {
     var defaultCoventions = new IConvention[]
                                 {
                                     new PrimaryKeyConvention(),
                                     new DefaultClassConvention(),
                                     new DefaultForeignKeyConvention(),
                                     //new DefaultManytoManyConvention(),
                                     new EnumConvention(),
                                     new DefaultOneToManyTableNameConvention(),
                                     new DefaultStringPropertyConvention(),
                                     new DefaultHasManyToManyConvention(),
                                     new BinaryColumnLengthConvention(),
                                     DefaultLazy.Always()
                                 };
     return defaultCoventions;
 }
コード例 #13
0
        public RemoveMappingController(IVersionControlService versionControlService, IAdeNetExeAdaper adeNetExeAdapter, IFileSystemAdapter fileSystemAdapter, IDatabaseService databaseService, IAblageService ablageService, IEnvironmentService environmentService, IConvention convention, ITextOutputService textOutputService)
        {
            if(versionControlService == null) throw new ArgumentNullException("versionControlService");
            if(adeNetExeAdapter == null) throw new ArgumentNullException("adeNetExeAdapter");
            if(fileSystemAdapter == null) throw new ArgumentNullException("fileSystemAdapter");
            if(databaseService == null) throw new ArgumentNullException("databaseService");
            if(ablageService == null) throw new ArgumentNullException("ablageService");
            if(convention == null) throw new ArgumentNullException("convention");

            this.VersionControl = versionControlService;
            this.AdeNetExeAdapter = adeNetExeAdapter;
            this.FileSystem = fileSystemAdapter;
            this.Database = databaseService;
            this.Ablage = ablageService;
            this.Environment = environmentService;
            this.Convention = convention;
            this.TextOutput = textOutputService;
        }
            public PropertyConfigurationConventionDispatcher(
                IConvention convention,
                Type propertyConfigurationType,
                PropertyInfo propertyInfo,
                Func <PropertyConfiguration> propertyConfiguration,
                ModelConfiguration modelConfiguration)
            {
                Check.NotNull(convention, "convention");
                Check.NotNull(propertyConfigurationType, "propertyConfigurationType");
                Check.NotNull(propertyInfo, "propertyInfo");
                Check.NotNull(propertyConfiguration, "propertyConfiguration");

                _convention = convention;
                _propertyConfigurationType = propertyConfigurationType;
                _propertyInfo          = propertyInfo;
                _propertyConfiguration = propertyConfiguration;
                _modelConfiguration    = modelConfiguration;
            }
コード例 #15
0
        /// <summary>
        /// Add a convention to fixture
        /// </summary>
        /// <param name="convention">new convention</param>
        public void Add(IConvention convention)
        {
            if (convention == null)
            {
                throw new ArgumentNullException(nameof(convention));
            }

            var typedConvention = convention as ITypedConvention;

            if (typedConvention != null)
            {
                _typedConventions.AddConvention(typedConvention);
            }
            else
            {
                _conventions.AddConvention(convention);
            }
        }
        public void AddBefore <TExistingConvention>(IConvention newConvention)
            where TExistingConvention : IConvention
        {
            Check.NotNull(newConvention, "newConvention");

            var typeMissmatch = true;

            if (ConventionsTypeFilter.IsConfigurationConvention(newConvention.GetType()) &&
                ConventionsTypeFilter.IsConfigurationConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _configurationConventions);
            }

            if (ConventionsTypeFilter.IsConceptualModelConvention(newConvention.GetType()) &&
                ConventionsTypeFilter.IsConceptualModelConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _conceptualModelConventions);
            }

            if (ConventionsTypeFilter.IsStoreModelConvention(newConvention.GetType()) &&
                ConventionsTypeFilter.IsStoreModelConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _storeModelConventions);
            }

            if (ConventionsTypeFilter.IsConceptualToStoreMappingConvention(newConvention.GetType()) &&
                ConventionsTypeFilter.IsConceptualToStoreMappingConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _conceptualToStoreMappingConventions);
            }

            if (typeMissmatch)
            {
                throw new InvalidOperationException(
                          Strings.ConventionsConfiguration_ConventionTypeMissmatch(
                              newConvention.GetType(), typeof(TExistingConvention)));
            }
        }
コード例 #17
0
        public void Execute <TDataSource>(IConvention <TDataSource> convention, TDataSource data)
            where TDataSource : IConventionData
        {
            conventionReason = convention.ConventionReason;
            if (!data.HasData)
            {
                throw new ConventionSourceInvalidException(String.Format("{0} has no data", data.Description));
            }
            convention.Execute(data, this);

            if (!resultSet)
            {
                throw new ResultNotSetException("{0} did not set a result, conventions must always set a result");
            }

            foreach (IResultsProcessor resultsProcessor in processors)
            {
                resultsProcessor.Process(this, ConventionResults);
            }
        }
コード例 #18
0
        /// <summary>
        /// Setup application's convention.
        /// </summary>
        private static void SetupConventions()
        {
            var conventions = new IConvention[] {
                new StringObjectIdIdGeneratorConvention(),
                new CamelCaseElementNameConvention()
            };

            var idx = 0;

            foreach (var convention in conventions)
            {
                var pack = new ConventionPack();
                pack.Add(convention);

                ConventionRegistry.Register(
                    string.Format("TrincaBarbecueApi.Conventions[{0}]", idx++),
                    pack,
                    t => true);
            }
        }
コード例 #19
0
        public void Setup()
        {
            _ontologies = new Mock<IOntologyProvider>();
            _ontologies.Setup(o => o.ResolveUri(It.IsAny<string>(), It.IsAny<string>()))
                       .Returns((string p, string t) => GetUri(p, t));

            _mappingsRepository = new MappingsRepository();
            foreach (var mappingSource in CreateMappingSources())
            {
                MappingsRepository.AddSource(GetType().Assembly, mappingSource);
            }

            IEnumerable<IConvention> conventions = new IConvention[]
                                                       {
                                                           new DefaultDictionaryKeyPredicateConvention(),
                                                           new DefaultDictionaryValuePredicateConvention(),
                                                           new CollectionStorageConvention(),
                                                           new RdfListConvention()
                                                       };
            MappingsRepository.RebuildMappings(new MappingContext(_ontologies.Object, conventions));
        }
コード例 #20
0
        ISessionFactory InitializeSessionFactory()
        {
            var conventions = new IConvention[]
            {
                Table.Is(x => x.EntityType.Name.ToLowerInvariant()), // All table names are lower case
                ForeignKey.EndsWith("Id"),                           // Foreign key references end with Id
                DefaultLazy.Always()                                 // Enable Lazy-Loading by default
            }
            .Concat(DatabaseConventions.NeverNull())
            .ToArray();

            var config = Fluently.Configure()
                         .Database(DatabaseConfiguration)
                         .Mappings(m => m.FluentMappings
                                   .AddFromAssemblyOf <DatabaseAdapter>()
                                   .Conventions.Add(conventions));

            nhConfig       = config.BuildConfiguration();
            sessionFactory = config.BuildSessionFactory();

            return(sessionFactory);
        }
コード例 #21
0
        public ConventionManager(Assembly scanAssembly, IConvention attachmentConvention, IConvention viewConvention, IConvention viewModelConvention)
        {
            this.attachmentConvention = attachmentConvention;
            this.viewConvention       = viewConvention;
            this.viewModelConvention  = viewModelConvention;

            attachmentTypes = scanAssembly.GetTypes().Where(attachmentConvention.Filter).ToList();
            viewTypes       = scanAssembly.GetTypes().Where(viewConvention.Filter).ToList();
            viewModelTypes  = scanAssembly.GetTypes().Where(viewModelConvention.Filter).ToList();

            foreach (var item in attachmentTypes)
            {
                attachmentConvention.Verify(item);
            }
            foreach (var item in viewTypes)
            {
                viewConvention.Verify(item);
            }
            foreach (var item in viewModelTypes)
            {
                viewModelConvention.Verify(item);
            }
        }
コード例 #22
0
ファイル: Composer.cs プロジェクト: rsg-bot/Conventions
        private static void Register(IConvention convention, IConventionContext context)
        {
            var interfaces = convention.GetType().GetTypeInfo().ImplementedInterfaces
                             .Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IConvention <>))
                             .Select(x => x.GetTypeInfo().GenericTypeArguments[0]);

            var contextTypes = context.GetType().GetTypeInfo().ImplementedInterfaces
                               .Where(x => typeof(IConventionContext).IsAssignableFrom(x));

            var typesToRegister = interfaces
                                  .Join(contextTypes, x => x, x => x, (_, contextType) => contextType);

            foreach (var item in typesToRegister)
            {
                if (!_registerMethodCache.TryGetValue(item, out var method))
                {
                    method = RegisterGenericMethod.MakeGenericMethod(item);
                    _registerMethodCache.TryAdd(item, method);
                }

                method.Invoke(null, new object[] { convention, context });
            }
        }
コード例 #23
0
        public void ShouldReturnAllConventions()
        {
            var scanner = AutoFake.Resolve <Scanner>();

            A.CallTo(
                () => AutoFake.Resolve <IAssemblyCandidateFinder>().GetCandidateAssemblies(A <IEnumerable <string> > ._)
                )
            .Returns(Array.Empty <Assembly>());

            IConvention convention  = A.Fake <IServiceConvention>();
            IConvention convention2 = A.Fake <ITestConvention>();
            IConvention convention3 = A.Fake <IServiceConvention>();
            IConvention convention4 = A.Fake <ITestConvention>();

            scanner.PrependConvention(convention, convention2);
            scanner.AppendConvention(convention3, convention4);

            var provider = scanner.BuildProvider();

            var result = provider.GetAll()
                         .Select(x => x.Convention);

            result.Should().ContainInOrder(convention, convention2, convention3, convention4);
        }
コード例 #24
0
 public static ISchemaBuilder TryAddConvention <T>(
     this ISchemaBuilder builder,
     IConvention convention,
     string?scope = null)
     where T : IConvention =>
 builder.TryAddConvention(typeof(T), convention, scope);
コード例 #25
0
 public virtual QueryExpression Translate(IConvention convention)
 {
     return(this);
 }
コード例 #26
0
 protected override Repository CreateRepository(IConvention convention)
 {
     return new InMemoryRepository { Convention = convention };
 }
コード例 #27
0
 public override QueryExpression Translate(IConvention convention)
 {
     return(new NotExpression(Expression.Translate(convention)));
 }
コード例 #28
0
 public static Action <IServiceLocator> Convention(IConvention convention)
 {
     return(convention.Build());
 }
コード例 #29
0
 /// <summary>
 /// Create a convention
 /// </summary>
 /// <param name="convention">The convention.</param>
 /// <param name="hostType">The host type.</param>
 internal DelegateOrConvention(IConvention convention, HostType hostType)
 {
     Convention = convention;
     Delegate   = default;
     HostType   = hostType;
 }
 public static IRequestExecutorBuilder TryAddConvention <T>(
     this IRequestExecutorBuilder builder,
     IConvention convention,
     string?scope = null)
     where T : IConvention =>
 builder.ConfigureSchema(b => b.TryAddConvention(typeof(T), convention, scope));
コード例 #31
0
ファイル: DatabaseAdapter.cs プロジェクト: relimited/core
        ISessionFactory InitializeSessionFactory()
        {
            var conventions = new IConvention[]
             {
            Table.Is(x => x.EntityType.Name.ToLowerInvariant()), // All table names are lower case
            ForeignKey.EndsWith("Id"), // Foreign key references end with Id
            DefaultLazy.Always() // Enable Lazy-Loading by default
             }
            .Concat(DatabaseConventions.NeverNull())
            .ToArray();

             var config = Fluently.Configure()
            .Database(DatabaseConfiguration)
            .Mappings(m => m.FluentMappings
               .AddFromAssemblyOf<DatabaseAdapter>()
               .Conventions.Add(conventions));

             nhConfig = config.BuildConfiguration();
             sessionFactory = config.BuildSessionFactory();

             return sessionFactory;
        }
コード例 #32
0
ファイル: ModelGenerator.cs プロジェクト: Polylytics/dashing
 public ModelGenerator(IConvention convention) {
     this.convention = convention;
 }
コード例 #33
0
ファイル: IocConfig.cs プロジェクト: RookieOne/Chimera
 public IocConfig AddConvention(IConvention convention)
 {
     _conventions.Add(convention);
     return this;
 }
コード例 #34
0
 public void Setup()
 {
     _convention = (IConvention<IPropertyMappingProvider>)(_defaultConvertersConvention = new DefaultConvertersConvention());
 }
コード例 #35
0
ファイル: ColumnValue.cs プロジェクト: erikojebo/WeenyMapper
 public bool IsForType(Type type, IConvention convention)
 {
     return !HasTableQualifiedAlias || TableName == convention.GetTableName(type);
 }
コード例 #36
0
 public void Remove(IConvention convention)
 {
     _conventions.Remove(convention);
 }
コード例 #37
0
 public override QueryExpression Translate(IConvention convention)
 {
     var columnName = convention.GetColumnName(_propertyInfo);
     return new PropertyExpression(columnName, PropertyType);
 }
コード例 #38
0
 public bool Contains(IConvention item)
 => FinderFunc(f => f.Conventions.Any(t => item.GetType().IsAssignableFrom(t)));
コード例 #39
0
        public override QueryExpression Translate(IConvention convention)
        {
            var columnName = convention.GetColumnName(_propertyInfo);

            return(new PropertyExpression(columnName, PropertyType));
        }
コード例 #40
0
 public bool Remove(IConvention item)
 {
     throw new NotImplementedException();
 }
コード例 #41
0
 public void Insert(int index, IConvention convention)
 {
     _conventions.Insert(index, convention);
 }
コード例 #42
0
 public int IndexOf(IConvention item)
 {
     throw new NotImplementedException();
 }
コード例 #43
0
 public ConventionReader(IConvention convention)
 {
     _convention = convention;
 }
コード例 #44
0
 public void Insert(int index, IConvention item)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
 public IConventionsPolicy <TEntity> SatisfiedAs(IConvention <TEntity> convention)
 {
     _convensPolicy.Add(convention);
     return(_convensPolicy);
 }
コード例 #46
0
 public AblageService(IFileSystemAdapter fileSystemAdapter, IConvention convention)
 {
     this.FileSystemAdapter = fileSystemAdapter;
     this.Convention = convention;
 }
 public void AddConventionApplicant(IConvention convention)
 {
     _conventionApplicant = convention;
 }
コード例 #48
0
 public override QueryExpression Translate(IConvention convention)
 {
     return(Create(
                (PropertyExpression)PropertyExpression.Translate(convention),
                (ValueExpression)ValueExpression.Translate(convention)));
 }
コード例 #49
0
 public DefaultConfiguration(ConnectionStringSettings connectionStringSettings, IConvention mappingConvention)
     : this(connectionStringSettings, mappingConvention, new SqlEngine(new DialectFactory().Create(connectionStringSettings))) {
 }
コード例 #50
0
        public void AddConvention(IConvention convention)
        {
            Guard.IsNotNull(convention, "convention");

            _conventions.Add(convention);
        }
コード例 #51
0
 //public PropertyConvention(Func<TEntity, TEntityProperty> getter, IConvention<TEntityProperty> propConvention)
 public PropertyConvention(Func <IConventionParams <TEntity>, IConventionParams <TEntityProperty> > getter, IConvention <TEntityProperty> propConvention)
 {
     _getter         = getter;
     _propConvention = propConvention;
 }
コード例 #52
0
 /// <summary>
 /// Retuns a new specification adding this one with the passed one.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="rightHand">The right hand.</param>
 /// <param name="leftHand">The left hand.</param>
 /// <returns></returns>
 public static IConvention <TEntity> And <TEntity>(this IConvention <TEntity> rightHand, IConvention <TEntity> leftHand)
 {
     return(new ComposeConvention <TEntity>(rightHand, leftHand, ComposeType.And));
 }
コード例 #53
0
ファイル: Engineer.cs プロジェクト: Polylytics/dashing
 public Engineer(IConvention convention) {
     this.convention = convention;
     this.typeMap = new Dictionary<string, Type>();
     this.manyToOneColumns = new Dictionary<string, IList<IColumn>>();
     this.InitTypeGenerator();
 }
コード例 #54
0
 /// <summary>
 /// Retuns a new specification or'ing this one with the passed one.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="rightHand">The right hand.</param>
 /// <param name="leftHand">The left hand.</param>
 /// <returns></returns>
 public static IConvention <TEntity> Or <TEntity>(IConvention <TEntity> rightHand, IConvention <TEntity> leftHand)
 {
     return(new ComposeConvention <TEntity>(rightHand, leftHand, ComposeType.Or));
 }
コード例 #55
0
 public bool IsForType(Type type, IConvention convention)
 {
     return(!HasTableQualifiedAlias || TableName == convention.GetTableName(type));
 }
コード例 #56
0
 /// <summary>
 /// Retuns a new specification or'ing this one with the passed one.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="rightHand">The right hand.</param>
 /// <param name="leftHand">The left hand.</param>
 /// <returns></returns>
 public static IConvention <TEntity> Not <TEntity>(IConvention <TEntity> convension)
 {
     return(new NotConvention <TEntity>(convension));
 }
コード例 #57
0
 public NotConvention(IConvention <TEntity> convension)
 {
     _convension = convension;
 }
コード例 #58
0
 /// <summary>
 /// Create a convention
 /// </summary>
 /// <param name="convention">The convention.</param>
 internal DelegateOrConvention(IConvention convention)
 {
     Convention = convention;
     Delegate   = default;
     HostType   = HostType.Undefined;
 }
コード例 #59
0
 public AdeNetExeAdapter(IFileExecutionService fileExecutionService, IConvention convention, ISettings settings)
 {
     this.FileExecution = fileExecutionService;
     this.Convention = convention;
     this.Settings = settings;
 }
コード例 #60
0
 public void Add(IConvention convention)
 {
     _conventions.Add(convention);
 }