Ejemplo n.º 1
0
        public async Task <ACADIAHeatMapOutputs> Handler(ACADIAHeatMapInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                // Preload the dependencies (if they exist),
                // so that they are available during model deserialization.
                var asmLocation = this.GetType().Assembly.Location;
                var asmDir      = Path.GetDirectoryName(asmLocation);
                var asmName     = Path.GetFileNameWithoutExtension(asmLocation);
                var depPath     = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

                if (File.Exists(depPath))
                {
                    Console.WriteLine($"Loading dependencies from assembly: {depPath}...");
                    Assembly.LoadFrom(depPath);
                    Console.WriteLine("Dependencies assembly loaded.");
                }

                this.store = new S3ModelStore <ACADIAHeatMapInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <ACADIAHeatMapInputs, ACADIAHeatMapOutputs>(store, ACADIAHeatMap.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Procedure"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            if (parameterClass!=null)
            {
            }
            else
            {
                if (parameterMap == null)
                {
                    parameterMap = modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP);
                }                
            }

            return new Procedure(
                id,
                parameterClass,
                parameterMap,
                resultClass,
                resultsMap,
                listClass,
                listClassFactory,
                cacheModel,
                remapResults,
                string.Empty,
                sqlSource,
                preserveWhitespace);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deserializes a ParameterMap object
        /// </summary>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="config">The config.</param>
        /// <param name="modelStore">The model store.</param>
        /// <returns></returns>
        public static ParameterMap Deserialize(
            DataExchangeFactory dataExchangeFactory,
            IConfiguration config,
            IModelStore modelStore)
        {
            Type          type         = null;
            IDataExchange dataExchange = null;

            string id        = config.Id;
            string className = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_CLASS);
            string extendMap = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS);

            if (className.Length > 0)
            {
                type         = dataExchangeFactory.TypeHandlerFactory.GetType(className);
                dataExchange = dataExchangeFactory.GetDataExchangeForClass(type);
            }
            else
            {
                // Get the ComplexDataExchange
                dataExchange = dataExchangeFactory.GetDataExchangeForClass(dataExchangeFactory.TypeHandlerFactory.GetTypeAlias(className).Type);
            }

            return(new ParameterMap(
                       id,
                       className,
                       extendMap,
                       type,
                       dataExchange,
                       modelStore.SessionFactory.DataSource.DbProvider.UsePositionalParameters));
        }
        /// <summary>
        /// Deserializes a ParameterMap object
        /// </summary>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="config">The config.</param>
        /// <param name="modelStore">The model store.</param>
        /// <returns></returns>
        public static ParameterMap Deserialize(
            DataExchangeFactory dataExchangeFactory,
            IConfiguration config,
            IModelStore modelStore)
        {
            Type type = null;
            IDataExchange dataExchange = null;

            string id = config.Id;
            string className = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_CLASS);
            string extendMap = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS);
            if (className.Length > 0)
            {
                type = dataExchangeFactory.TypeHandlerFactory.GetType(className);
                dataExchange = dataExchangeFactory.GetDataExchangeForClass(type);
            }
            else
            {
                // Get the ComplexDataExchange
                dataExchange = dataExchangeFactory.GetDataExchangeForClass(dataExchangeFactory.TypeHandlerFactory.GetTypeAlias(className).Type);
            }

            return new ParameterMap(
                id,
                className,
                extendMap,
                type,
                dataExchange,
                modelStore.SessionFactory.DataSource.DbProvider.UsePositionalParameters);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Procedure"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            if (parameterClass != null)
            {
            }
            else
            {
                if (parameterMap == null)
                {
                    parameterMap = modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP);
                }
            }

            return(new Procedure(
                       id,
                       parameterClass,
                       parameterMap,
                       resultClass,
                       resultsMap,
                       listClass,
                       listClassFactory,
                       cacheModel,
                       remapResults,
                       string.Empty,
                       sqlSource,
                       preserveWhitespace));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappedStatement"/> class.
 /// </summary>
 /// <param name="modelStore">The model store.</param>
 /// <param name="statement">The statement.</param>
 public MappedStatement(IModelStore modelStore, IStatement statement)
 {
     this.modelStore = modelStore;
     this.statement  = statement;
     preparedCommand = new DefaultPreparedCommand();
     resultStrategy  = ResultStrategyFactory.Get(this.statement);
 }
Ejemplo n.º 7
0
        public AssignmentEditPage(int assignmentId, ModelUser user)
        {
            InitializeComponent();

            IModelStore model = ((App)Application.Current).model;



            ModelAssignment assignment = user.getAssignemt(assignmentId);

            this.name_Entry.Text        = assignment.name;
            this.description_Entry.Text = assignment.description;


            //DatePicker stuff
            this.datePicker.Date = assignment.dueDate;

            DateTime now = DateTime.Now;

            this.datePicker.Format      = "d";
            this.datePicker.MinimumDate = now;
            this.datePicker.MaximumDate = now.AddYears(1);
            //--------------------------------------


            AssignmentEditPage_Controler controler = new AssignmentEditPage_Controler(
                name_Entry, datePicker, description_Entry,
                confirm_Button,
                this,
                assignmentId,
                user.id
                );
        }
Ejemplo n.º 8
0
 public SQLGenerator(StreamWriter fsSql, IDatabaseTableGenerator mySql, StreamWriter fsPy, IDatabaseCodeGenerator py, IModelStore ms)
 {
     _ms = ms;
     _py = py;
     _mySql = mySql;
     _py.AddStreamWriter(fsPy);
     _mySql.AddStreamWriter(fsSql);
 }
        public CreateClassRoomPage(int teacherId)
        {
            InitializeComponent();

            IModelStore model = ((App)Application.Current).model;

            CreateClassRoomPageControler controler = new CreateClassRoomPageControler(confirm_button, newClassRoom_entry, teacherId);
        }
Ejemplo n.º 10
0
 public TesterDbContext([NotNull] IModelStore store,
                        [NotNull] IIndexProvider indexProvider,
                        DbContextOptions options) :
     base(options)
 {
     _store         = store ?? throw new ArgumentNullException(nameof(store));
     _indexProvider = indexProvider ?? throw new ArgumentNullException(nameof(indexProvider));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataMapper"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        public DataMapper(IModelStore modelStore)
        {
            Contract.Require.That(modelStore, Is.Not.Null).When("retrieving argument modelStore in DataMapper constructor");

            this.modelStore            = modelStore;
            this.modelStore.DataMapper = this;
            sessionStore   = modelStore.SessionStore;
            sessionFactory = modelStore.SessionFactory;
        }
Ejemplo n.º 12
0
        public void register(IModelStore model, int assignmentId, int userId)
        {
            this.model        = model;
            this.assignmentId = assignmentId;
            this.userId       = userId;


            model.addWatcher(viewUpdated, this.getUserDataKey());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultModelBuilder"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        public DefaultModelBuilder(IModelStore modelStore)
        {
            Contract.Require.That(modelStore, Is.Not.Null).When("retrieving argument modelStore in DefaultModelBuilder constructor");

            this.modelStore = modelStore;
            inlineParemeterMapBuilder = new InlineParemeterMapBuilder(modelStore);

            waitResultPropertyResolution = WaitResultPropertyResolution;
            waitDiscriminatorResolution = WaitDiscriminatorResolution;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultModelBuilder"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        public DefaultModelBuilder(IModelStore modelStore)
        {
            Contract.Require.That(modelStore, Is.Not.Null).When("retrieving argument modelStore in DefaultModelBuilder constructor");

            this.modelStore           = modelStore;
            inlineParemeterMapBuilder = new InlineParemeterMapBuilder(modelStore);

            waitResultPropertyResolution = WaitResultPropertyResolution;
            waitDiscriminatorResolution  = WaitDiscriminatorResolution;
        }
Ejemplo n.º 15
0
        public void Execute(IMenuCommand command)
        {
            // A selection of starting points:
            // IDiagram diagram = this.DiagramContext.CurrentDiagram;
            Microsoft.VisualStudio.ArchitectureTools.Extensibility.Presentation.IUseCaseDiagram usercaseDiagram = DiagramContext.CurrentDiagram as IUseCaseDiagram;
            var dslDiagram = DiagramContext.CurrentDiagram.GetObject <Microsoft.VisualStudio.Modeling.Diagrams.Diagram>();

            IEnumerable <IShape <IUseCase> > shapelist = usercaseDiagram.GetSelectedShapes <IUseCase>();

            var selectedShapes = DiagramContext.CurrentDiagram.GetSelectedShapes <IClassifier>();

            if (selectedShapes.Count() > 0)
            {
                IClassifier firstElement = selectedShapes.First().Element;
            }


            foreach (IShape shape in shapelist)
            {
                string strPrint = string.Format("xpos:{0};ypos:{1};color:{2};width:{3};height:{4}",
                                                shape.XPosition, shape.YPosition, shape.Color, shape.Width, shape.Height);
                // shape.GetObject<Shape>();
                // IElement element = shape.Element;
                IShape <IUseCase> classShape = shape.ToIShape <IUseCase>();
                if (classShape != null)
                {
                    IUseCase aUseCase = classShape.Element;
                    //  如果节点没有子节点,说明是终节点,此处应该弹出菜单,跳转至目标位置
                    IEnumerable <IShape <IUseCase> > nodeChilds = shape.GetChildShapes <IUseCase>();
                    if (nodeChilds.Count() == 0)
                    {
                        SetHtmlSql(aUseCase);
                    }
                }

                // aClass.
                IElement ele = shape.GetElement();

                // string str = ele.OwnedComments.ToString();
                IShape <Microsoft.VisualStudio.Uml.UseCases.IUseCase> cc = shape.ToIShape <IUseCase>();
            }

            //foreach (IShape<IUseCase> shape in usercaseDiagram.GetChildShapes<IUseCase>())
            //{
            //    IUseCase displayedElement = shape.Element;
            //}

            // IPackage linkedPackage = DiagramContext.CurrentDiagram..Element as IPackage;


            IModelStore modelStore = usercaseDiagram.ModelStore;
            IModel      model      = modelStore.Root;
            //foreach (IElement element in modelStore.AllInstances<IClass>())
            //{ }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initialize the Discriminator
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        public void Initialize(IModelStore modelStore)
        {
            // Set the ResultMaps 遍历每一个Case 根据其值获取ResultProperty类对象 保存到字典中
            int count = cases.Count;

            for (int index = 0; index < count; index++)
            {
                Case kase = cases[index];
                resultMaps.Add(kase.DiscriminatorValue, modelStore.GetResultMap(kase.ResultMapName));
            }
        }
Ejemplo n.º 17
0
        public async Task <FoundationByEnvelopeOutputs> Handler(FoundationByEnvelopeInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                this.store = new S3ModelStore <FoundationByEnvelopeInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <FoundationByEnvelopeInputs, FoundationByEnvelopeOutputs>(store, FoundationByEnvelope.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Ejemplo n.º 18
0
        public async Task <MakeHyparOutputs> Handler(MakeHyparInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                this.store = new S3ModelStore <MakeHyparInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <MakeHyparInputs, MakeHyparOutputs>(store, MakeHypar.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Update"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            return(new Update(
                       id,
                       parameterClass,
                       parameterMap,
                       remapResults,
                       extendsName,
                       sqlSource,
                       preserveWhitespace));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Update"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            return new Update(
                id,
                parameterClass,
                parameterMap,
                remapResults,
                extendsName,
                sqlSource,
                preserveWhitespace);
        }
Ejemplo n.º 21
0
        public async Task <WallsOutputs> Handler(WallsInputs args, ILambdaContext context)
        {
            // Preload dependencies (if they exist),
            // so that they are available during model deserialization.

            var sw          = System.Diagnostics.Stopwatch.StartNew();
            var asmLocation = this.GetType().Assembly.Location;
            var asmDir      = Path.GetDirectoryName(asmLocation);

            // Explicitly load the dependencies project, it might have types
            // that aren't used in the function but are necessary for correct
            // deserialization.
            var asmName = Path.GetFileNameWithoutExtension(asmLocation);
            var depPath = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

            if (File.Exists(depPath))
            {
                Console.WriteLine($"Loading dependencies assembly from: {depPath}...");
                Assembly.LoadFrom(depPath);
                Console.WriteLine("Dependencies assembly loaded.");
            }

            // Load all reference assemblies.
            Console.WriteLine($"Loading all referenced assemblies.");
            foreach (var asm in this.GetType().Assembly.GetReferencedAssemblies())
            {
                try
                {
                    Assembly.Load(asm);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to load {asm.FullName}");
                    Console.WriteLine(e.Message);
                }
            }
            sw.Stop();
            Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})");

            if (this.store == null)
            {
                this.store = new S3ModelStore <WallsInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <WallsInputs, WallsOutputs>(store, Walls.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Ejemplo n.º 22
0
        public static ModelBuilder BuildIndex(
            this ModelBuilder builder,
            IModelStore modelStore,
            IIndexProvider?indexProvider = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (modelStore == null)
            {
                throw new ArgumentNullException(nameof(modelStore));
            }
            indexProvider ??= new DefaultIndexProvider();

            foreach (var type in modelStore.GetModels())
            {
                var indices = type.GetProperties()
                              .Select(p => new { Property = p, Attribute = p.GetCustomAttribute <IndexAttribute>(true) })
                              .Where(x => x.Attribute != null)
                              .Select(p => new
                {
                    IndexName = string.IsNullOrWhiteSpace(p.Attribute.IndexName)
                            ? null
                            : p.Attribute.IndexName,
                    PropertyName = p.Property.Name,
                    Order        = p.Attribute.Order,
                    Attribute    = p.Attribute
                })
                              .GroupBy(p => p.IndexName, NullUniqueEqualityComparer <string?> .Get());

                foreach (var index in indices)
                {
                    var attribute = index.First().Attribute;

                    var propertyNames = index.OrderBy(x => x.Order).Select(x => x.PropertyName).ToArray();
                    var indexBuilder  = builder.Entity(type)
                                        .HasIndex(propertyNames, attribute.IndexName)
                                        .IsUnique(attribute.IsUnique);

                    if (!string.IsNullOrEmpty(attribute.Method))
                    {
                        indexProvider.HasMethod(indexBuilder, attribute.Method);
                    }
                }
            }

            return(builder);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExternalSql"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="statement">The statement.</param>
        /// <param name="commandText">The command text.</param>
        public ExternalSql(
            IModelStore modelStore,
            IStatement statement,
            string commandText)
        {
            Contract.Require.That(modelStore, Is.Not.Null).When("retrieving argument modelStore in ExternalSql constructor");
            Contract.Require.That(statement, Is.Not.Null).When("retrieving argument statement in ExternalSql constructor");

            this.statement         = statement;
            this.commandText       = commandText;
            dataExchangeFactory    = modelStore.DataExchangeFactory;
            dbHelperParameterCache = modelStore.DBHelperParameterCache;

            inlineParemeterMapBuilder = new InlineParemeterMapBuilder(modelStore);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExternalSql"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="statement">The statement.</param>
        /// <param name="commandText">The command text.</param>
        public ExternalSql(
            IModelStore modelStore,
            IStatement statement,
            string commandText)
        {
            Contract.Require.That(modelStore, Is.Not.Null).When("retrieving argument modelStore in ExternalSql constructor");
            Contract.Require.That(statement, Is.Not.Null).When("retrieving argument statement in ExternalSql constructor");

            this.statement = statement;
            this.commandText = commandText;
            dataExchangeFactory = modelStore.DataExchangeFactory;
            dbHelperParameterCache = modelStore.DBHelperParameterCache;

            inlineParemeterMapBuilder = new InlineParemeterMapBuilder(modelStore);
        }
Ejemplo n.º 25
0
        private SelectKey BuildSelectKey(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            SelectKey selectKey = null;
            
            ConfigurationCollection selectKeys = config.Children.Find(ConfigConstants.ELEMENT_SELECTKEY);

            if (selectKeys.Count > 0)
            {
                IConfiguration selectKeyConfig = selectKeys[0];

                BaseStatementDeSerializer selectKeyDeSerializer = new SelectKeyDeSerializer();
                selectKey = (SelectKey)selectKeyDeSerializer.Deserialize(modelStore, selectKeyConfig, configurationSetting);
            }
            return selectKey;
       }
Ejemplo n.º 26
0
        private SelectKey BuildSelectKey(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            SelectKey selectKey = null;

            ConfigurationCollection selectKeys = config.Children.Find(ConfigConstants.ELEMENT_SELECTKEY);

            if (selectKeys.Count > 0)
            {
                IConfiguration selectKeyConfig = selectKeys[0];

                BaseStatementDeSerializer selectKeyDeSerializer = new SelectKeyDeSerializer();
                selectKey = (SelectKey)selectKeyDeSerializer.Deserialize(modelStore, selectKeyConfig, configurationSetting);
            }
            return(selectKey);
        }
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Select"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            string        propertyName  = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_PROPERTY);
            SelectKeyType selectKeyType = ReadSelectKeyType(ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_TYPE));

            return(new SelectKey(
                       config.Parent.Id + ConfigConstants.DOT + "SelectKey",
                       propertyName,
                       resultClass,
                       resultsMap,
                       selectKeyType,
                       sqlSource,
                       preserveWhitespace));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Select"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            string propertyName = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_PROPERTY);
            SelectKeyType selectKeyType = ReadSelectKeyType(ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_TYPE));

            return  new SelectKey(
                config.Parent.Id + ConfigConstants.DOT + "SelectKey",
                propertyName,
                resultClass,
                resultsMap,
                selectKeyType,
                sqlSource,
                preserveWhitespace);
        }
Ejemplo n.º 29
0
        private void SetPricePrimaryKey(IModelStore <Product> product,
                                        IModelStore <HistoryPrice> prices)
        {
            if (product.TrackedCount(StateTrackable.Deleted) == 0 &&
                product.Count > 0)
            {
                var productId = product.FirstOrDefault().Productid;

                for (int i = 0; i < prices.Count; i++)
                {
                    if (prices.GetModelState(i) == ModelState.NewModified)
                    {
                        prices.SetValue(i, "Productid", productId);
                    }
                }
            }
        }
Ejemplo n.º 30
0
        private void SetPrimaryKey(IModelStore <SalesOrderHeader> salesOrderHeaders,
                                   IModelStore <SalesOrderDetail> salesOrderDetails)
        {
            if (salesOrderHeaders.TrackedCount(StateTrackable.Deleted) == 0 &&
                salesOrderHeaders.Count > 0)
            {
                var salesOrderId = salesOrderHeaders.FirstOrDefault().SalesOrderID;

                for (int i = 0; i < salesOrderDetails.Count; i++)
                {
                    if (salesOrderDetails.GetModelState(i) == ModelState.NewModified)
                    {
                        salesOrderDetails.SetValue(i, "SalesOrderID", salesOrderId);
                    }
                }
            }
        }
Ejemplo n.º 31
0
        public string Update <TModel>(bool autoCommit,
                                      IModelStore <TModel> modelList)
            where TModel : class, new()
        {
            if (autoCommit)
            {
                _context.BeginTransaction();
                modelList.SaveChanges(_context);
                _context.Commit();
            }
            else
            {
                modelList.SaveChanges(_context);
            }

            return("Success");
        }
Ejemplo n.º 32
0
        private void SetProductPrimaryKey(IModelStore <SubCategory> subcate,
                                          IModelStore <Product> product)
        {
            if (subcate.TrackedCount(StateTrackable.Deleted) == 0 &&
                subcate.Count > 0)
            {
                var subCateId = subcate.FirstOrDefault().Productsubcategoryid;

                for (int i = 0; i < product.Count; i++)
                {
                    if (product.GetModelState(i) == ModelState.NewModified)
                    {
                        product.SetValue(i, "Productsubcategoryid", subCateId);
                    }
                }
            }
        }
Ejemplo n.º 33
0
        public int SavePerson(IModelStore <Person> person,
                              IModelStore <BusinessEntityAddress> addresses,
                              IModelStore <PersonPhone> phones,
                              IModelStore <Customer> customers)
        {
            int intPersonId = 0;

            _context.BeginTransaction();

            if (person.TrackedCount(StateTrackable.NewModified) == 1)
            {
                var businessEntity = new ModelStore <BusinessEntity>()
                                     .TrackChanges(ChangeTrackingStrategy.PropertyState);

                businessEntity.Add(new BusinessEntity()
                {
                    ModifiedDate = DateTime.Now
                });

                var result = businessEntity.SaveChanges(_context);

                if (result.InsertedCount == 1)
                {
                    intPersonId = businessEntity.FirstOrDefault().BusinessEntityID;
                    person.SetValue(0, "Businessentityid", intPersonId);
                }
            }
            else
            {
                intPersonId = person.FirstOrDefault().Businessentityid;
            }


            SetPrimaryKey(person, addresses, phones, customers);

            //Save person address, phone, customer
            person.SaveChanges(_context);
            addresses.SaveChanges(_context);
            phones.SaveChanges(_context);
            customers.SaveChanges(_context);

            _context.Commit();

            return(intPersonId);
        }
Ejemplo n.º 34
0
        public int SaveProductAndPrice(IModelStore <Product> product,
                                       IModelStore <HistoryPrice> prices)
        {
            int intProductId = 0;

            _context.BeginTransaction();

            product.SaveChanges(_context);

            intProductId = product.FirstOrDefault().Productid;

            SetPricePrimaryKey(product, prices);
            prices.SaveChanges(_context);

            _context.Commit();

            return(intProductId);
        }
Ejemplo n.º 35
0
        public int SaveSalesOrderAndDetail(IModelStore <SalesOrderHeader> salesOrderHeaders,
                                           IModelStore <SalesOrderDetail> salesOrderDetails)
        {
            int intSalesOrderId = 0;

            _context.BeginTransaction();

            salesOrderHeaders.SaveChanges(_context);

            intSalesOrderId = salesOrderHeaders.FirstOrDefault().SalesOrderID;

            SetPrimaryKey(salesOrderHeaders, salesOrderDetails);
            salesOrderDetails.SaveChanges(_context);

            _context.Commit();

            return(intSalesOrderId);
        }
Ejemplo n.º 36
0
        /// <summary>
        /// 当用户单击菜单项(如果它可见并已启用)时调用。
        /// </summary>
        /// <param name="command"></param>
        public void Execute(IMenuCommand command)
        {
            var dslDiagram = context.CurrentDiagram.GetObject <Microsoft.VisualStudio.Modeling.Diagrams.Diagram>();

            if (dslDiagram != null)
            {
                var dialog = new SaveFileDialog
                {
                    AddExtension = true,
                    DefaultExt   = "image.bmp",
                    Filter       = "Bitmap ( *.bmp )|*.bmp|" +
                                   "JPEG File ( *.jpg )|*.jpg|" +
                                   "Enhanced Metafile (*.emf )|*.emf|" +
                                   "Portable Network Graphic ( *.png )|*.png",
                    FilterIndex = 1,
                    Title       = "Save Diagram to Image"
                };

                if (dialog.ShowDialog() == DialogResult.OK &&
                    !string.IsNullOrEmpty(dialog.FileName))
                {
                    var bitmap = dslDiagram.CreateBitmap(dslDiagram.NestedChildShapes,
                                                         Diagram.CreateBitmapPreference.FavorClarityOverSmallSize);
                    bitmap.Save(dialog.FileName, GetImageType(dialog.FilterIndex));
                }

                IDiagram diagram = this.context.CurrentDiagram;
                //foreach (IShape<IElement> shape in diagram.GetSelectedShapes<IElement>())
                //{
                //    IElement element = shape.Element;
                //}
                IModelStore            modelStore = diagram.ModelStore;
                IModel                 model      = modelStore.Root;
                IEnumerable <IElement> eList      = model.OwnedElements;
                foreach (IElement element in model.OwnedElements)
                {
                    //string str = element.Shapes();
                }
                //foreach (IElement element in modelStore.AllInstances<IClass>())
                //{

                //}
            }
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeSerializerFactory"/> class.
 /// </summary>
 /// <param name="modelStore">The model store.</param>
 public DeSerializerFactory(IModelStore modelStore)
 {
     serializerMap.Add(ConfigConstants.ELEMENT_DYNAMIC, new DynamicDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISEQUAL, new IsEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTEQUAL, new IsNotEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISGREATEREQUAL, new IsGreaterEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISGREATERTHAN, new IsGreaterThanDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISLESSEQUAL, new IsLessEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISLESSTHAN, new IsLessThanDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTEMPTY, new IsNotEmptyDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISEMPTY, new IsEmptyDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTNULL, new IsNotNullDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTPARAMETERPRESENT, new IsNotParameterPresentDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTPROPERTYAVAILABLE, new IsNotPropertyAvailableDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNULL, new IsNullDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISPARAMETERPRESENT, new IsParameterPresentDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISPROPERTYAVAILABLE, new IsPropertyAvailableDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ITERATE, new IterateSerializer(modelStore.DataExchangeFactory.AccessorFactory));
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeSerializerFactory"/> class.
 /// </summary>
 /// <param name="modelStore">The model store.</param>
 public DeSerializerFactory(IModelStore modelStore)
 {
     serializerMap.Add(ConfigConstants.ELEMENT_DYNAMIC, new DynamicDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISEQUAL, new IsEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTEQUAL, new IsNotEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISGREATEREQUAL, new IsGreaterEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISGREATERTHAN, new IsGreaterThanDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISLESSEQUAL, new IsLessEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISLESSTHAN, new IsLessThanDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTEMPTY, new IsNotEmptyDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISEMPTY, new IsEmptyDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTNULL, new IsNotNullDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTPARAMETERPRESENT, new IsNotParameterPresentDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNOTPROPERTYAVAILABLE, new IsNotPropertyAvailableDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISNULL, new IsNullDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISPARAMETERPRESENT, new IsParameterPresentDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ISPROPERTYAVAILABLE, new IsPropertyAvailableDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
     serializerMap.Add(ConfigConstants.ELEMENT_ITERATE, new IterateSerializer(modelStore.DataExchangeFactory.AccessorFactory));
 }
Ejemplo n.º 39
0
        public void Cache_stats_should_only_be_calculated_on_CachingStatments()
        {
            IModelStore modelStore = ((IModelStoreAccessor)dataMapper).ModelStore;

            modelStore.FlushCaches();

            // taken from TestFlushDataCache()
            // first query is not cached, second query is: 50% cache hit
            IList list    = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
            int   firstId = HashCodeProvider.GetIdentityHashCode(list);

            list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
            int secondId = HashCodeProvider.GetIdentityHashCode(list);

            Assert.AreEqual(firstId, secondId);

            //string cacheStats = modelStore.GetDataCacheStats();

            //Assert.IsNotNull(cacheStats);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeSerializerFactory"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        public DeSerializerFactory(IModelStore modelStore)
		{
            serializerMap.Add(ConfigConstants.ELEMENT_DYNAMIC, new DynamicDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISEQUAL, new IsEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISNOTEQUAL, new IsNotEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISGREATEREQUAL, new IsGreaterEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISGREATERTHAN, new IsGreaterThanDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISLESSEQUAL, new IsLessEqualDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISLESSTHAN, new IsLessThanDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISNOTEMPTY, new IsNotEmptyDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISEMPTY, new IsEmptyDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            // Richard Beacroft: 11\10\2013, Description: Added bind element to be used as a variable, typically within an iterate element.
            serializerMap.Add(ConfigConstants.ELEMENT_BIND, new BindDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISNOTNULL, new IsNotNullDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISNOTPARAMETERPRESENT, new IsNotParameterPresentDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISNOTPROPERTYAVAILABLE, new IsNotPropertyAvailableDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISNULL, new IsNullDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISPARAMETERPRESENT, new IsParameterPresentDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ISPROPERTYAVAILABLE, new IsPropertyAvailableDeSerializer(modelStore.DataExchangeFactory.AccessorFactory));
            serializerMap.Add(ConfigConstants.ELEMENT_ITERATE, new IterateSerializer(modelStore.DataExchangeFactory.AccessorFactory));
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Insert"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            SelectKey selectKey = BuildSelectKey(modelStore, config, configurationSetting);

            return new Insert(
                id,
                parameterClass,
                parameterMap,
                resultClass,
                resultsMap,
                null,
                null,
                cacheModel,
                remapResults,
                extendsName,
                selectKey,
                sqlSource,
                preserveWhitespace
                );
        }
        /// <summary>
        /// Deserializes the specified configuration in a Statement object.
        /// </summary>
        /// <param name="modelStore"></param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting">Default settings.</param>
        /// <returns></returns>
        /// <remarks>
        /// Updated By: Richard Beacroft
        /// Updated Date: 11\10\2013
        /// Description: configurationSetting can be null and therefore references to it have to assume that it could be null.
        /// </remarks>
        protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            // DefaultModelBuilderTest.Test_DefaultModelBuilder assumes that configurationSetting can be null - added code accordingly.
            // Typically, no public method should allow null to be passed-in, best handled by overloading method to exclude parameter, or in .NET 4, use optional parameter.
            var preserveWhitespace = (configurationSetting == null) ? false : configurationSetting.PreserveWhitespace;
            bool useStatementNamespaces = (configurationSetting == null) ? false : configurationSetting.UseStatementNamespaces;

            nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE);
            id = useStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id;
            cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL);
            extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS);
            listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS);
            parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS);
            parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP);
            resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS);
            resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP);
            remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false);
            sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE);
            preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, preserveWhitespace);

            // Gets the results Map
            if (resultMapName.Length > 0)
            {
                string[] ids = resultMapName.Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    string name = ApplyNamespace(nameSpace, ids[i].Trim());
                    resultsMap.Add(modelStore.GetResultMap(name));
                }
            }

            // Gets the results class
            if (resultClassName.Length > 0)
            {
                string[] classNames = resultClassName.Split(',');
                for (int i = 0; i < classNames.Length; i++)
                {
                    resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim());
                    IFactory resultClassFactory = null;
                    if (Type.GetTypeCode(resultClass) == TypeCode.Object &&
                        (resultClass.IsValueType == false) && resultClass != typeof(DataRow))
                    {
                        resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes);
                    }
                    IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass);
                    bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass);
                    IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType);
                    resultsMap.Add(autoMap);
                }
            }

            // Gets the ParameterMap
            if (parameterMapName.Length > 0)
            {
                parameterMap = modelStore.GetParameterMap(parameterMapName);
            }

            // Gets the ParameterClass
            if (parameterClassName.Length > 0)
            {
                parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName);
            }

            // Gets the listClass
            if (listClassName.Length > 0)
            {
                listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName);
                listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes);
            }

            // Gets the CacheModel
            if (cacheModelName.Length > 0)
            {
                cacheModel = modelStore.GetCacheModel(cacheModelName);
            }

            // Gets the SqlSource
            if (sqlSourceClassName.Length > 0)
            {
                Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName);
                IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes);
                sqlSource = (ISqlSource)factory.CreateInstance(null);
            }
        }
Ejemplo n.º 43
0
 public ModelsCommittedMessage (IModelStore store) : base (store)
 {
 }
Ejemplo n.º 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InsertMappedStatement"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="statement">The statement.</param>
        public InsertMappedStatement(IModelStore modelStore, IStatement statement)
            : base(modelStore, statement)
		{
		}
Ejemplo n.º 45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InlineParemeterMapBuilder"/> class.
 /// </summary>
 public InlineParemeterMapBuilder(IModelStore modelStore)
 {
     this.modelStore = modelStore;
 }
Ejemplo n.º 46
0
        /// <summary>
        /// Initialize the Discriminator
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        public void Initialize(IModelStore modelStore)
		{
			// Set the ResultMaps 遍历每一个Case 根据其值获取ResultProperty类对象 保存到字典中
			int count = cases.Count;
			for(int index=0; index<count; index++)
			{
				Case kase = cases[index];
                resultMaps.Add(kase.DiscriminatorValue, modelStore.GetResultMap(kase.ResultMapName));
			}
		}
Ejemplo n.º 47
0
        /// <summary>
        /// Deserializes the specified configuration in a Statement object.
        /// </summary>
        /// <param name="modelStore"></param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting">Default settings.</param>
        /// <returns></returns>
        protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE);
            id = configurationSetting.UseStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id;
            cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL);
            extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS);
            listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS);
            parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS);
            parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP);
            resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS);
            resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP);
            remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false);
            sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE);
            preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace);

            // Gets the results Map
            if (resultMapName.Length > 0)
            {
                string[] ids = resultMapName.Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    string name = ApplyNamespace(nameSpace, ids[i].Trim());
                    resultsMap.Add(modelStore.GetResultMap(name));
                }
            }
            // Gets the results class
            if (resultClassName.Length > 0)
            {
                string[] classNames = resultClassName.Split(',');
                for (int i = 0; i < classNames.Length; i++)
                {
                    resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim());
                    IFactory resultClassFactory = null;
                    if (Type.GetTypeCode(resultClass) == TypeCode.Object &&
                        (resultClass.IsValueType == false) && resultClass != typeof(DataRow))
                    {
                        resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes);
                    }
                    IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass);
                    bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass);
                    IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType);
                    resultsMap.Add(autoMap);
                }
            }

            // Gets the ParameterMap
            if (parameterMapName.Length > 0)
            {
                parameterMap = modelStore.GetParameterMap(parameterMapName);
            }
            // Gets the ParameterClass
            if (parameterClassName.Length > 0)
            {
                parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName);
            }

            // Gets the listClass
            if (listClassName.Length > 0)
            {
                listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName);
                listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes);
            }

            // Gets the CacheModel
            if (cacheModelName.Length > 0)
            {
                cacheModel = modelStore.GetCacheModel(cacheModelName);
            }
            // Gets the SqlSource
            if (sqlSourceClassName.Length > 0)
            {
                Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName);
                IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes);
                sqlSource = (ISqlSource)factory.CreateInstance(null);
            }
        }
Ejemplo n.º 48
0
 /// <summary>
 /// Deserializes the specified configuration in a Statement object.
 /// </summary>
 /// <param name="modelStore">The model store.</param>
 /// <param name="config">The config.</param>
 /// <returns></returns>
 public abstract IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting);
Ejemplo n.º 49
0
        /// <summary>
        /// Builds the mapper factory.
        /// </summary>
        /// <returns>the mapper factory</returns>
        public IMapperFactory BuildMapperFactory()
        {
            // Registers file Xml, ... configuration element
            if (interpreter!=null)
            {
                interpreter.ProcessResource(configurationStore);

                // ensure that the default configuration settings get updated after the interpreter runs
                configurationSetting.PreserveWhitespace = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace);
                configurationSetting.UseReflectionOptimizer = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_USE_REFLECTION_OPTIMIZER, configurationSetting.UseReflectionOptimizer);
                configurationSetting.IsCacheModelsEnabled = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_CACHE_MODELS_ENABLED, configurationSetting.IsCacheModelsEnabled);
                configurationSetting.UseStatementNamespaces = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_USE_STATEMENT_NAMESPACES, configurationSetting.UseStatementNamespaces);
                configurationSetting.ValidateMapperConfigFile = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_VALIDATE_SQLMAP, configurationSetting.ValidateMapperConfigFile);
            }

            // Registers code configuration element
            //此处还未有案例分析????
            for(int i=0;i<modules.Count;i++)
            {
                modules[i].Configure(this);
            }

            // Process Extends ResultMap
            //将父节点的子节点信息添加到含有extends节点的下面
            List<IConfiguration> resolved = new List<IConfiguration>();
            for (int i = 0; i < configurationStore.ResultMaps.Length; i++)
            {
                ResolveExtendResultMap(resolved, configurationStore.ResultMaps[i]);
            }

            // Process Extends ParameterMap
            resolved = new List<IConfiguration>();
            for (int i = 0; i < configurationStore.ParameterMaps.Length; i++)
            {
                ResolveExtendParameterMap(resolved, configurationStore.ParameterMaps[i]);
            }

            // Process Include Sql statement
            //处理statements节点下的include属性
            for (int i = 0; i < configurationStore.Statements.Length; i++)
            {
                //获取节点statement update insert delete select节点的子节点include集合
                ConfigurationCollection includes = configurationStore.Statements[i].Children.RecursiveFind(ConfigConstants.ELEMENT_INCLUDE);

                if (includes.Count > 0)
                {
                    ResolveIncludeStatement(includes);
                }
            }

            // Process Extends statement
            resolved = new List<IConfiguration>();
            for (int i = 0; i < configurationStore.Statements.Length; i++)
            {
                ResolveExtendStatement(resolved, configurationStore.Statements[i]);
            }

            modelStore = new DefaultModelStore();

            IModelBuilder builder = new DefaultModelBuilder(modelStore);
            //核心处理结果都存储在了modelStore类中了
            builder.BuildModel(configurationSetting, configurationStore);
            //将核心处理结果对象存到DataMapper类中
            IDataMapper dataMapper = new DataMapper(modelStore);

            return new DefaultMapperFactory(dataMapper);
        }
Ejemplo n.º 50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SelectMappedStatement"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="statement">The statement.</param>
        public SelectMappedStatement(IModelStore modelStore, IStatement statement)
            : base(modelStore, statement)
		{ }
Ejemplo n.º 51
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateMappedStatement"/> class.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="statement">The statement.</param>
        public UpdateMappedStatement(IModelStore modelStore, IStatement statement)
            : base(modelStore, statement)
		{ }
Ejemplo n.º 52
0
 public AccountController(IModelStore modelStore)
 {
     this.ims = modelStore;
 }
Ejemplo n.º 53
0
        private void CheckModelStore(IModelStore store)
        {
            Console.WriteLine(store.ToString());

            //Assert.That(store.Properties.Length, Is.EqualTo(14));
            //Assert.That(store.GetPropertyConfiguration("useStatementNamespaces").Value, Is.EqualTo("false"));

            //Assert.That(store.Settings.Length, Is.EqualTo(4));
            //Assert.That(store.GetSettingConfiguration("validateSqlMap").Value, Is.EqualTo("false"));

            //Assert.That(store.Providers.Length, Is.EqualTo(17));
            //IConfiguration informixProvider = store.GetProviderConfiguration("Informix");
            //Assert.That(informixProvider.Attributes["description"], Is.EqualTo("Informix NET Provider, 2.81.0.0"));
            //Assert.That(informixProvider.Attributes["commandBuilderClass"], Is.EqualTo("IBM.Data.Informix.IfxCommandBuilder"));

            //Assert.That(store.Databases.Length, Is.EqualTo(1));
            //Assert.That(store.Databases[0].Children.Count, Is.EqualTo(2));

            //IConfiguration provider = store.Databases[0].Children.Find(DataConstants.ELEMENT_PROVIDER)[0];
            //Assert.That(provider, Is.Not.Null);
            //Assert.That(provider.Attributes[DataConstants.ATTRIBUTE_NAME], Is.EqualTo("sqlServer1.1"));
            //Assert.That(provider.Id, Is.EqualTo("sqlServer1.1"));
            //Assert.That(provider.Value, Is.EqualTo("sqlServer1.1"));
            //Assert.That(provider.Type, Is.EqualTo(DataConstants.ELEMENT_PROVIDER));

            //IConfiguration datasource = store.Databases[0].Children.Find(DataConstants.ELEMENT_DATASOURCE)[0];
            //Assert.That(datasource, Is.Not.Null);
            //Assert.That(datasource.Value.StartsWith("data source="));
            //Assert.That(datasource.Type, Is.EqualTo(DataConstants.ELEMENT_DATASOURCE));

            //Assert.That(store.Alias.Length, Is.EqualTo(12));
            //Assert.That(store.GetAliasConfiguration("Account").Value, Is.EqualTo("MyBatis.DataMapper.SqlClient.Test.Domain.Account, MyBatis.DataMapper.SqlClient.Test"));

            //Assert.That(store.TypeHandlers.Length, Is.EqualTo(2));
            //Assert.That(store.GetTypeHandlerConfiguration("bool").Attributes.Count, Is.EqualTo(3));
            //Assert.That(store.GetTypeHandlerConfiguration("string").Attributes.Count, Is.EqualTo(2));

            //// Cache model
            //Assert.That(store.CacheModels.Length, Is.EqualTo(2));
            //IConfiguration cacheModel = store.CacheModels[0];
            //Assert.That(cacheModel.Children.Count, Is.EqualTo(4));
            //Assert.That(cacheModel.Attributes.ContainsKey(ConfigConstants.ATTRIBUTE_NAMESPACE), Is.True);

            //// Result map
            //Assert.That(store.ResultMaps.Length, Is.EqualTo(3 + 3 + 2));
            //IConfiguration resultMap = store.GetResultMapConfiguration("Account.account-result-constructor");
            //Assert.IsNotNull(resultMap);
            //Assert.That(resultMap.Children.Count, Is.EqualTo(4));

            //IConfiguration constructor = resultMap.Children.Find(ConfigConstants.ELEMENT_CONSTRUCTOR)[0];
            //Assert.IsNotNull(constructor);
            //Assert.That(constructor.Children.Count, Is.EqualTo(3));

            //ConfigurationCollection arguments = constructor.Children.Find(ConfigConstants.ELEMENT_ARGUMENT);

            //Assert.IsNotEmpty(arguments);
            //Assert.That(arguments.Count, Is.EqualTo(3));
            //Assert.That(arguments[0].Attributes[ConfigConstants.ATTRIBUTE_ARGUMENTNAME], Is.EqualTo("identifiant"));

            //ConfigurationCollection results = resultMap.Children.Find(ConfigConstants.ELEMENT_RESULT);
            //Assert.IsNotEmpty(results);
            //Assert.That(results.Count, Is.EqualTo(3));
            //Assert.That(results[0].Attributes[ConfigConstants.ATTRIBUTE_PROPERTY], Is.EqualTo("EmailAddress"));

            //// Parameter map
            //Assert.That(store.ParameterMaps.Length, Is.EqualTo(7));
            //IConfiguration parameterMap = store.GetParameterMapConfiguration("Account.insert-params");
            //Assert.IsNotNull(parameterMap);
            //Assert.That(parameterMap.Children.Count, Is.EqualTo(6));

            //ConfigurationCollection parameters = parameterMap.Children.Find(ConfigConstants.ELEMENT_PARAMETER);

            //Assert.IsNotEmpty(parameters);
            //Assert.That(parameters.Count, Is.EqualTo(6));
            //Assert.That(parameters[4].Attributes.Count, Is.EqualTo(4));
            //Assert.That(parameters[3].Attributes[ConfigConstants.ATTRIBUTE_PROPERTY], Is.EqualTo("EmailAddress"));

            //// sql statement in Mapping2.xml
            //Assert.That(store.Statements.Length, Is.EqualTo(97));
            //IConfiguration sqlStatement = store.GetStatementConfiguration("includeComplex");
            //Assert.IsNotNull(sqlStatement);
            //Assert.That(sqlStatement.Attributes.ContainsKey(ConfigConstants.ATTRIBUTE_NAMESPACE), Is.True);

            //Assert.That(sqlStatement.Children.Count, Is.EqualTo(1));
            //IConfiguration child = sqlStatement.Children[0];//dynamic
            //Assert.That(child.Children.Count, Is.EqualTo(1));
            //child = child.Children[0];//isParameterPresent
            //Assert.That(child.Children.Count, Is.EqualTo(3));
            //child = child.Children[1];//isNotEmpty
            //Assert.That(child.Attributes.Count, Is.EqualTo(2));
            //Assert.IsTrue(child.Attributes.ContainsKey("prepend"));
            //Assert.IsTrue(child.Attributes.ContainsKey("property"));
            //Assert.That(child.Attributes["prepend"], Is.EqualTo("and"));
            //Assert.That(child.Attributes["property"], Is.EqualTo("FirstName"));
        }