/// <summary>
        /// Loads the connector dictionary from the specified assembly.
        /// </summary>
        /// <param name="assembly">The assembly to consider.</param>
        /// <param name="extensionDefinition">The extension definition to consider.</param>
        /// <param name="log">The log to consider.</param>
        /// <returns></returns>
        private int LoadConnectorDictionaryFromAssembly(
            Assembly assembly,
            IBdoExtensionDefinition extensionDefinition,
            IBdoLog log = null)
        {
            if (assembly == null)
            {
                return(-1);
            }

            // we load the carrier dictionary from the assembly

            IBdoConnectorDictionaryDto dictionaryDto = (IBdoConnectorDictionaryDto)ExtractDictionaryFromAssembly <BdoConnectorDefinitionDto>(assembly, log);

            // we feach connector classes

            var types = assembly.GetTypes().Where(p => typeof(IBdoConnector).IsAssignableFrom(p) && !p.IsAbstract);
            int count = 0;

            foreach (Type type in types)
            {
                IBdoConnectorDefinitionDto definitionDto = new BdoConnectorDefinitionDto();

                // we update definition from connector attribute

                if (type.GetCustomAttribute(typeof(BdoConnectorAttribute)) is BdoConnectorAttribute connectorAttribute)
                {
                    UpdateDictionary(definitionDto, connectorAttribute);
                }
                definitionDto.ItemClass = type.FullName;
                definitionDto.LibraryId = extensionDefinition?.Dto?.Id;

                // we create the detail specification from detail property attributes

                foreach (PropertyInfo property in type.GetProperties().Where(p => p.GetCustomAttributes(typeof(DetailPropertyAttribute)).Any()))
                {
                    definitionDto.DatasourceDetailSpec.Add(ElementSpecFactory.Create(property.Name, property.PropertyType));
                }

                // we build the runtime definition

                IBdoConnectorDefinition itemDefinition = new BdoConnectorDefinition(extensionDefinition, definitionDto)
                {
                    RuntimeType = type
                };

                if (dictionaryDto != null)
                {
                    // retrieve the definition index

                    // update definition with index
                }

                _store.Add <IBdoConnectorDefinition>(itemDefinition);

                count++;
            }

            return(count);
        }
示例#2
0
        /// <summary>
        /// Loads the entity dictionary from the specified assembly.
        /// </summary>
        /// <param name="assembly">The assembly to consider.</param>
        /// <param name="extensionDefinition">The extension definition to consider.</param>
        /// <param name="log">The log to consider.</param>
        /// <returns></returns>
        private int LoadEntityDictionaryFromAssembly(
            Assembly assembly,
            IBdoExtensionDefinition extensionDefinition,
            IBdoLog log = null)
        {
            if (assembly == null)
            {
                return(-1);
            }

            // we load the entity dictionary from the assembly

            IBdoEntityDictionaryDto dictionaryDto = (IBdoEntityDictionaryDto)ExtractDictionaryFromAssembly <BdoEntityDefinitionDto>(assembly, log);


            // we feach entity classes

            var types = assembly.GetTypes().Where(p => typeof(IBdoEntity).IsAssignableFrom(p));
            int count = 0;

            foreach (Type type in types)
            {
                IBdoEntityDefinitionDto definitionDto = new BdoEntityDefinitionDto();

                if (type.GetCustomAttributes(typeof(BdoEntityAttribute)).FirstOrDefault() is BdoEntityAttribute entityAttribute)
                {
                    UpdateDictionary(definitionDto, entityAttribute);
                }
                definitionDto.ItemClass = type.FullName;
                definitionDto.LibraryId = extensionDefinition?.Dto?.Id;

                foreach (PropertyInfo property in type.GetProperties().Where(p => p.GetCustomAttributes(typeof(DetailPropertyAttribute)).Any()))
                {
                    definitionDto.DetailSpec.Add(ElementSpecFactory.Create(property.Name, property.PropertyType));
                }

                // we build the runtime definition

                IBdoEntityDefinition itemDefinition = new BdoEntityDefinition(extensionDefinition, definitionDto)
                {
                    RuntimeType = type
                };

                if (dictionaryDto != null)
                {
                    // retrieve the definition index

                    // update definition with index
                }

                _store.Add <IBdoEntityDefinition>(itemDefinition);

                count++;
            }

            return(count);
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 internal IDbQuery QuerySelectCountryWithCode(string code)
 {
     return(this.UseQuery("GetCountryWithCode", p =>
                          DbFluent.SelectQuery(Table("Country"))
                          .From(
                              DbFluent.TableAsJoin(DbQueryJoinKind.Left, Table("RegionalDirectorate"),
                                                   JoinCondition("Country_RegionalDirectorate")))
                          .WithFields(Tuple("SelectCountry"))
                          .AddIdField(DbFluent.FieldAsParameter(nameof(DbCountry.Code), "code"))
                          .UsingParameters(ElementSpecFactory.Create("code", DataValueTypes.Text))
                          )
            .WithParameters(
                ElementFactory.CreateScalar("code", code)));
 }
示例#4
0
        /// <summary>
        /// Defines the parameter specifications of this instance.
        /// </summary>
        /// <param name="parameterSpecs">The set of parameter specifications to consider.</param>
        /// <returns>Return this instance.</returns>
        public IDbQuery UsingParameters(params IDataElementSpec[] parameterSpecs)
        {
            ParameterSpecSet = ElementSpecFactory.CreateSet(parameterSpecs);

            return this;
        }