private static GdbObjectReference GetOriginalGdbObjectReference( [NotNull] ResultObjectMsg resultObjectMsg) { Assert.ArgumentNotNull(nameof(resultObjectMsg)); // TODO: long int! int classHandle, objectId; if (resultObjectMsg.FeatureCase == ResultObjectMsg.FeatureOneofCase.Insert) { InsertedObjectMsg insert = Assert.NotNull(resultObjectMsg.Insert); GdbObjRefMsg originalObjRefMsg = insert.OriginalReference; classHandle = originalObjRefMsg.ClassHandle; objectId = originalObjRefMsg.ObjectId; } else { GdbObjectMsg updateMsg = Assert.NotNull(resultObjectMsg.Update); classHandle = updateMsg.ClassHandle; objectId = updateMsg.ObjectId; } return(new GdbObjectReference(classHandle, objectId)); }
private static IList <ResultObjectMsg> GetResultFeatureMessages( [CanBeNull] ICollection <KeyValuePair <IFeature, IList <IFeature> > > insertsByOriginal, [CanBeNull] IEnumerable <IFeature> allResultFeatures, [CanBeNull] Func <IFeature, IEnumerable <string> > notificationsForFeature = null, [CanBeNull] Func <IFeature, bool> warningForFeature = null) { IList <ResultObjectMsg> ResultObjectMsgs = new List <ResultObjectMsg>(); HashSet <IFeature> allInserts = new HashSet <IFeature>(); if (insertsByOriginal != null) { foreach (KeyValuePair <IFeature, IList <IFeature> > kvp in insertsByOriginal) { IList <IFeature> inserts = kvp.Value; IFeature original = kvp.Key; var originalRef = new GdbObjRefMsg { ClassHandle = original.Class.ObjectClassID, ObjectId = original.OID }; foreach (IFeature insert in inserts) { allInserts.Add(insert); var insertMsg = new InsertedObjectMsg { InsertedObject = ProtobufGdbUtils.ToGdbObjectMsg(insert), OriginalReference = originalRef }; var featureMsg = new ResultObjectMsg { Insert = insertMsg }; AddNotification(insert, featureMsg, notificationsForFeature, warningForFeature); ResultObjectMsgs.Add(featureMsg); } } } if (allResultFeatures != null) { foreach (IFeature resultFeature in allResultFeatures) { if (allInserts.Contains(resultFeature)) { continue; } ResultObjectMsg updateMsg = new ResultObjectMsg { Update = ProtobufGdbUtils.ToGdbObjectMsg(resultFeature) }; AddNotification(resultFeature, updateMsg, notificationsForFeature, warningForFeature); ResultObjectMsgs.Add(updateMsg); } } return(ResultObjectMsgs); }