// Summary: // Get objects according to the specified object type // Remarks: // If there is only a DGObjects with the specified object type, // it will be returned directly. // // If there are multiple DGObjects with the specified object type, // then a new DGObjects is returned which will merged all the objects. // In this situation, the index of the DGObjects are lost. public async Task <DGObjectsCollection> getObjects(string objType) { DGObjectsCollection result = new DGObjectsCollection(); DGObjectRepository repository = DGObjectRepository.Instance( "SHML12", name, objType); List <DGObject> objList = await repository.GetAllAsync(); DGObjects objs = new DGObjects(); objs._objs = new Dictionary <string, DGObject>(); objs._id2Obj = new Dictionary <int, DGObject>(); foreach (DGObject obj in objList) { objs._id2Obj[obj.id] = obj; objs._objs[obj.name] = obj; } result.Add(objs); //IEnumerable<DGObjectsDefinition> defs = // objsDefinitions.Values.Where(x => x.Type == objType); //if (defs == null || defs.Count() == 0) // return null; //DGObjectsCollection result = new DGObjectsCollection(); //foreach (DGObjectsDefinition def in defs) //{ // if (objsContainer.ContainsKey(def.Name)) // { // DGObjects objs = objsContainer[def.Name]; // result.Add(objs); // } //} return(result); }
// Summary: // Get objects according to the specified object type // Remarks: // If there is only a DGObjects with the specified object type, // it will be returned directly. // // If there are multiple DGObjects with the specified object type, // then a new DGObjects is returned which will merged all the objects. // In this situation, the index of the DGObjects are lost. public DGObjectsCollection getObjects(string objType) { IEnumerable <DGObjectsDefinition> defs = objsDefinitions.Values.Where(x => x.Type == objType); if (defs == null || defs.Count() == 0) { return(null); } DGObjectsCollection result = new DGObjectsCollection(); foreach (DGObjectsDefinition def in defs) { if (objsContainer.ContainsKey(def.Name)) { DGObjects objs = objsContainer[def.Name]; result.Add(objs); } } return(result); }