예제 #1
0
 public NnClassifier(IScanningWindowGenerator swg, IObjectModel objectModel, float pnnSimilarityThreshold, float relativeSimilarityThreshold)
 {
     _scanningWindowGenerator     = swg;
     _objectModel                 = objectModel;
     _pnnSimilarityThreshold      = pnnSimilarityThreshold;
     _relativeSimilarityThreshold = relativeSimilarityThreshold;
 }
예제 #2
0
        private static ILearner LoadLearner(IObjectModel objectModel, IDetector detector)
        {
            // initial positive patch synthesis info
            WarpInfo initPosPatchWarpInfo = new WarpInfo(0.01f, 0.01f, 10);
            PositivePatchSynthesisInfo initPosPatchSynthesisInfo = new PositivePatchSynthesisInfo(
                100, 10, initPosPatchWarpInfo, 0.2
                );
            WarpInfo runtimePosPatchWarpInfo = new WarpInfo(0.01f, 0.01f, 10);
            PositivePatchSynthesisInfo runtimePosPatchSynthesisInfo = new PositivePatchSynthesisInfo(
                100, 10, runtimePosPatchWarpInfo, 0.2
                );

            // initial negative patch picking info
            NegativePatchPickingInfo initNegPatchPickInfo    = new NegativePatchPickingInfo(50, 10, 0.2f);
            NegativePatchPickingInfo runtimeNegPatchPickInfo = new NegativePatchPickingInfo(100, 10, 0.2f);

            Learner learner = new Learner(
                objectModel,
                detector,
                initPosPatchSynthesisInfo,
                initNegPatchPickInfo,
                runtimePosPatchSynthesisInfo,
                runtimeNegPatchPickInfo,
                0.95f,
                0.57f
                );

            return(learner);
        }
예제 #3
0
        /// <summary>
        /// Creates instance with valid type
        /// </summary>
        /// <param name="modelName">Model name of required instance</param>
        /// <returns>Instance with type set in <see cref="IObjectModel.InstanceTypeQualifiedName"/> (or default type <see cref="Constants.DefaultInstanceType"/>)</returns>
        public IObjectInstance CreateInstance(string modelName)
        {
            if (!cachedModels.ContainsKey(modelName))
            {
                throw new ModelNotFoundException(modelName);
            }

            IObjectModel model = cachedModels[modelName];

            if (string.IsNullOrEmpty(model.InstanceTypeQualifiedName))
            {
                model.InstanceTypeQualifiedName = Constants.DefaultInstanceType;
            }

            IObjectInstance instance = null;

            try
            {
                instance = (IObjectInstance)Activator.CreateInstance(Type.GetType(model.InstanceTypeQualifiedName), model);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(instance);
        }
예제 #4
0
 /// <summary>
 /// Setups the model and Form fields.
 /// </summary>
 /// <param name="form">The form</param>
 /// <param name="model">The IO bject model</param>
 /// <param name="fieldName">The field name</param>
 /// <param name="control">The object model iucontrol</param>
 /// <param name="id">The identifier setting. Default value = -1.</param>
 /// <code>CTIM_Generation;</code>
 public void ModelField(IObjectModel model, Form form, string fieldName, IUControl_ObjectModel control, int id = -1)
 {
     //=================
     // Generated @ 2015/07/20
     // Generated from 'BlueprintUI.Windows.libUI.WinForms.ModelField'() -> the parameter order was changed to ensure better MTIN results after transformations.
     ModelField(form, model, fieldName, control, id);
 }
예제 #5
0
        /// <summary>Generates the controls on the designer panels.</summary>
        /// <param name="form">The form</param>
        /// <param name="classObject">The class objectect</param>
        /// <param name="panel1">The panel1</param>
        /// <param name="panel2">The panel to setting. Default value = null.</param>
        /// <param name="panel3">The panel3 setting. Default value = null.</param>
        /// <param name="onValueChange">The on valueue change setting. Default value = null.</param>
        /// <returns>bool</returns>
        public bool Generate_Controls(Form form, IObjectModel classObject, Panel panel1, Panel panel2 = null, Panel panel3 = null, EventHandler <onInputControl_EventArgs> onValueChange = null)
        {
            var type = classObject.GetType();
            BlueprintData_TableAttribute attribute;

            LamedalCore_.Instance.Types.Class.ClassAttributes.Find_Class(type, out attribute, new BlueprintData_TableAttribute());

            stateForm state = form.zzState();

            state.onValueChange   = onValueChange;
            state.FormObjectModel = classObject;
            state.DoEventsFlag    = false;

            IDesignerHost host   = UIDesigner_Service.IDesignerHost_FromForm(form);
            int           height = Lamedal_WinForms.Instance.libUI.WinForms.FormGenerate.Generate_Controls(host, type, attribute, panel1, panel2, panel3, OnValueChangeEvent);

            form.Height = height;
            if (attribute != null)
            {
                if (attribute.Caption != "")
                {
                    form.Text = attribute.Caption;
                }
            }

            state.DoEventsFlag = true;
            return(true);
        }
예제 #6
0
        public IObjectModel Create(IObjectModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateIDIsNull(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Search for an Existing Record (Don't allow Duplicates
            var results = Search(ObjectMapper.MapToSearchModel(model));

            if (results.Any())
            {
                return(results.First());
            }                                              // Return the first that matches
            // Map model to a new entity
            var newEntity = ObjectMapper.MapToEntity(model);

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            ObjectsRepository.Add(newEntity);
            // Try to Save Changes
            ObjectsRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
예제 #7
0
        public IObjectModel Update(IObjectModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = ObjectsRepository.Get(model.Id.Value);

            // Check if we would be applying identical information, if we are, just return the original
            // ReSharper disable once SuspiciousTypeConversion.Global
            if (ObjectMapper.AreEqual(model, existingEntity))
            {
                return(ObjectMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            ObjectMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            ObjectsRepository.Update(ObjectMapper.MapToEntity(model));
            // Try to Save Changes
            ObjectsRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
예제 #8
0
        public async Task <ActionResult> Index(CancellationToken cancellationToken)
        {
            ViewData[Constant.FormTitle] = "ADD Object";
            IObjectModel model = await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken));

            return(View(model));
        }
예제 #9
0
파일: TLD.cs 프로젝트: denjiz/tld
 public Tld(IObjectModel objectModel, ITracker tracker, ILearner learner, IDetector detector, IOutputStrategy outputStrategy)
 {
     _objectModel    = objectModel;
     _tracker        = tracker;
     _learner        = learner;
     _detector       = detector;
     _outputStrategy = outputStrategy;
 }
        public void GetObject_Called_ReturnsObject()
        {
            _serv.Factory = _factoryMock.Object;

            IObjectModel newObj = _serv.GetObject(_someFirstName);

            Assert.Equal(_someFirstName + ", Cos", newObj.FullName);
        }
예제 #11
0
 public ObjectInstance(IObjectModel model)
 {
     this.Model      = model;
     this.Attributes = new Dictionary <string, IAttributeModel>();
     this.BeforeParse();
     this.Parse();
     this.AfterParse();
 }
예제 #12
0
        public frmObjectModel(IObjectModel objectModel, frmMain frmMain)
        {
            InitializeComponent();
            _frmMain = frmMain;

            _objectModel       = objectModel;
            NewPositivePatches = new List <Image <Gray, byte> >();
            NewNegativePatches = new List <Image <Gray, byte> >();
        }
 public virtual bool AreEqual(IObjectModel model, IObject entity)
 {
     return(NameableEntityMapper.AreEqual(model, entity)
            // Object Properties
            && model.StartYear == entity.StartYear
            // Related Objects
            && model.FirstIssueAppearanceId == entity.FirstIssueAppearanceId &&
            model.PrimaryImageFileId == entity.PrimaryImageFileId
            );
 }
 public virtual bool AreEqual(IObjectModel model, IObject entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Object Properties
         && model.StartYear == entity.StartYear
         // Related Objects
         && model.FirstIssueAppearanceId == entity.FirstIssueAppearanceId
         && model.PrimaryImageFileId == entity.PrimaryImageFileId
         ;
 }
예제 #15
0
 public bool ContainsInCached(IObjectModel model)
 {
     foreach (ObjectModelKey key in this.cachedModels.Keys)
     {
         if (key.Equals(new ObjectModelKey(model)))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #16
0
        public virtual QueryModel CreateNewQueryModel(LambdaExpression selector)
        {
            QueryModel newQueryModel = this._queryModel.Clone();

            ScopeParameterDictionary scopeParameters = this._queryModel.ScopeParameters.Clone(selector.Parameters[0], this._queryModel.ResultModel);
            IObjectModel             newResultModel  = SelectorResolver.Resolve(selector, scopeParameters, this._queryModel.ScopeTables);

            newQueryModel.ResultModel = newResultModel;

            return(newQueryModel);
        }
예제 #17
0
        public virtual GeneralQueryState AsSubQueryState()
        {
            DbSqlQueryExpression sqlQuery = this.CreateSqlQuery();
            DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery);

            QueryModel newQueryModel = new QueryModel(this._queryModel.ScopeParameters, this._queryModel.ScopeTables, this._queryModel.IgnoreFilters);

            DbTableSegment        tableSeg  = new DbTableSegment(subQuery, newQueryModel.GenerateUniqueTableAlias(), LockType.Unspecified);
            DbFromTableExpression fromTable = new DbFromTableExpression(tableSeg);

            newQueryModel.FromTable = fromTable;

            DbTable aliasTable = new DbTable(tableSeg.Alias);

            //TODO 根据旧的生成新 ResultModel
            IObjectModel newResultModel = this.QueryModel.ResultModel.ToNewObjectModel(sqlQuery, aliasTable, fromTable);

            newQueryModel.ResultModel = newResultModel;

            //得将 subQuery.SqlQuery.Orders 告诉 以下创建的 result
            //将 orderPart 传递下去
            for (int i = 0; i < this.QueryModel.Orderings.Count; i++)
            {
                DbOrdering   ordering    = this.QueryModel.Orderings[i];
                DbExpression orderingExp = ordering.Expression;

                string alias = null;

                DbColumnSegment columnExpression = sqlQuery.ColumnSegments.Find(a => DbExpressionEqualityComparer.EqualsCompare(orderingExp, a.Body));

                // 对于重复的则不需要往 sqlQuery.Columns 重复添加了
                if (columnExpression != null)
                {
                    alias = columnExpression.Alias;
                }
                else
                {
                    alias = Utils.GenerateUniqueColumnAlias(sqlQuery);
                    DbColumnSegment columnSeg = new DbColumnSegment(orderingExp, alias);
                    sqlQuery.ColumnSegments.Add(columnSeg);
                }

                DbColumnAccessExpression columnAccessExpression = new DbColumnAccessExpression(aliasTable, DbColumn.MakeColumn(orderingExp, alias));
                newQueryModel.Orderings.Add(new DbOrdering(columnAccessExpression, ordering.OrderType));
            }

            newQueryModel.InheritOrderings = true;

            GeneralQueryState queryState = new GeneralQueryState(newQueryModel);

            return(queryState);
        }
예제 #18
0
 public P3PoseEstimator(EquipmentSettings settings, IObjectModel model)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     this.settings = settings;
     this.model    = model;
 }
예제 #19
0
        private void SyncFormAndObject(Form form)
        {
            //Update the generated the form from the object.
            stateForm state = form.zzState();

            state.DoEventsFlag = false;   // Stop events while we update things
            IObjectModel classObject = state.FormObjectModel;

            try
            {
                Lamedal_WinForms.Instance.libUI.WinForms.FormGenerate.Form_FromObject(form, classObject);
            }
            finally { state.DoEventsFlag = true; }  // Activate the events again
        }
예제 #20
0
        protected override DbExpression VisitParameter(ParameterExpression exp)
        {
            //只支持 MappingFieldExpression 类型,即类似 q.Select(a=> a.Id).Where(a=> a > 0) 这种情况,也就是 ParameterExpression.Type 为基本映射类型。

            if (MappingTypeSystem.IsMappingType(exp.Type))
            {
                IObjectModel         model       = this.FindModel(exp);
                PrimitiveObjectModel resultModel = (PrimitiveObjectModel)model;
                return(resultModel.Expression);
            }
            else
            {
                throw new NotSupportedException(exp.ToString());
            }
        }
예제 #21
0
 public bool ReplaceModel(int id, IObjectModel model)
 {
     lock (modelSync) {
         if (id < 0 || id >= models.Count)
         {
             return(false);
         }
         if (models[id] == null)
         {
             return(false);
         }
         models[id] = model;
         return(true);
     }
 }
예제 #22
0
        public async Task <ActionResult> IndexEdit(long hdObjectId, CancellationToken cancellationToken)
        {
            if (hdObjectId > 0)
            {
                ViewData[Constant.FormTitle] = "EDIT Object";
                IObjectModel model = await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, hdObjectId, GetCanellationToken(cancellationToken));

                ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess];
                return(View("Index", model));
            }
            else
            {
                return(Redirect("~/ObjectSearch/Index"));
            }
        }
예제 #23
0
        /// <summary>
        /// Setups the model and Form fields.
        /// </summary>
        /// <param name="form">The form</param>
        /// <param name="model">The IO bject model</param>
        /// <param name="fieldName">The field name</param>
        /// <param name="control">The object model iucontrol</param>
        /// <param name="id">The identifier setting. Default value = -1.</param>
        /// <code GenerateParameter1="model"></code>
        public void ModelField(Form form, IObjectModel model, string fieldName, IUControl_ObjectModel control, int id = -1)
        {
            // Double check value before assignment!
            // =====================================
            var type = model.GetType();

            BlueprintData_FieldAttribute[] fieldDefinition = null;

            FieldInfo fieldInfo1 = type.GetField(fieldName);

            if (fieldInfo1 != null)
            {
                fieldDefinition = (BlueprintData_FieldAttribute[])fieldInfo1.GetCustomAttributes(typeof(BlueprintData_FieldAttribute), false);
            }
            else
            {
                PropertyInfo propertyInfo = type.GetProperty(fieldName);
                if (propertyInfo != null)
                {
                    fieldDefinition = (BlueprintData_FieldAttribute[])propertyInfo.GetCustomAttributes(typeof(BlueprintData_FieldAttribute), false);
                }
            }

            if (fieldDefinition == null)
            {
                var errMsg = "Error! Field '{0}.{1}' does not exist!".zFormat(type.ToString(), fieldName);
                throw new ArgumentException(errMsg, nameof(fieldName));
            }

            // Check the ID value
            // ==================
            var fieldId = fieldDefinition.Length > 0 ? fieldDefinition[0].Id : -1;

            if (id != -1)
            {
                if (id != fieldId)
                {
                    string msg = "Error in object mapping!".NL() + "Field '{0}.{1}'".zFormat(type.ToString(), fieldName).NL() +
                                 "{0} id = {1} (and not {2} as expected)".zFormat(fieldName, fieldId, id);
                    throw new ArgumentException(msg, nameof(id));
                }
            }

            control.Field_Name = fieldName;   // Map the field;

            // Update the field value on the form
            Lamedal_WinForms.Instance.libUI.WinForms.FormGenerate.Form_FromObject(form, model, fieldName);  // Sync form
        }
 public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var entity = ObjectsMockingSetup.DoMockingSetupForObject(1);
     var mockObjectsRepository = ObjectsMockingSetup.DoMockingSetupForRepository();
     mockObjectsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => entity.Object);
     var businessWorkflow = new ObjectsBusinessWorkflow(mockObjectsRepository.Object, new ObjectMapper());
     var model = ObjectsMockingSetup.DoMockingSetupForObjectModel(1);
     IObjectModel result = null;
     // Act
     try { result = businessWorkflow.Update(model.Object); }
     catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
     // Assert
     Assert.NotNull(result);
     Assert.Equal("/TEST/KING-STEPHEN", result.ApiDetailUrl);
     Assert.Null(result.UpdatedDate);
 }
예제 #25
0
        public virtual QueryModel ToFromQueryModel()
        {
            QueryModel queryModel = new QueryModel(this._queryModel.ScopeParameters, this._queryModel.ScopeTables, this._queryModel.IgnoreFilters);

            string alias = queryModel.GenerateUniqueTableAlias(UtilConstants.DefaultTableAlias);
            DbSqlQueryExpression sqlQuery = this.CreateSqlQuery();
            DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery);

            DbTableSegment        tableSeg  = new DbTableSegment(subQuery, alias, LockType.Unspecified);
            DbFromTableExpression fromTable = new DbFromTableExpression(tableSeg);

            DbTable      aliasTable = new DbTable(tableSeg.Alias);
            IObjectModel newModel   = this.QueryModel.ResultModel.ToNewObjectModel(sqlQuery, aliasTable, fromTable);

            queryModel.FromTable   = fromTable;
            queryModel.ResultModel = newModel;
            return(queryModel);
        }
예제 #26
0
        public virtual QueryModel CreateNewQueryModel(LambdaExpression selector)
        {
            QueryModel newQueryModel = this._queryModel.Clone();

            ComplexObjectModel complexObjectModel = this._queryModel.ResultModel as ComplexObjectModel;

            if (complexObjectModel != null)
            {
                complexObjectModel.SetupFilters(this._queryModel.IgnoreFilters);
            }

            ScopeParameterDictionary scopeParameters = this._queryModel.ScopeParameters.Clone(selector.Parameters[0], this._queryModel.ResultModel);
            IObjectModel             newResultModel  = SelectorResolver.Resolve(selector, scopeParameters, this._queryModel.ScopeTables);

            newQueryModel.ResultModel = newResultModel;

            return(newQueryModel);
        }
예제 #27
0
        private void OnValueChangeEvent(object sender, onInputControl_EventArgs e)
        {
            // Update the object from when the form values change
            Form      frm   = e.Control_.ParentForm;
            stateForm state = frm.zzState();

            if (state.DoEventsFlag == false)
            {
                return;                                // Events were stopped -> Exit <=========================================================
            }
            IObjectModel classObject = state.FormObjectModel;

            if (state.onValueChange != null)
            {
                state.onValueChange(sender, e);                                                  // Notify the client that the value has changed
            }
            Lamedal_WinForms.Instance.libUI.WinForms.FormGenerate.Form_ToObject(e, classObject); // Update the object in memory
            500.zExecute_Async(() => SyncFormAndObject(frm), "formRefresh", true);               // Sync the object back to the form in 1 sec
        }
예제 #28
0
        public static ITld Instantiate()
        {
            IObjectModel      objectModel = LoadObjectModel();
            MedianFlowTracker tracker     = LoadTracker();
            IDetector         detector    = LoadDetector(objectModel);
            ILearner          learner     = LoadLearner(objectModel, detector);

            ITld tld = new Tld(
                objectModel,
                tracker,
                learner,
                detector,
                new ZdenekOutputStrategy(objectModel, learner)
                );

            tld.PostInstantiation();

            return(tld);
        }
 public virtual void MapToEntity(IObjectModel model, ref IObject entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Object Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance   = (Issue)model.FirstIssueAppearance?.MapToEntity();
     entity.PrimaryImageFileId     = model.PrimaryImageFileId;
     entity.PrimaryImageFile       = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.ObjectAliases          = model.ObjectAliases?.Where(i => i.Active).Select(ObjectAliasMapperExtensions.MapToEntity).ToList();
     entity.ObjectIssuesAppearedIn = model.ObjectIssuesAppearedIn?.Where(i => i.Active).Select(ObjectAppearedInIssueMapperExtensions.MapToEntity).ToList();
     entity.ObjectIssues           = model.ObjectIssues?.Where(i => i.Active).Select(ObjectIssueMapperExtensions.MapToEntity).ToList();
     entity.ObjectMovies           = model.ObjectMovies?.Where(i => i.Active).Select(ObjectMovieMapperExtensions.MapToEntity).ToList();
     entity.ObjectStoryArcs        = model.ObjectStoryArcs?.Where(i => i.Active).Select(ObjectStoryArcMapperExtensions.MapToEntity).ToList();
     entity.ObjectVolumes          = model.ObjectVolumes?.Where(i => i.Active).Select(ObjectVolumeMapperExtensions.MapToEntity).ToList();
 }
 public virtual void MapToEntity(IObjectModel model, ref IObject entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Object Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance = (Issue)model.FirstIssueAppearance?.MapToEntity();
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.ObjectAliases = model.ObjectAliases?.Where(i => i.Active).Select(ObjectAliasMapperExtensions.MapToEntity).ToList();
     entity.ObjectIssuesAppearedIn = model.ObjectIssuesAppearedIn?.Where(i => i.Active).Select(ObjectAppearedInIssueMapperExtensions.MapToEntity).ToList();
     entity.ObjectIssues = model.ObjectIssues?.Where(i => i.Active).Select(ObjectIssueMapperExtensions.MapToEntity).ToList();
     entity.ObjectMovies = model.ObjectMovies?.Where(i => i.Active).Select(ObjectMovieMapperExtensions.MapToEntity).ToList();
     entity.ObjectStoryArcs = model.ObjectStoryArcs?.Where(i => i.Active).Select(ObjectStoryArcMapperExtensions.MapToEntity).ToList();
     entity.ObjectVolumes = model.ObjectVolumes?.Where(i => i.Active).Select(ObjectVolumeMapperExtensions.MapToEntity).ToList();
 }
 public IObjectModel Create(IObjectModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateIDIsNull(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Search for an Existing Record (Don't allow Duplicates
     var results = Search(ObjectMapper.MapToSearchModel(model));
     if (results.Any()) { return results.First(); } // Return the first that matches
     // Map model to a new entity
     var newEntity = ObjectMapper.MapToEntity(model);
     newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
     newEntity.UpdatedDate = null;
     newEntity.Active = true;
     // Add it
     ObjectsRepository.Add(newEntity);
     // Try to Save Changes
     ObjectsRepository.SaveChanges();
     // Return the new value
     return Get(newEntity.Id);
 }
예제 #32
0
        protected override DbExpression VisitMemberAccess(MemberExpression exp)
        {
            ParameterExpression p;

            if (ExpressionExtension.IsDerivedFromParameter(exp, out p))
            {
                IObjectModel model = this.FindModel(p);
                return(model.GetDbExpression(exp));
            }

            if (IsComeFrom_First_Or_FirstOrDefault(exp))
            {
                DbExpression dbExpression = this.Process_MemberAccess_Which_Link_First_Or_FirstOrDefault(exp);
                return(dbExpression);
            }
            else
            {
                return(base.VisitMemberAccess(exp));
            }
        }
예제 #33
0
 public int RegisterModel(IObjectModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     lock (modelSync) {
         for (int i = 0; i < models.Count; i++)
         {
             if (models[i] == null)
             {
                 models[i] = model;
                 return(i);
             }
         }
         int index = models.Count;
         models.Add(model);
         return(index);
     }
 }
 public virtual IObject MapToEntity(IObjectModel model, int currentDepth = 1)
 {
     currentDepth++;
     var entity = NameableEntityMapper.MapToEntity<Object, IObjectModel>(model);
     // Object Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance = (Issue)model.FirstIssueAppearance?.MapToEntity();
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.ObjectAliases = model.ObjectAliases?.Where(i => i.Active).Select(ObjectAliasMapperExtensions.MapToEntity).Cast<ObjectAlias>().ToList();
     entity.ObjectIssuesAppearedIn = model.ObjectIssuesAppearedIn?.Where(i => i.Active).Select(ObjectAppearedInIssueMapperExtensions.MapToEntity).Cast<ObjectAppearedInIssue>().ToList();
     entity.ObjectIssues = model.ObjectIssues?.Where(i => i.Active).Select(ObjectIssueMapperExtensions.MapToEntity).Cast<ObjectIssue>().ToList();
     entity.ObjectMovies = model.ObjectMovies?.Where(i => i.Active).Select(ObjectMovieMapperExtensions.MapToEntity).Cast<ObjectMovie>().ToList();
     entity.ObjectStoryArcs = model.ObjectStoryArcs?.Where(i => i.Active).Select(ObjectStoryArcMapperExtensions.MapToEntity).Cast<ObjectStoryArc>().ToList();
     entity.ObjectVolumes = model.ObjectVolumes?.Where(i => i.Active).Select(ObjectVolumeMapperExtensions.MapToEntity).Cast<ObjectVolume>().ToList();
     // Return Entity
     return entity;
 }
 public virtual IObjectSearchModel MapToSearchModel(IObjectModel model)
 {
     var searchModel = NameableEntityMapper.MapToSearchModel<IObjectModel, ObjectSearchModel>(model);
     // Search Properties
     searchModel.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     searchModel.FirstIssueAppearanceCustomKey = model.FirstIssueAppearance?.CustomKey;
     searchModel.FirstIssueAppearanceApiDetailUrl = model.FirstIssueAppearance?.ApiDetailUrl;
     searchModel.FirstIssueAppearanceSiteDetailUrl = model.FirstIssueAppearance?.SiteDetailUrl;
     searchModel.FirstIssueAppearanceName = model.FirstIssueAppearance?.Name;
     searchModel.FirstIssueAppearanceShortDescription = model.FirstIssueAppearance?.ShortDescription;
     searchModel.FirstIssueAppearanceDescription = model.FirstIssueAppearance?.Description;
     searchModel.PrimaryImageFileId = model.PrimaryImageFileId;
     searchModel.PrimaryImageFileCustomKey = model.PrimaryImageFile?.CustomKey;
     searchModel.PrimaryImageFileApiDetailUrl = model.PrimaryImageFile?.ApiDetailUrl;
     searchModel.PrimaryImageFileSiteDetailUrl = model.PrimaryImageFile?.SiteDetailUrl;
     searchModel.PrimaryImageFileName = model.PrimaryImageFile?.Name;
     searchModel.PrimaryImageFileShortDescription = model.PrimaryImageFile?.ShortDescription;
     searchModel.PrimaryImageFileDescription = model.PrimaryImageFile?.Description;
     // Return Search Model
     return searchModel;
 }
 public IObjectModel Update(IObjectModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Find existing entity
     // ReSharper disable once PossibleInvalidOperationException
     var existingEntity = ObjectsRepository.Get(model.Id.Value);
     // Check if we would be applying identical information, if we are, just return the original
     // ReSharper disable once SuspiciousTypeConversion.Global
     if (ObjectMapper.AreEqual(model, existingEntity))
     {
         return ObjectMapper.MapToModel(existingEntity);
     }
     // Map model to an existing entity
     ObjectMapper.MapToEntity(model, ref existingEntity);
     existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
     // Update it
     ObjectsRepository.Update(ObjectMapper.MapToEntity(model));
     // Try to Save Changes
     ObjectsRepository.SaveChanges();
     // Return the new value
     return Get(existingEntity.Id);
 }