public List ScrubObjectList()

in CosmosClone/CosmosCloneCommon/Utility/ObjectScrubber.cs [14:85]


        public List<JToken> ScrubObjectList(List<string> srcList, ScrubRule scrubRule)
        {
            //var scrubbedObjects = new List<string>();
            var scrubbedObjects = new List<JToken>();
            var propNames = scrubRule.PropertyName.Split('.').ToList();
            if(scrubRule.Type == RuleType.NullValue || scrubRule.Type == RuleType.SingleValue || scrubRule.Type == RuleType.PartialMaskFromLeft || scrubRule.Type == RuleType.PartialMaskFromRight)
            {
                foreach (var strObj in srcList)
                {
                    try
                    {
                        JToken jToken = GetUpdatedJsonArrayValue((JToken)JObject.Parse(strObj), propNames, scrubRule.UpdateValue, scrubRule.Type);
                        scrubbedObjects.Add(jToken);
                    }
                    catch(Exception ex)
                    {
                        CloneLogger.LogInfo("Log failed");
                        CloneLogger.LogError(ex);
                        throw ;
                    }
                   
                }
            }
            else if(scrubRule.Type == RuleType.Shuffle)
            {
                //get all similar values
                var propertyValues = new List<JToken>();
                foreach (var strObj in srcList)
                {
                    try
                    {
                        List<JToken> jTokenList = new List<JToken>();
                        GetPropertyValues((JToken)JObject.Parse(strObj), propNames, ref jTokenList);
                        propertyValues.AddRange(jTokenList);
                    }
                    catch (Exception ex)
                    {
                        CloneLogger.LogInfo("Log failed");
                        CloneLogger.LogError(ex);
                        throw ;
                    }
                   
                }
                
                var shuffledTokens = RandomNumberGenerator.Shuffle(propertyValues);
                var shuffledTokenQ = new Queue<JToken>(shuffledTokens);

                foreach (var strObj in srcList)
                {
                    try
                    {
                        JToken jToken = GetDocumentShuffledToken((JToken)JObject.Parse(strObj), propNames, ref shuffledTokenQ);
                        scrubbedObjects.Add(jToken);
                    }
                    catch (Exception ex)
                    {
                        CloneLogger.LogInfo("Log failed");
                        CloneLogger.LogError(ex);
                        throw ;
                    }
                }
            }
            else
            {
                foreach (var strObj in srcList)
                {
                    scrubbedObjects.Add((JToken)strObj);
                }
            }
            
            return scrubbedObjects;
        }