コード例 #1
0
 private void ExtractGlobalizationKeys(string compacted)
 {
     GlobalizedResourceHandler.ExtractGlobalizationKeys(compacted, this.GlobalizationKeys);
 }
コード例 #2
0
ファイル: JbstCodeProvider.cs プロジェクト: morganpage/JsonFx
        internal static void ExtractGlobalizationKeys(object root, List <string> globalizationKeys)
        {
            List <JbstControl> queue = new List <JbstControl>();

            queue.Add(root as JbstControl);

            while (queue.Count > 0)
            {
                // pop and cast
                JbstControl control = queue[0];
                queue.RemoveAt(0);
                if (control == null)
                {
                    continue;
                }

                // queue up children
                JbstContainerControl container = control as JbstContainerControl;
                if (container != null)
                {
                    if (container.ChildControlsSpecified)
                    {
                        queue.AddRange(container.ChildControls);
                    }
                    if (container.AttributesSpecified)
                    {
                        foreach (object value in container.Attributes.Values)
                        {
                            if (value is JbstControl)
                            {
                                queue.Add((JbstControl)value);
                            }
                        }
                    }
                    continue;
                }

                // parse expression blocks
                if (control is JbstExpressionBlock)
                {
                    GlobalizedResourceHandler.ExtractGlobalizationKeys(((JbstExpressionBlock)control).Code, globalizationKeys);
                    continue;
                }

                // parse statement blocks
                if (control is JbstStatementBlock)
                {
                    GlobalizedResourceHandler.ExtractGlobalizationKeys(((JbstStatementBlock)control).Code, globalizationKeys);
                    continue;
                }

                // look up declarative resource string expressions
                JbstExtensionBlock extension = control as JbstExtensionBlock;
                if (extension == null)
                {
                    continue;
                }

                ResourceJbstExtension res = extension.Extension as ResourceJbstExtension;
                if (res == null)
                {
                    continue;
                }

                string key = res.GlobalizationKey;
                if (!globalizationKeys.Contains(key))
                {
                    globalizationKeys.Add(key);
                }
            }
        }