@@ -54,74 +54,5 @@ public static Variation GetVariationByKey(this IExperimentCore experimentCore, s
5454
5555 return experimentCore . Variations . FirstOrDefault ( v => v . Key == key ) ;
5656 }
57-
58- /// <summary>
59- /// Replace audience IDs with audience names in a condition string
60- /// </summary>
61- /// <param name="experimentCore">The experiment or holdout instance</param>
62- /// <param name="conditionString">String containing audience conditions</param>
63- /// <param name="audiencesMap">Map of audience ID to audience name</param>
64- /// <returns>String with audience IDs replaced by names</returns>
65- public static string ReplaceAudienceIdsWithNames ( this IExperimentCore experimentCore ,
66- string conditionString , System . Collections . Generic . Dictionary < string , string > audiencesMap )
67- {
68- if ( string . IsNullOrEmpty ( conditionString ) || audiencesMap == null )
69- {
70- return conditionString ?? string . Empty ;
71- }
72-
73- const string beginWord = "AUDIENCE(" ;
74- const string endWord = ")" ;
75- var keyIdx = 0 ;
76- var audienceId = string . Empty ;
77- var collect = false ;
78- var replaced = string . Empty ;
79-
80- foreach ( var ch in conditionString )
81- {
82- // Extract audience id in parenthesis (example: AUDIENCE("35") => "35")
83- if ( collect )
84- {
85- if ( ch . ToString ( ) == endWord )
86- {
87- // Output the extracted audienceId
88- var audienceName = audiencesMap . ContainsKey ( audienceId ) ? audiencesMap [ audienceId ] : audienceId ;
89- replaced += $ "\" { audienceName } \" ";
90- collect = false ;
91- audienceId = string . Empty ;
92- }
93- else
94- {
95- audienceId += ch ;
96- }
97- continue ;
98- }
99-
100- // Walk-through until finding a matching keyword "AUDIENCE("
101- if ( ch == beginWord [ keyIdx ] )
102- {
103- keyIdx ++ ;
104- if ( keyIdx == beginWord . Length )
105- {
106- keyIdx = 0 ;
107- collect = true ;
108- }
109- continue ;
110- }
111- else
112- {
113- if ( keyIdx > 0 )
114- {
115- replaced += beginWord . Substring ( 0 , keyIdx ) ;
116- }
117- keyIdx = 0 ;
118- }
119-
120- // Pass through other characters
121- replaced += ch ;
122- }
123-
124- return replaced ;
125- }
12657 }
12758}
0 commit comments