Exemple #1
0
        public MathSymbol Convert(MathSymbol symbol)
        {
            Type   t    = symbol.GetType();
            string type = t.ToString();

            if (type.Contains(Serializable))
            {
                type = type.Substring(0, type.Length - Serializable.Length);
            }
            if (type.Length > Drawable.Length)
            {
                if (type.Substring(type.Length - Drawable.Length).Equals(Drawable))
                {
                    type = type.Substring(0, type.Length - Drawable.Length);
                }
            }
            if (type.Contains("FormulaEditor.Symbols."))
            {
                type = type.Substring("FormulaEditor.Symbols.".Length);
            }
            string typeDrawable = "FormulaEditor.Drawing.Symbols." + type + Drawable;

            typeDrawable = typeDrawable.Replace(".FormulaEditor.", ".");
            Type tDrawable = Type.GetType(typeDrawable);

            System.Reflection.ConstructorInfo c = tDrawable.GetConstructor(new Type[] { t });
            MathSymbol sym = c.Invoke(new object[] { symbol }) as MathSymbol;

            return(sym);
        }
Exemple #2
0
        public MathSymbol Convert(MathSymbol symbol)
        {
            Type   t    = symbol.GetType();
            string type = t.ToString();

            if (type.Length > Drawable.Length)
            {
                if (type.Substring(type.Length - Drawable.Length).Equals(Drawable))
                {
                    type = type.Substring(0, type.Length - Drawable.Length);
                }
            }
            type = type.Replace("Drawing.Symbols.", "Symbols.");
            string ass = typeof(MathFormula).Assembly.FullName;
            Type   ty  = Type.GetType(String.Format("{0}, {1}", type, ass));

            System.Reflection.ConstructorInfo c = ty.GetConstructor(new Type[] { ty });
            MathSymbol sym = c.Invoke(new object[] { symbol }) as MathSymbol;

            return(sym);
        }