private static T Find <T>(this IdName name) where T : class
        {
            IdName n = name.Double();

            if (sources.ContainsKey(name))
            {
                return(sources[name] as T);
            }
            if (n != null)
            {
                if (sources.ContainsKey(n))
                {
                    return(sources[n] as T);
                }
            }
            XmlElement e = name.Find();

            object[] o = actions[e.Name];
            if (o[1] is Dictionary <IdName, object> )
            {
                Dictionary <IdName, object> dd = o[1] as Dictionary <IdName, object>;
                if (!dd.ContainsKey(name))
                {
                    (o[0] as Action <IdName, XmlElement>)(name, e);
                }
                return(dd[name] as T);
            }
            Dictionary <IdName, T> d = o[1] as Dictionary <IdName, T>;

            if (!d.ContainsKey(name))
            {
                (o[0] as Action <IdName, XmlElement>)(name, e);
            }
            return(d[name]);
        }
        private static void GetMaterial(IdName name, XmlElement element)
        {
            Material   mat = null;
            XmlElement e   = element.GetElementsByTagName("instance_effect")[0] as XmlElement;
            Dictionary <string, XmlElement> par = e.GetParameters();
            string s = e.GetAttribute("url").Substring(1);
            IdName n = new IdName(s, s);

            e = nameElement[n];
            foreach (string key in materialCalc.Keys)
            {
                XmlNodeList nl = e.GetElementsByTagName(key);
                if (nl.Count == 1)
                {
                    mat = materialCalc[key](nl[0] as XmlElement);
                }
            }
            if (mat == null)
            {
            }
            materials[name] = mat;
            IdName nd = name.Double();

            if (nd != null)
            {
                materials[nd] = mat;
            }
        }
        static XmlElement Find(this IdName idName)
        {
            if (nameElement.ContainsKey(idName))
            {
                return(nameElement[idName]);
            }
            IdName id = idName.Double();

            if (nameElement.ContainsKey(id))
            {
                return(nameElement[id]);
            }
            return(null);
        }