public static void ModifiedClone_Collection_ShouldNotBeEqual() { var original = new CollectionObject { IntCollection = new List <int> { 1, 2, 3, 4 }, ObjectCollection = new List <BasicObject> { new BasicObject { BoolValue = true, ByteValue = 0x10, }, new BasicObject { BoolValue = false, ByteValue = 0x20, }, } }; CollectionObject cloned = original.Clone(); cloned.ObjectCollection.Skip(1).First().BoolValue = true; cloned.ShouldNotBe(original); }
public BehaviourReturnCode ActionSetTargetCollection() { if (RunningProperty.SelfActor == null) { return(BehaviourReturnCode.Success); } // 副本是否配置自动采集 if (DBInstanceTypeControl.Instance.AutoCollect(InstanceManager.Instance.InstanceType, InstanceManager.Instance.InstanceSubType) == false) { RunningProperty.TargetCollectionId = 0; return(BehaviourReturnCode.Success); } if (CollectionObjectManager.Instance.Enable == false) { RunningProperty.TargetCollectionId = 0; return(BehaviourReturnCode.Success); } if (RunningProperty.TargetCollectionId > 0) { return(BehaviourReturnCode.Success); } CollectionObject targetCollection = AIHelper.GetNearstAutoCollectableCollectionObject(RunningProperty); if (targetCollection != null) { RunningProperty.TargetCollectionId = targetCollection.Id; return(BehaviourReturnCode.Success); } return(BehaviourReturnCode.Success); }
public static void Should_Clone_CollectionObject() { var original = new CollectionObject { IntCollection = new List <int> { 1, 2, 3, 4 }, ObjectCollection = new List <BasicObject> { new BasicObject { BoolValue = true, ByteValue = 0x10, }, new BasicObject { BoolValue = false, ByteValue = 0x20, }, } }; CollectionObject cloned = original.Clone(); cloned.ShouldBe(original); }
public void TestCollectionUpdate() { var so1 = new SimpleObject { ValueOne = 1, ValueTwo = 2 }; var so2 = new SimpleObject { ValueOne = 3, ValueTwo = 4 }; var co = new CollectionObject(); co.CollectionOne.Add(so1); var clone = (CollectionObject)CopyUtils.CloneObjectTest(co); clone.CollectionOne.Add(so2); Assert.AreNotSame(co, clone); Assert.AreSame(co.GetType(), clone.GetType()); Assert.AreNotSame(co.CollectionOne, clone.CollectionOne); Assert.AreNotEqual(co.CollectionOne.Count, clone.CollectionOne.Count); CopyUtils.UpdateFromClone(co, clone); Assert.AreNotSame(co, clone); Assert.AreSame(co.GetType(), clone.GetType()); Assert.AreNotSame(co.CollectionOne, clone.CollectionOne); Assert.AreEqual(co.CollectionOne.Count, clone.CollectionOne.Count); Assert.AreSame(co.CollectionOne.First(), clone.CollectionOne.First()); Assert.AreSame(co.CollectionOne.ElementAt(1), clone.CollectionOne.ElementAt(1)); }
public void Should_Clone_CollectionObject() { var original = new CollectionObject { IntCollection = new List <int> { 1, 2, 3, 4 }, ObjectCollection = new List <BasicObject> { new BasicObject { BoolValue = true, ByteValue = 0x10, }, new BasicObject { BoolValue = false, ByteValue = 0x20, }, } }; var cloned = original.Clone(); Assert.AreEqual(original, cloned); }
/// <summary> /// 找最近的可以自动采集的采集物 /// </summary> /// <param name="runningProperty"></param> /// <returns></returns> public static CollectionObject GetNearstAutoCollectableCollectionObject(AIRunningProperty runningProperty) { if (runningProperty == null) { return(null); } float shortest = float.MaxValue; Vector3 selfActorPos = runningProperty.SelfActorPos; CollectionObject retCollectionObject = null; Dictionary <int, CollectionObject> collectionObjects = xc.Dungeon.CollectionObjectManager.Instance.CollectionObjects; foreach (CollectionObject collectionObject in collectionObjects.Values) { if (collectionObject == null || collectionObject.BindGameObject == null || collectionObject.BindGameObject.transform == null) { continue; } CollectionObjectBehaviour collectionObjectBehaviour = collectionObject.BindGameObject.GetComponent <CollectionObjectBehaviour>(); if (collectionObjectBehaviour == null) { continue; } // 婚宴食物是否能采集 if (collectionObjectBehaviour.Class == "wedding_foods" && MarryManager.Instance.WeddingFoodsCanBeCollected == false) { continue; } // 婚宴宝箱是否能采集 if (collectionObjectBehaviour.Class == "wedding_bos" && MarryManager.Instance.WeddingBoxCanBeCollected == false) { continue; } Vector3 pos = collectionObject.BindGameObject.transform.position; if (!TargetPositionHeightIsAbnormal(pos)) { continue; } if (!InstanceHelper.CanWalkTo(pos)) { continue; } float distanceSquare = AIHelper.DistanceSquare(selfActorPos, pos); if (distanceSquare < shortest) { shortest = distanceSquare; retCollectionObject = collectionObject; } } return(retCollectionObject); }
public static string ToCsv(this CollectionObject list) { if (list?.items == null || list.items.Count == 0) { return(null); } // todo: make sure to include links return(string.Join(',', list.items.Select(i => i.PublicId.ToString().Replace(",", ",,")))); }
public void TestCollectionClone() { var so = new SimpleObject {ValueOne = 1, ValueTwo = 2}; var co = new CollectionObject(); co.CollectionOne.Add(so); var clone = (CollectionObject) CopyUtils.CloneObjectTest(co); Assert.AreNotSame(co, clone); Assert.AreSame(co.GetType(), clone.GetType()); Assert.AreNotSame(co.CollectionOne, clone.CollectionOne); Assert.AreSame(co.CollectionOne.First(), clone.CollectionOne.First()); }
public void CallCountWithQueryCriteria() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction countmth = (IFunction)collobj.GetMember("count"); var result = countmth.Apply(new object[] { new DynamicObject("Age", 700) }); Assert.IsNotNull(result); Assert.AreEqual(1, result); }
public void CallCount() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction countmth = (IFunction)collobj.GetMember("count"); var result = countmth.Apply(new object[] { }); Assert.IsNotNull(result); Assert.AreEqual(4, result); }
public void CallFind() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction findmth = (IFunction)collobj.GetMember("find"); var result = findmth.Apply(new object[] { }); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <DynamicDocument>)); Assert.AreEqual(4, ((IEnumerable <DynamicDocument>)result).Count()); }
public void CallRemoveFirst() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction removemth = (IFunction)collobj.GetMember("remove"); removemth.Apply(new object[] { null, true }); var result = collection.Find(); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count()); }
public void CallFind() { Collection collection = new Collection("people"); CollectionObject collobj = new CollectionObject(collection); Context context = new Context(); context.SetMember("people", collobj); CallExpression expression = new CallExpression(new DotExpression(new NameExpression("people"), "find"), new IExpression[] { }); var result = expression.Evaluate(context); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <DynamicDocument>)); }
private async Task SerializeCollection(CollectionObject collection, Stream dest, CustomJsonSerializer serializer) { if (collection.IsBaseObjectDefined) { await SerializeObject(collection, dest); } else if (collection.items != null) { await SerializeArray(collection.items, dest); } else { await SerializeNull(dest); } }
public void CallUpdateWithMulti() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction updatemth = (IFunction)collobj.GetMember("update"); updatemth.Apply(new object[] { new DynamicObject("Age", 700), new DynamicObject("Name", "New Eve", "Age", 700), true }); var result = collection.Find(new DynamicObject("Age", 700)).FirstOrDefault(); Assert.IsNotNull(result); Assert.AreEqual(700, result.GetMember("Age")); Assert.AreEqual("New Eve", result.GetMember("Name")); }
public void TestCollectionClone() { var so = new SimpleObject { ValueOne = 1, ValueTwo = 2 }; var co = new CollectionObject(); co.CollectionOne.Add(so); var clone = (CollectionObject)CopyUtils.CloneObjectTest(co); Assert.AreNotSame(co, clone); Assert.AreSame(co.GetType(), clone.GetType()); Assert.AreNotSame(co.CollectionOne, clone.CollectionOne); Assert.AreSame(co.CollectionOne.First(), clone.CollectionOne.First()); }
public void CallFindOneWithQuery() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction findonemth = (IFunction)collobj.GetMember("findOne"); var result = findonemth.Apply(new object[] { new DynamicObject("Age", 800) }); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(DynamicDocument)); var document = (DynamicDocument)result; Assert.AreEqual(800, document.GetMember("Age")); }
public void CallRemoveOne() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction removemth = (IFunction)collobj.GetMember("remove"); removemth.Apply(new object[] { new DynamicObject("Age", 700) }); var result = collection.Find(); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count()); Assert.IsTrue(result.All(d => !d.GetMember("Age").Equals(700))); }
public void CallSaveExistingDocument() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction savemth = (IFunction)collobj.GetMember("save"); savemth.Apply(new object[] { new DynamicObject("Id", this.adam.Id, "Name", "Adam", "Age", 300) }); var result = collection.Find(new DynamicObject("Name", "Adam")).FirstOrDefault(); Assert.IsNotNull(result); Assert.AreEqual("Adam", result.GetMember("Name")); Assert.AreEqual(300, result.GetMember("Age")); Assert.AreEqual(this.adam.Id, result.Id); }
public void CallFindWithQuery() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction findmth = (IFunction)collobj.GetMember("find"); var result = findmth.Apply(new object[] { new DynamicObject("Age", 800) }); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <DynamicDocument>)); Assert.AreEqual(1, ((IEnumerable <DynamicDocument>)result).Count()); var document = ((IEnumerable <DynamicDocument>)result).First(); Assert.AreEqual(800, document.GetMember("Age")); }
public void CallUpdateAllWithMulti() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction updatemth = (IFunction)collobj.GetMember("update"); updatemth.Apply(new object[] { null, new DynamicObject("Kind", "Human"), true }); var result = collection.Find(); Assert.IsNotNull(result); Assert.AreEqual(4, result.Count()); Assert.IsTrue(result.All(d => d.GetMemberNames().Contains("Kind"))); Assert.IsTrue(result.All(d => d.GetMember("Kind").Equals("Human"))); }
public void Deserialize_HugeCollection_UsesGZip() { var source = new CollectionObject { RandomObject1CollectionProperty = FixtureUtils.Array(1000, 1000, () => new RandomObject1 { StringProperty = FixtureUtils.String() }).ToList() }; var serialized = AzureTableSerializer.Serialize(source); var deserialized = AzureTableSerializer.Deserialize <CollectionObject>(Entity(serialized)); serialized.Keys.Any(k => k.Contains("GZip", StringComparison.Ordinal)).Should().BeTrue(); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public BehaviourReturnCode ActionWalkToTargetCollection() { if (RunningProperty.AI.Machine.CurrentStateType == BehaviourMachine.State.WALK) { return(BehaviourReturnCode.Failure); } CollectionObject collectionObject = CollectionObjectManager.Instance.GetCollectionObject(RunningProperty.TargetCollectionId); if (collectionObject == null || collectionObject.BindGameObject == null || collectionObject.BindGameObject.transform == null) { RunningProperty.TargetCollectionId = 0; return(BehaviourReturnCode.Success); } CollectionObjectBehaviour collectionObjectBehaviour = collectionObject.BindGameObject.GetComponent <CollectionObjectBehaviour>(); if (collectionObjectBehaviour == null) { RunningProperty.TargetCollectionId = 0; return(BehaviourReturnCode.Success); } Vector3 pos = collectionObject.BindGameObject.transform.position; if (AIHelper.RoughlyEqual(pos, RunningProperty.SelfActorPos) || collectionObjectBehaviour.IsTouching == true) { RunningProperty.TargetCollectionId = 0; RunningProperty.AI.PathWalker.IsWalkingToCollectionPos = false; RunningProperty.AI.Machine.SwitchToState(BehaviourMachine.State.EMPTY); // 已经在采集物范围内,马上开始采集 collectionObjectBehaviour.StartInteract(); return(BehaviourReturnCode.Success); } RunningProperty.TargetActor = null; RunningProperty.AI.PathWalker.WalkTo(pos); RunningProperty.AI.PathWalker.IsWalkingToCollectionPos = true; RunningProperty.AI.Machine.SwitchToState(BehaviourMachine.State.WALK); // 设置IsClickedTouch为true,走到采集物范围内就可以开始采集了 collectionObjectBehaviour.IsClickedTouch = true; return(BehaviourReturnCode.Failure); }
private async Task BindSqlActorCollection(CollectionObject collection, ActivityDeliveryContext ctx) { if (collection?.items != null) { var nonActors = collection.items.Except(collection.items.OfType <ActorObject>()).ToList(); foreach (var actor in nonActors) { var actor2 = await _contentRepository.Get(actor.PublicId, new PublicId(ctx.Filter.viewerId, 0)); collection.items[collection.items.IndexOf(actor)] = actor2; } foreach (var actor in collection.items.Where(a => a != null).OfType <ActorObject>()) { await BindSqlActor(ctx, actor); } } }
public void CallFindOneWithProjection() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction findonemth = (IFunction)collobj.GetMember("findOne"); var result = findonemth.Apply(new object[] { null, new DynamicObject("Age", 1) }); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(DynamicDocument)); var document = (DynamicDocument)result; Assert.IsNotNull(document.GetMember("Age")); Assert.IsNotNull(document.GetMember("Id")); Assert.IsNull(document.GetMember("Name")); Assert.AreEqual(2, document.GetMemberNames().Count()); }
public async Task SyncProfiles(long authId, CollectionObject profiles) { if (profiles == null || profiles.totalItems == 0) { Console.WriteLine($"No profiles to sync for {authId}"); return; } var client = GetClient(); foreach (var profile in profiles.items) { if (profile == null) { continue; } await SyncProfile(client, authId, profile); } }
public async Task SyncArchivedMedias(long peerId, CollectionObject items) { if (items == null || items.totalItems == 0) { Console.WriteLine($"No archived media to sync for {peerId}"); return; } var client = GetClient(); foreach (var item in items.items) { if (item == null) { continue; } await SyncArchivedMedia(client, peerId, item); } }
public void CallInsertObject() { Collection collection = new Collection("people"); CollectionObject collobj = new CollectionObject(collection); IFunction insertmth = (IFunction)collobj.GetMember("insert"); insertmth.Apply(new object[] { new DynamicObject("Name", "Adam", "Age", 800) }); var result = collection.Find(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); var document = result.First(); Assert.AreEqual("Adam", document.GetMember("Name")); Assert.AreEqual(800, document.GetMember("Age")); Assert.IsNotNull(document.Id); Assert.AreEqual(3, document.GetMemberNames().Count()); }
public void CallFindWithProjection() { Collection collection = this.GetCollection(); CollectionObject collobj = new CollectionObject(collection); IFunction findmth = (IFunction)collobj.GetMember("find"); var result = findmth.Apply(new object[] { null, new DynamicObject("Age", 1) }); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <DynamicDocument>)); var documents = (IEnumerable <DynamicDocument>)result; Assert.AreEqual(4, documents.Count()); Assert.IsTrue(documents.All(d => d.GetMember("Age") != null)); Assert.IsTrue(documents.All(d => d.GetMember("Id") != null)); Assert.IsTrue(documents.All(d => d.GetMember("Name") == null)); Assert.IsTrue(documents.All(d => d.GetMemberNames().Count() == 2)); }
private void Initialize() { this.Header.Data = this.CreateHeader(); this._itemsWithHeaderAndFooter.Merge((INotifyCollectionChanged)this._coHeader.Coll); if (!this.IsHorizontal) { if (!this.IsVerticalCompact) { foreach (VideoCatalogItem videoCatalogItem in this._videoCategory.items.Take <VideoCatalogItem>(3)) { this._catalogItems.Add(this.CreateCatalogItemViewModel(videoCatalogItem)); } this._itemsWithHeaderAndFooter.Merge((INotifyCollectionChanged)this._catalogItems); } else { foreach (IEnumerable <VideoCatalogItem> source in this._videoCategory.items.Take <VideoCatalogItem>(6).Partition <VideoCatalogItem>(2)) { CatalogItemTwoInARowViewModel twoInArowViewModel = new CatalogItemTwoInARowViewModel(); twoInArowViewModel.Item1 = this.CreateCatalogItemViewModel(source.First <VideoCatalogItem>()); if (source.Count <VideoCatalogItem>() > 1) { twoInArowViewModel.Item2 = this.CreateCatalogItemViewModel(source.Skip <VideoCatalogItem>(1).First <VideoCatalogItem>()); } this._catalogItemsTwoInARow.Add(twoInArowViewModel); } this._itemsWithHeaderAndFooter.Merge((INotifyCollectionChanged)this._catalogItemsTwoInARow); } this._itemsWithHeaderAndFooter.Merge((INotifyCollectionChanged)CollectionObject <DividerSpaceDownViewModel> .CreateCollectionObject <DividerSpaceDownViewModel>(new DividerSpaceDownViewModel()).Coll); } else { this.CatalogItemsHorizontalVM.Data = new CatalogItemsHorizontalViewModel(this._videoCategory, this._knownUsers, this._knownGroups); this._itemsWithHeaderAndFooter.Merge((INotifyCollectionChanged)this.CatalogItemsHorizontalVM.Coll); } this.Footer.Data = this.CreateFooter(); this._itemsWithHeaderAndFooter.Merge((INotifyCollectionChanged)this._coFooter.Coll); }
public void TestCollectionUpdate() { var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2}; var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4}; var co = new CollectionObject(); co.CollectionOne.Add(so1); var clone = (CollectionObject) CopyUtils.CloneObjectTest(co); clone.CollectionOne.Add(so2); Assert.AreNotSame(co, clone); Assert.AreSame(co.GetType(), clone.GetType()); Assert.AreNotSame(co.CollectionOne, clone.CollectionOne); Assert.AreNotEqual(co.CollectionOne.Count(), clone.CollectionOne.Count()); CopyUtils.UpdateFromClone(co, clone); Assert.AreNotSame(co, clone); Assert.AreSame(co.GetType(), clone.GetType()); Assert.AreNotSame(co.CollectionOne, clone.CollectionOne); Assert.AreEqual(co.CollectionOne.Count(), clone.CollectionOne.Count()); Assert.AreSame(co.CollectionOne.First(), clone.CollectionOne.First()); Assert.AreSame(co.CollectionOne.ElementAt(1), clone.CollectionOne.ElementAt(1)); }
public void GetData(GenericCollectionViewModel <VKList <VKClient.Common.Backend.DataObjects.Video>, VideoHeader> caller, int offset, int count, Action <BackendResult <VKList <VKClient.Common.Backend.DataObjects.Video>, ResultCode> > callback) { if (caller.Refresh && !this._switchingAlbums) { this._loadedBaseInfo = false; } if (!this._loadedBaseInfo) { VideoService.Instance.GetVideoDataExt(this._ownerId, (Action <BackendResult <GetVideosDataExtResponse, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() => { VKList <VKClient.Common.Backend.DataObjects.Video> resultData = (VKList <VKClient.Common.Backend.DataObjects.Video>)null; if (res.ResultCode == ResultCode.Succeeded) { resultData = this._albumId == VideoAlbum.ADDED_ALBUM_ID ? res.ResultData.AddedVideos : res.ResultData.UploadedVideos; this._headerCollObj.Data = (OwnerHeaderWithSubscribeViewModel)null; this._albumsHeaderCollObj.Data = (SectionHeaderViewModel)null; this._albumsCollObj.Data = (AlbumsListHorizontalViewModel)null; this._videosHeaderCollObj.Data = (SectionHeaderViewModel)null; OwnerHeaderWithSubscribeViewModel subscribeViewModel = new OwnerHeaderWithSubscribeViewModel(res.ResultData.Group); this.CanUploadVideo = res.ResultData.Group != null && res.ResultData.Group.can_upload_video == 1; this._headerCollObj.Data = subscribeViewModel; if (res.ResultData.Albums.items.Count > 0) { this._albumsHeaderCollObj.Data = new SectionHeaderViewModel() { Count = res.ResultData.Albums.count, Title = CommonResources.VideoCatalog_Albums, ShowAllVisibility = Visibility.Visible, ShowOptionsVisibility = Visibility.Collapsed, OnHeaderTap = (Action)(() => Navigator.Current.NavigateToVideoAlbumsList(this._ownerId, this.CanUploadVideo)) }; this._albumsCollObj.Data = new AlbumsListHorizontalViewModel(this._ownerId, res.ResultData.Albums, new List <User>(), new List <Group>()); } CollectionObject <SectionHeaderViewModel> videosHeaderCollObj = this._videosHeaderCollObj; SectionHeaderViewModel sectionHeaderViewModel = new SectionHeaderViewModel(); sectionHeaderViewModel.Title = CommonResources.Profile_Videos; int count1 = resultData.count; sectionHeaderViewModel.Count = count1; int num1 = 1; sectionHeaderViewModel.ShowAllVisibility = (Visibility)num1; int num2 = 0; sectionHeaderViewModel.ShowOptionsVisibility = (Visibility)num2; sectionHeaderViewModel.HeaderOptions = new List <HeaderOption>() { new HeaderOption() { ID = VideoAlbum.ADDED_ALBUM_ID, Name = CommonResources.VideoCatalog_Added }, new HeaderOption() { ID = VideoAlbum.UPLOADED_ALBUM_ID, Name = CommonResources.VideoCatalog_Uploaded } }; videosHeaderCollObj.Data = sectionHeaderViewModel; this._videosHeaderCollObj.Data.PropertyChanged += new PropertyChangedEventHandler(this.VideosHeader_Data_PropertyChanged); this._videosHeaderCollObj.Data.SelectedOption = this._videosHeaderCollObj.Data.HeaderOptions.First <HeaderOption>((Func <HeaderOption, bool>)(ho => ho.ID == this._albumId)); this._loadedBaseInfo = true; } callback(new BackendResult <VKList <VKClient.Common.Backend.DataObjects.Video>, ResultCode>(res.ResultCode, resultData)); })))); } else { VideoService.Instance.GetVideos(Math.Abs(this._ownerId), this._ownerId < 0, offset, count, (Action <BackendResult <VKList <VKClient.Common.Backend.DataObjects.Video>, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { this._videosHeaderCollObj.Data.Count = res.ResultData.count; } callback(res); }), this._albumId, true); } }
private static bool ParseNestedObject( List<AnnotationToken> tokenList, ref int nextToken, ref NestedObject result, ref int fareastError) { int currentToken = nextToken; string tokenStr = null; if (ReadToken(tokenList, AnnotationTokenType.LeftBrace, ref currentToken, ref tokenStr, ref fareastError)) { string fieldName = null; NestedObject fieldValue = null; CollectionObject collectionObj = new CollectionObject() { Collection = new Dictionary<string, NestedObject>() }; // Field Name can be a NameToken or a DoubleQuotedString if ((ReadToken(tokenList, AnnotationTokenType.DoubleQuotedString, ref currentToken, ref fieldName, ref fareastError) || ReadToken(tokenList, AnnotationTokenType.NameToken, ref currentToken, ref fieldName, ref fareastError)) && ReadToken(tokenList, AnnotationTokenType.Colon, ref currentToken, ref tokenStr, ref fareastError) && ParseNestedObject(tokenList, ref currentToken, ref fieldValue, ref fareastError)) { collectionObj.Collection[fieldName.ToLower()] = fieldValue; } else { return false; } while (ReadToken(tokenList, AnnotationTokenType.Comma, ref currentToken, ref tokenStr, ref fareastError) && (ReadToken(tokenList, AnnotationTokenType.DoubleQuotedString, ref currentToken, ref fieldName, ref fareastError) || ReadToken(tokenList, AnnotationTokenType.NameToken, ref currentToken, ref fieldName, ref fareastError)) && ReadToken(tokenList, AnnotationTokenType.Colon, ref currentToken, ref tokenStr, ref fareastError) && ParseNestedObject(tokenList, ref currentToken, ref fieldValue, ref fareastError)) { collectionObj.Collection[fieldName.ToLower()] = fieldValue; } if (!ReadToken(tokenList, AnnotationTokenType.RightBrace, ref currentToken, ref tokenStr, ref fareastError)) { return false; } result = collectionObj; nextToken = currentToken; return true; } else if (ReadToken(tokenList, AnnotationTokenType.DoubleQuotedString, ref currentToken, ref tokenStr, ref fareastError)) { StringObject stringObj = new StringObject() { Value = tokenStr }; result = stringObj; nextToken = currentToken; return true; } else { return false; } }