/// <summary>
        ///
        /// </summary>
        /// <param name="glNode"></param>
        /// <returns></returns>
        protected override GLSnippet FindSnippet(GLNode glNode)
        {
            Type      nodeType = glNode.SelfTypeCache;
            GLSnippet snippet  = null;

            dictionary.TryGetValue(nodeType, out snippet);

            return(snippet);
        }
Beispiel #2
0
        /// <summary>
        /// Find the wanted <see cref="GLSnippet"/> according to specified <paramref name="glNode"/>.
        /// </summary>
        /// <param name="glNode"></param>
        /// <returns></returns>
        protected GLSnippet Find(GLNode glNode)
        {
            Type      nodeType = glNode.GetType();
            GLSnippet snippet  = null;
            var       dict     = this.Dictionary;

            if (!dict.TryGetValue(nodeType, out snippet))
            {
                snippet = GLSnippetHelper.CreateInstance(this, glNode);
                dict.Add(nodeType, snippet);
            }

            return(snippet);
        }
Beispiel #3
0
        private void Triverse(GLNode gLNode)
        {
            GLSnippet snippet = this.FindSnippet(gLNode);

            if (snippet != null)
            {
                snippet.BeforeChildren(this, gLNode);
            }

            foreach (var item in gLNode.Children)
            {
                this.Triverse(item);
            }

            if (snippet != null)
            {
                snippet.AfterChildren(this, gLNode);
            }
        }
Beispiel #4
0
        public static GLSnippet CreateInstance(GLAction someAction, GLNode glSomeNode)
        {
            Type actionType = someAction.ThisTypeCache;
            Type nodeType   = glSomeNode.ThisTypeCache;

            GLSnippet result = null;
            // NOTE: This forces GLSnippet's class name's pattern.
            string prefix  = actionType.Name.Substring(0, actionType.Name.Length - "Action".Length);
            string postfix = nodeType.Name.Substring("GL".Length, nodeType.Name.Length - "GL".Length - "Node".Length);

            try
            {
                Type type = Type.GetType(prefix + "_" + postfix);
                result = Activator.CreateInstance(type) as GLSnippet;
            }
            catch (Exception)
            {
            }

            return(result);
        }