public static Expression RestoreSnapshot(KeyValuePair<string, List<Type>>[] SnapshotData)
 {
     if (SnapshotData.SequenceEqual(CurrentScope.OnDateType)) return null;
     var Ret = Expression.Block(
         SnapshotData.Except(CurrentScope.OnDateType)
         .SelectMany(x => x.Value.Select(y => CurrentScope.GetVarCached(x.Key, y)))
     );
     SnapshotData = null;
     return Ret;
 }
Example #2
0
        private static void WriteConstants(StringBuilder outputString, HashSet<string> usedConstants, ref KeyValuePair<string,string>[] remainingConstants, string prefix, string constantsName = null, Func<string, bool> additionalAcceptanceConstantFilter = null, Func<string, bool> additionalRejectConstantFilter = null)
        {
            if (string.IsNullOrEmpty(constantsName))
                constantsName = FormatEnumName(prefix, "");

            var constants = remainingConstants.Where(k => (k.Key.StartsWith(prefix) || (additionalAcceptanceConstantFilter != null && additionalAcceptanceConstantFilter(k.Key))) && (additionalRejectConstantFilter == null || additionalRejectConstantFilter(k.Key))).ToArray();
            remainingConstants = remainingConstants.Except(constants).ToArray();

            outputString.AppendLine("    enum " + constantsName);
            outputString.AppendLine("    {");
            foreach (var c in constants)
            {
                string cname = FormatEnumName(c.Key, prefix);

                while (usedConstants.Contains(cname))
                    cname += "_";
                usedConstants.Add(cname);

                outputString.AppendFormat("        {0} = {1},", cname, c.Value);
                outputString.AppendLine();
            }

            outputString.AppendLine("    };");
        }