コード例 #1
0
        private static void InitializeDecoders(ScanState scanState, double version)
        {
            decoders.Clear();
            var type  = typeof(INode);
            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(s => s.GetTypes())
                        .Where(p => p.IsClass && !p.IsAbstract && p.IsSubclassOf(typeof(AbstractNode)));

            foreach (var t in types)
            {
                INode n = (INode)Activator.CreateInstance(t);
                if (n.JsxbinVersion == ALL_VERSIONS || n.JsxbinVersion == version)
                {
                    decoders.Add(n.Marker, t);
                }
            }
            if (version == 1.0)
            {
                referenceDecoder = new ReferenceDecoderVersion1();
            }
            else
            {
                referenceDecoder = new ReferenceDecoderVersion2();
            }
        }
コード例 #2
0
        public char GetCurrentAndAdvanceCore(ScanState scanState)
        {
            char cur = scanState.getCur();

            scanState.Inc();
            return(cur);
        }
コード例 #3
0
 public static string Decode(string jsxbin, bool printStructure)
 {
     string normalized = jsxbin.Replace("\n", "").Replace("\r", "").Replace("\\", "");
     Match versionMatch = Regex.Match(normalized, "^@JSXBIN@ES@([\\d.]+)@");
     double version = ALL_VERSIONS;
     if (versionMatch.Success)
         version = double.Parse(versionMatch.Groups[1].Value, CultureInfo.InvariantCulture);
     string noheader = Regex.Replace(normalized, "^@JSXBIN@ES@[\\d.]+@", "");
     scanState = new ScanState(noheader);
     InitializeDecoders(scanState, version);
     var root = new RootNode();
     root.PrintStructure = printStructure;
     root.Decode();
     var jsx = root.PrettyPrint();
     return string.Join(Environment.NewLine, jsx);
 }
コード例 #4
0
        public static string Decode(string jsxbin, bool printStructure)
        {
            string normalized   = jsxbin.Replace("\n", "").Replace("\r", "").Replace("\\", "");
            Match  versionMatch = Regex.Match(normalized, "^@JSXBIN@ES@([\\d.]+)@");
            double version      = ALL_VERSIONS;

            if (versionMatch.Success)
            {
                version = double.Parse(versionMatch.Groups[1].Value);
            }
            string noheader = Regex.Replace(normalized, "^@JSXBIN@ES@[\\d.]+@", "");

            scanState = new ScanState(noheader);
            InitializeDecoders(scanState, version);
            var root = new RootNode();

            root.PrintStructure = printStructure;
            root.Decode();
            var jsx = root.PrettyPrint();

            return(string.Join(Environment.NewLine, jsx));
        }
コード例 #5
0
 public char GetCurrentAndAdvance(ScanState scanState)
 {
     return(GetCurrentAndAdvanceCore(scanState));
 }
コード例 #6
0
 private static void InitializeDecoders(ScanState scanState, double version)
 {
     decoders.Clear();
     var type = typeof(INode);
     var types = AppDomain.CurrentDomain.GetAssemblies()
         .SelectMany(s => s.GetTypes())
         .Where(p => p.IsClass && !p.IsAbstract && p.IsSubclassOf(typeof(AbstractNode)));
     foreach (var t in types)
     {
         INode n = (INode)Activator.CreateInstance(t);
         if (n.JsxbinVersion == ALL_VERSIONS || n.JsxbinVersion == version)
             decoders.Add(n.Marker, t);
     }
     if (version == 1.0)
         referenceDecoder = new ReferenceDecoderVersion1();
     else
         referenceDecoder = new ReferenceDecoderVersion2();                
 }
コード例 #7
0
 public char GetCurrentAndAdvanceCore(ScanState scanState)
 {
     char cur = scanState.getCur();
     scanState.Inc();
     return cur;
 }
コード例 #8
0
 public char GetCurrentAndAdvance(ScanState scanState)
 {
     return GetCurrentAndAdvanceCore(scanState);
 }