// 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); }
public static DGObjectRepository Instance(string prjID, string domainType, string dgobjectName) { if (_DGObjectsRepository == null) { _DGObjectsRepository = new DGObjectRepository(); } _DGObjectsRepository.projectID = prjID; _DGObjectsRepository.domainType = domainType; _DGObjectsRepository.dgobjectName = dgobjectName; return(_DGObjectsRepository); }