Exemplo n.º 1
0
        public void Init()
        {
            TextAsset      jsonData    = ECSLocate.Factory.GetProduct <TextAsset>(FactoryType.Asset, null, ECSDefinitionPath.EntityJsonPath);
            EntityJsonList entityJsons = LitJson.JsonMapper.ToObject <EntityJsonList>(jsonData.text);

            SetEntityConf(entityJsons);
            RegAllSensor();
        }
Exemplo n.º 2
0
        public static void OpenWindow()
        {
            EntityConfigEditorWindow window = GetWindow <EntityConfigEditorWindow>("实体编辑器");

            window.minSize = new Vector2(800, 600);

            if (EDTool.CheckFileInPath(Application.dataPath + EntityJsonPath))
            {
                string dataJson = EDTool.ReadText(Application.dataPath + EntityJsonPath);
                MEntityJsonList = LitJson.JsonMapper.ToObject <EntityJsonList>(dataJson);
            }
        }
Exemplo n.º 3
0
        private static object ConvertOutputComponent(object value)
        {
            //服务的输出属性如果类型是一个实体或者实体列表,则需要进行格式转换。
            if (value is IDomainComponent)
            {
                var model = (value as IDomainComponent).GetRepository().EntityType;

                //TODO:这里可能存在问题:当一个非默认的视图请求这个服务得到一个默认视图的实体数据时,可能会因为列不一致而出现问题。
                var defaultVM = UIModel.Views.CreateBaseView(model);

                if (value is EntityList)
                {
                    var listRes = new EntityJsonList {
                        model = model
                    };

                    EntityJsonConverter.EntityToJson(defaultVM, value as EntityList, listRes.entities);
                    listRes.total = listRes.entities.Count;

                    value = listRes;
                }
                else if (value is Entity)
                {
                    var entityJson = new EntityJson();
                    EntityJsonConverter.EntityToJson(defaultVM, value as Entity, entityJson);

                    //在纯数据的基础上添加以下两个约定的属性:标记这是一个实体以及它在客户端的类型名称。
                    entityJson.SetProperty(Consts.isEntityProperty, BooleanBoxes.True);
                    entityJson.SetProperty(Consts.modelProperty, ClientEntities.GetClientName(model));

                    value = entityJson;
                }
                else
                {
                    throw new NotSupportedException("只支持对实体、实体列表进行格式转换。");
                }
            }

            return(value);
        }
Exemplo n.º 4
0
 private void SetEntityConf(EntityJsonList json)
 {
     entityJsons = json;
 }
Exemplo n.º 5
0
        private JsonModel QueryEntityList(HttpRequest request, EntityViewMeta evm)
        {
            var repo = RF.Find(evm.EntityType);

            var pagingInfo = ParsePagingInfo(request, repo);

            var entities = QueryEntityListCore(request, repo, pagingInfo);

            var list = new EntityJsonList {
                model = evm.EntityType
            };

            if (repo.SupportTree)
            {
                var roots = entities;
                foreach (var rootItem in roots)
                {
                    var i = ConvertRecur(rootItem, evm);
                    i.expanded = true;
                    list.entities.Add(i);
                }

                list.total = (entities as ITreeComponent).CountNodes();
            }
            else
            {
                //如果此时,还需要进行统计,表示在数据层查询时,并没有对分页进行处理。这时,只能在内存中对实体进行分页。
                if (pagingInfo.IsNeedCount)
                {
                    entities = JumpToPageInMemory(repo, entities, pagingInfo);
                }

                EntityJsonConverter.EntityToJson(evm, entities, list.entities);

                list.total = pagingInfo.TotalCount;
            }

            return(list);

            #region //暂时不用

            //var repo = RF.Create(evm.EntityType);

            //EntityList entities = QueryEntityListCore(request, repo);

            //if (repo.SupportTree)
            //{
            //    entities.EnsureObjectRelations();

            //    var root = new RootTreeEntityJson();

            //    var roots = entities.FindRoots();
            //    foreach (var rootItem in roots)
            //    {
            //        var i = ConvertRecur(rootItem, evm);
            //        root.children.Add(i);
            //    }

            //    return root;
            //}
            //else
            //{
            //    var page = request.GetQueryStringOrDefault("page", 1);
            //    var limit = request.GetQueryStringOrDefault("limit", 10);
            //    var pagerInfo = new PagerInfo(page, limit, true);
            //    entities = JumpToPage(repo, entities, pagerInfo);

            //    var list = new EntityJsonList
            //    {
            //        totalCount = pagerInfo.TotalCount,
            //    };

            //    EntityJsonConverter.EntityToJson(evm, entities, list.entities);

            //    return list;
            //}

            #endregion
        }