private EntityProxy CreateProxy(string language, IEnumerable <Node> values)
        {
            var entityId  = new EntityId("urn:test");
            var predicate = new Uri("urn:predicate");
            var store     = new Mock <IEntityStore>();

            store.Setup(instance => instance.GetObjectsForPredicate(entityId, predicate, It.IsAny <Uri>())).Returns(values);
            var context = new Mock <IEntityContext>();

            context.SetupGet(instance => instance.CurrentCulture).Returns(new CultureInfo(language));
            context.SetupGet(instance => instance.Store).Returns(store.Object);
            var entity = new Entity(entityId, context.Object);

            context.Setup(instance => instance.InitializeEnitity(entity));
            var propertyMapping = new Mock <IPropertyMapping>();

            propertyMapping.SetupGet(instance => instance.Uri).Returns(predicate);
            var mapping = new Mock <IEntityMapping>();

            mapping.Setup(instance => instance.PropertyFor("Test")).Returns(propertyMapping.Object);
            var transformer = new Mock <IResultTransformer>();
            var catalog     = new Mock <IResultTransformerCatalog>();

            catalog.Setup(instance => instance.GetTransformer(propertyMapping.Object)).Returns(transformer.Object);
            var selector = new Mock <INamedGraphSelector>();

            selector.Setup(instance => instance.SelectGraph(entityId, mapping.Object, propertyMapping.Object)).Returns(new Uri("urn:graph"));
            var proxy = new EntityProxy(entity, mapping.Object, catalog.Object, selector.Object, null);

            transformer.Setup(instance => instance.FromNodes(proxy, propertyMapping.Object, context.Object, It.IsAny <IEnumerable <INode> >()))
            .Returns <IEntityProxy, IPropertyMapping, IEntityContext, IEnumerable <INode> >(
                (prx, pm, ctx, nodes) => nodes.Select(node => (node.IsLiteral ? (object)node.Literal : (object)node.Uri)).FirstOrDefault());

            return(proxy);
        }
        /// <summary>
        /// Called when context menu is opened.
        /// </summary>
        private void SceneContextMenuStrip_Opening(object sender, CancelEventArgs e)
        {
            // Check if user has opened context menu on an entity node
            bool            enableComponentMenus = false;
            BaseEditorProxy proxy  = GetSelectedProxy();
            EntityProxy     entity = GetSelectedEntity();

            if (entity != null)
            {
                enableComponentMenus = true;
            }

            // Disable/Enable component menus
            EnableComponentsMenu(enableComponentMenus);

            // Cannot delete scene document proxy
            if (proxy is SceneDocumentProxy)
            {
                DeleteSceneObjectMenu.Enabled = false;
            }
            else
            {
                DeleteSceneObjectMenu.Enabled = true;
            }
        }
示例#3
0
        public IndexSpecification <T> Add(string propertyName, IndexType indexType)
        {
            EntityProxy <T> proxy  = EntityProxyManager.Instance.GetEntityProxy <T>();
            PropertySchema  schema = proxy.GetProperty(propertyName);

            if (schema == null)
            {
                return(this);
            }

            bool containFlag = false;

            foreach (IndexMeta item in IndexedProperties)
            {
                if (string.Compare(item.PropertyName, schema.Name, false) == 0)
                {
                    containFlag = true;
                    break;
                }
            }

            if (!containFlag)
            {
                IndexedProperties.Add(new IndexMeta()
                {
                    PropertyName = schema.Name, IndexType = indexType, PropertyType = schema.PropertyType
                });
            }

            return(this);
        }
示例#4
0
        public IndexList(IndexMeta indexMeta, List <T> list)
        {
            this.indexMeta = indexMeta;
            proxy          = EntityProxyManager.Instance.GetEntityProxy <T>();

            CreateIndexValue(list);
        }
示例#5
0
        /// <summary>
        /// Get the property value of the instance.
        /// </summary>
        /// <typeparam name="T">the type of instance.</typeparam>
        /// <param name="src">the instance.</param>
        /// <param name="propertyName">the property name. ignore the case sensitive.</param>
        public static object GetPropertyValue <T>(T src, string propertyName)
            where T : class
        {
            EntityProxy <T> proxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            return(proxy.GetPropertyValue(src, propertyName));
        }
示例#6
0
        public ControllerBase()
        {
            if (OrmUtil.CheckCacheFlag <T>())
            {
                DbSession.RegisterCacheTable(TableName, true);
            }

            EntityProxy <T> entityProxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            foreach (PropertySchema item in entityProxy.GetPropertyList())
            {
                if (item.PropertyType.IsEnum)
                {
                    Dictionary <string, string> dict = new Dictionary <string, string>();

                    foreach (object enumItem in Enum.GetValues(item.PropertyType))
                    {
                        long l = Convert.ToInt64(enumItem);
                        dict.Add(l.ToString(), enumItem.ToString());
                    }

                    DataMapping.Instance.Add(item.PropertyType.ToString(), dict);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Set the property value of the instance.
        /// </summary>
        /// <typeparam name="T">the type of instance.</typeparam>
        /// <param name="src">the instance.</param>
        /// <param name="propertyName">the property name. ignore the case sensitive.</param>
        /// <param name="propertyValue">the property value.</param>
        public static void SetPropertyValue <T>(T src, string propertyName, object propertyValue)
            where T : class
        {
            EntityProxy <T> proxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            proxy.SetPropertyValue(src, propertyName, propertyValue);
        }
        /// <summary>
        /// Creates a new light proxy.
        /// </summary>
        private LightProxy AddLightProxy(EntityProxy parent)
        {
            LightProxy light = new LightProxy(sceneDocument, parent);
            TreeNode   node  = AddTreeNode(parent.TreeNode, light);

            return(light);
        }
示例#9
0
        // --------------------------------------------------------------------

        public void ExitEntity()
        {
            AssetLoader <Entity> .Save(mEntityProxy.EntityRef, mEntityProxy.EntityRef.LinkedProjectAsset.Path);

            mEntityProxy = null;
            SetScene(mScene);
        }
示例#10
0
        /// <summary>
        /// 保存数据。
        /// 默认的表名就是类名, 若T类型上有指定的表名,则以此为准
        /// 默认的自增列为Id,若T类型上有指定的自增列, 则以此为准。
        /// 若value中的标识列大于0, 则修改。 若小于等于0, 则新增。
        /// 注:主键为int
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="value">类型值</param>
        /// <returns>新增则返回自增列, 修改则返回本身标示列值。</returns>
        public int Save <T>(T value) where T : class
        {
            ThrowExceptionUtil.ArgumentNotNull(value, "value");

            string identityColumnName = OrmUtil.GetIdentityColumnName <T>();

            string tableName = OrmUtil.GetTableName <T>();

            EntityProxy <T> entityProxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            object identity = entityProxy.GetPropertyValue(value, identityColumnName);

            ThrowExceptionUtil.ArgumentConditionTrue(identity != null, string.Empty, "未指定主键列");

            if ((int)identity <= 0)
            {
                return(Insert <T>(value));
            }
            else
            {
                BeeDataAdapter dataAdapter = BeeDataAdapter.From <T>(value);
                dataAdapter.RemoveKey(identityColumnName);

                Update(tableName, dataAdapter, SqlCriteria.New.Equal(identityColumnName, identity));

                return((int)identity);
            }
        }
示例#11
0
        public void SetEntity(IEntity entity, bool replace)
        {
            var isAdded = false;
            var path    = entity.Path;

            lock (_modified)
            {
                if (!_modified.TryGetValue(path, out var proxy) ||
                    proxy.State != EntityState.Modified)
                {
                    _modified[path] = new EntityProxy(this, entity);
                    isAdded         = true;
                }
                else if (replace) // if it is allowed to replace the entity in the modified list
                {
                    proxy.Capture(entity);
                    isAdded = true;
                }
            }

            // invoke entity changed event
            if (isAdded)
            {
                Changed?.Invoke(this, new EntityEventArgs(entity));
            }
        }
示例#12
0
        private T ExecuteDataReader <T>(DbDataReader dataReader)
            where T : class
        {
            var len = dataReader.FieldCount;

            EntityProxy <T> entityProxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            T result = entityProxy.CreateInstance() as T;

            for (var i = 0; i < len; i++)
            {
                string name     = dataReader.GetName(i);
                var    rawValue = dataReader.GetValue(i);

                try
                {
                    entityProxy.SetPropertyValue(result, name, rawValue);
                }
                catch (Exception)
                {
                    ThrowExceptionUtil.ThrowMessageException("setpropertyerror.name:{0} value:{1}".FormatWith(name, rawValue));
                }
            }

            return(result);
        }
        /// <summary>
        /// Creates a new sphere primitive proxy.
        /// </summary>
        private SphereProxy AddSphereProxy(EntityProxy parent)
        {
            SphereProxy sphere = new SphereProxy(sceneDocument, parent);
            TreeNode    node   = AddTreeNode(parent.TreeNode, sphere);

            return(sphere);
        }
        // --------------------------------------------------------------------

        public static void AddProxy()
        {
            EntityProxy tmp = new EntityProxy("TemplateProxy");

            tmp.Parent             = SceneManagement.ActiveScene.Root;
            Selection.ActiveObject = tmp;
        }
 //[Fact] //TODO: That's a problem but related to AutoMapper rather than ABP.
 public void Should_Map_EntityProxy_To_EntityDto_And_To_DrivedEntityDto()
 {
     var proxy = new EntityProxy() { Value = "42"};
     var target = _mapper.Map<EntityDto>(proxy);
     var target2 = _mapper.Map<DerivedEntityDto>(proxy);
     target.Value.ShouldBe("42");
     target2.Value.ShouldBe("42");
 }
        public void Should_Map_EntityProxy_To_EntityDto_And_To_DrivedEntityDto()
        {
            var proxy = new EntityProxy()
            {
                Value = "42"
            };
            var target  = _mapper.Map <EntityDto>(proxy);
            var target2 = _mapper.Map <DerivedEntityDto>(proxy);

            target.Value.ShouldBe("42");
            target2.Value.ShouldBe("42");
        }
        //[Fact] //TODO: That's a problem but related to AutoMapper rather than StudioX.
        public void ShouldMapEntityProxyToEntityDtoAndToDrivedEntityDto()
        {
            var proxy = new EntityProxy()
            {
                Value = "42"
            };
            var target  = mapper.Map <EntityDto>(proxy);
            var target2 = mapper.Map <DerivedEntityDto>(proxy);

            target.Value.ShouldBe("42");
            target2.Value.ShouldBe("42");
        }
        /// <summary>
        /// Called when a new Daggerfall model is requested.
        /// </summary>
        private void AddDaggerfallModelMenuItem_Click(object sender, EventArgs e)
        {
            // Get selected entity
            EntityProxy entity = GetSelectedEntity();

            if (entity == null)
            {
                return;
            }

            // Add model
            DaggerfallModelProxy modelProxy = AddModelProxy(entity, defaultModelId);
        }
        /// <summary>
        /// Called when a new Daggerfall block is requested.
        /// </summary>
        private void AddDaggerfallBlockMenuItem_Click(object sender, EventArgs e)
        {
            // Get selected entity
            EntityProxy entity = GetSelectedEntity();

            if (entity == null)
            {
                return;
            }

            // Add block
            DaggerfallBlockProxy blockProxy = AddBlockProxy(entity, defaultBlockName);
        }
        /// <summary>
        /// Creates a new model component proxy.
        /// </summary>
        private DaggerfallModelProxy AddModelProxy(EntityProxy parent, uint id)
        {
            // Create new model
            DaggerfallModelComponent model = new DaggerfallModelComponent(worldControl.Core, id);

            // Create proxy for component
            DaggerfallModelProxy modelProxy = new DaggerfallModelProxy(sceneDocument, parent, model);

            // Add new proxy to tree view
            TreeNode node = AddTreeNode(parent.TreeNode, modelProxy);

            return(modelProxy);
        }
        /// <summary>
        /// Called when a new terrain is requested.
        /// </summary>
        private void AddQuadTerrainMenuItem_Click(object sender, EventArgs e)
        {
            // Get selected entity
            EntityProxy entity = GetSelectedEntity();

            if (entity == null)
            {
                return;
            }

            // Add quad terrain
            QuadTerrainProxy terrainProxy = AddQuadTerrainComponentProxy(entity);
        }
        /// <summary>
        /// Called when a new light is requested.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddLightMenuItem_Click(object sender, EventArgs e)
        {
            // Get selected entity
            EntityProxy entity = GetSelectedEntity();

            if (entity == null)
            {
                return;
            }

            // Add light
            LightProxy lightProxy = AddLightProxy(entity);
        }
        // --------------------------------------------------------------------

        public static void CreateFromSelection()
        {
            if (Selection.ActiveObject == null)
            {
                return;
            }

            if (Selection.ActiveObject.GetType() == typeof(EntityProxy))
            {
                if (Selection.Selected.Count > 0)
                {
                    if (MessageBox.Show("Add selected objects to active entity?", "Add to entity", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        Entity entity = (Selection.ActiveObject as EntityProxy).EntityRef;

                        foreach (SceneObject obj in Selection.Selected)
                        {
                            if (obj != Selection.ActiveObject)
                            {
                                obj.Parent = Selection.ActiveObject; // Do this so the localposition is transformed into the instance space
                                obj.Parent = entity.Root;
                            }
                        }

                        AssetLoader <Entity> .Save(entity, entity.LinkedProjectAsset.Path);

                        Selection.ActiveObject = Selection.ActiveObject;
                    }
                }
                return;
            }

            NewEntityWindow window = new NewEntityWindow();

            if (window.ShowDialog() == DialogResult.OK)
            {
                SceneObject parent = Selection.ActiveObject.Parent;

                OpenTK.Vector3 position = Selection.MiddlePoint();
                Entity         entity   = Create(Selection.Selected, window.EntityName, position);
                EntityProxy    proxy    = new EntityProxy(Selection.ActiveObject.Id, SceneManagement.ActiveScene);

                proxy.EntityRef = entity;
                proxy.Parent    = parent;
                proxy.Transform.LocalPosition = position;

                Selection.ActiveObject = proxy;
            }
            window.Dispose();
        }
示例#24
0
        private void bTp_Click(object sender, EventArgs e)
        {
            //RemotingServices.IsTransparentProxy(this);
            TestService t = new TestService();

            t.Name = "xxx";
            EntityProxy p = new EntityProxy(t);
            object      o = p.GetTransparentProxy();
            TestService s = o as TestService;
            //var r = s.Test();
            var r = s.Name;

            MessageBox.Show(r.ToString());
        }
示例#25
0
 private void renderCanvas_DoubleClick(object sender, EventArgs e)
 {
     if (Selection.ActiveObject != null && Selection.ActiveObject.GetType() == typeof(EntityProxy))
     {
         EntityProxy proxy = (EntityProxy)Selection.ActiveObject;
         sceneHierarchy.EnterEntity(proxy);
         SetEditingEntity(proxy);
     }
     else if (Selection.ActiveObject == null && EditingEntity)
     {
         sceneHierarchy.ExitEntity();
         SetEditingEntity(null);
     }
 }
        public void Setup()
        {
            _mapping = new Mock<IEntityMapping>(MockBehavior.Strict);
            _context = new Mock<IEntityContext>(MockBehavior.Strict);
            _graphSelector = new Mock<INamedGraphSelector>();

            _context.Setup(c => c.Store).Returns(new EntityStore());
            _context.Setup(c => c.GraphSelector).Returns(_graphSelector.Object);
            _context.Setup(c => c.InitializeEnitity(It.IsAny<IEntity>()));
            _graphSelector.Setup(g => g.SelectGraph(It.IsAny<EntityId>(), It.IsAny<IEntityMapping>(), It.IsAny<IPropertyMapping>()))
                          .Returns(new Uri("urn:default:graph"));

            var entity = new Entity(_entityId, _context.Object);
            _entityProxy = new EntityProxy(entity, _mapping.Object, new TestTransformerCatalog());
        }
        /// <summary>
        /// Creates a new block component proxy.
        /// </summary>
        private DaggerfallBlockProxy AddBlockProxy(EntityProxy parent, string name)
        {
            // Create new block
            DaggerfallBlockComponent block = new DaggerfallBlockComponent(worldControl.Core);

            block.LoadBlock(defaultBlockName, MapsFile.DefaultClimateSettings, worldControl.Core.ActiveScene, false);

            // Create proxy for component
            DaggerfallBlockProxy blockProxy = new DaggerfallBlockProxy(sceneDocument, parent, block);

            // Add new proxy to tree view
            TreeNode node = AddTreeNode(parent.TreeNode, blockProxy);

            return(blockProxy);
        }
        /// <summary>
        /// Creates a new entity proxy.
        /// </summary>
        private EntityProxy AddEntityProxy()
        {
            // Create new entity
            DynamicEntity entity = new DynamicEntity(sceneDocument.EditorScene);

            // Create new entity proxy
            EntityProxy entityProxy = new EntityProxy(sceneDocument, entity);

            // Add new entity proxy to tree view
            TreeNode entityNode = AddTreeNode(documentProxy.TreeNode, entityProxy);

            // Assign tree node to proxy
            entityProxy.TreeNode = entityNode;

            return(entityProxy);
        }
        /// <summary>
        /// Creates a new quad terrain proxy.
        /// </summary>
        private QuadTerrainProxy AddQuadTerrainComponentProxy(EntityProxy parent)
        {
            // Create new quad terrain
            QuadTerrainComponent quadTerrain = new QuadTerrainComponent(worldControl.Core, QuadTerrainComponent.TerrainSize.Small);

            // Create new quad terrain proxy
            QuadTerrainProxy quadTerrainProxy = new QuadTerrainProxy(sceneDocument, parent, quadTerrain);

            // Add new quad terrain proxy to tree view
            TreeNode quadTerrainNode = AddTreeNode(parent.TreeNode, quadTerrainProxy);

            // Assign tree node to proxy
            quadTerrainProxy.TreeNode = quadTerrainNode;

            return(quadTerrainProxy);
        }
示例#30
0
        public static bool CheckCacheFlag <T>()
            where T : class
        {
            bool result = false;

            EntityProxy <T> entityProxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            OrmTableAttribute ormTableAttribute =
                entityProxy.GetCustomerAttribute <OrmTableAttribute>();

            if (ormTableAttribute != null)
            {
                result = ormTableAttribute.CachedFlag;
            }

            return(result);
        }
示例#31
0
        public void Setup()
        {
            _entityStore = new EntityStore(new Mock <RomanticWeb.Updates.IDatasetChangesTracker>().Object);
            _mapping     = new Mock <IEntityMapping>(MockBehavior.Strict);
            _context     = new Mock <IEntityContext>(MockBehavior.Strict);
            _context.SetupGet(instance => instance.CurrentCulture).Returns(new CultureInfo("en"));
            _graphSelector = new Mock <INamedGraphSelector>();

            _context.Setup(c => c.Store).Returns(_entityStore);
            _context.Setup(c => c.InitializeEnitity(It.IsAny <IEntity>()));
            _graphSelector.Setup(g => g.SelectGraph(It.IsAny <EntityId>(), It.IsAny <IEntityMapping>(), It.IsAny <IPropertyMapping>()))
            .Returns(new Uri("urn:default:graph"));

            var entity = new Entity(_entityId, _context.Object);

            _entityProxy = new EntityProxy(entity, _mapping.Object, new TestTransformerCatalog(), _graphSelector.Object, null);
        }
示例#32
0
        /// <summary>
        /// 动态列
        /// </summary>
        public void Execute()
        {
            string excelPath = Directory.GetCurrentDirectory() + "\\..\\Template\\合同材料导入模版-配置化XML.xlsx";
            string path      = Directory.GetCurrentDirectory() + "\\..\\Template\\合同基本信息.xml";

            //代码注释
            //代码注释
            ImportByConfig <ExcelRowModel> import = new ImportByConfig <ExcelRowModel>(path, 1);

            import.Execute(excelPath);

            EntityProxy.GenerateProxy(import.ExcelGlobalDTO);

            //代码注释
            Export <ExcelRowModel> export = new Export <ExcelRowModel>();

            export.Execute(import.ExcelGlobalDTO);
        }