Ejemplo n.º 1
0
 /// <summary>
 /// Deserializes xml markup from file into an QvxTableHeader object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output QvxTableHeader object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out QvxTableHeader obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(QvxTableHeader);
     try
     {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deserializes workflow markup into an QvxTableHeader object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output QvxTableHeader object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out QvxTableHeader obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(QvxTableHeader);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Ejemplo n.º 3
0
        public QvxWriteCode(Type type, Dictionary<string, List<QvxBaseAttribute>> overrideAttributes)
        {
            var data = QvxData.FromObjectCode(type, overrideAttributes);
            qvxTableHeader = new QvxTableHeader();
            qvxTableHeader.TableName = type.Name;
            qvxTableHeader.Fields.AddRange(data.Item1);
            QvxHeader = Encoding.UTF8.GetBytes(qvxTableHeader.Serialize());

            #region Code Template
            string code = @"
            namespace QvxLib {
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Reflection;
            using System.Reflection.Emit;
            using System.IO;

            public static class FieldInfoExtensions
            {
            public static DynamicMethod GetGetMethod(this FieldInfo fi)
            {
            DynamicMethod dm = new DynamicMethod(""Get"" + fi.Name,
                fi.FieldType, new Type[] { fi.DeclaringType }, fi.DeclaringType);
            ILGenerator il = dm.GetILGenerator();
            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Ldfld, fi);
            il.Emit(OpCodes.Ret);
            return dm;
            }
            }

            public class QvxWriterClass
            {
            public static void QvxWriter(BinaryWriter bw, IEnumerable<object> list)
            {
            object tmpValue = null;
            byte[] sbuf = null;
            StringBuilder sb = null;

            Type T_base__ = list.GetType().GetInterface(typeof(IEnumerable<>).Name).GetGenericArguments()[0];
            " + data.Item2 + @"
            foreach (var base__item in list)
            {
            " + data.Item3 + @"
            }
            }
            }
            }";
            #endregion

            #region Compiler Paramater
            CompilerParameters compilerParams = new CompilerParameters()
            {
                CompilerOptions = "/target:library /optimize /define:RELEASE",
                GenerateExecutable = false,
                WarningLevel = 3,
                GenerateInMemory = true,
                IncludeDebugInformation = false,
                ReferencedAssemblies = { "mscorlib.dll", "System.dll", "System.Core.dll" }
            };
            #if DEBUG
            compilerParams.CompilerOptions = "/target:library /define:DEBUG";
            compilerParams.GenerateInMemory = false;
            compilerParams.IncludeDebugInformation = true;
            compilerParams.TempFiles.KeepFiles = true;
            compilerParams.TempFiles = new TempFileCollection(Environment.GetEnvironmentVariable("TEMP"), true);
            #endif
            #endregion

            var provOptions = new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } };

            CodeDomProvider codeProvider = new CSharpCodeProvider(provOptions);
            CompilerResults results = codeProvider.CompileAssemblyFromSource(compilerParams, code);

            if (!results.Errors.HasErrors)
            {
                var QvxWriterClassType = results.CompiledAssembly.GetType("QvxLib.QvxWriterClass");
                QvxWriterMethod = QvxWriterClassType.GetMethod("QvxWriter", BindingFlags.Static | BindingFlags.Public);
            }
            else
                throw new Exception("Compilation Error" + results.Output.ToString());
        }
Ejemplo n.º 4
0
 public static bool LoadFromFile(string fileName, out QvxTableHeader obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Deserializes xml markup from file into an QvxTableHeader object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output QvxTableHeader object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out QvxTableHeader obj, out System.Exception exception)
 {
     exception = null;
     obj = default(QvxTableHeader);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Ejemplo n.º 6
0
 public static bool Deserialize(string xml, out QvxTableHeader obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Deserializes workflow markup into an QvxTableHeader object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output QvxTableHeader object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out QvxTableHeader obj, out System.Exception exception)
 {
     exception = null;
     obj = default(QvxTableHeader);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Ejemplo n.º 8
0
        public QvxWriteCode(Type type, Dictionary <string, List <QvxBaseAttribute> > overrideAttributes)
        {
            var data = QvxData.FromObjectCode(type, overrideAttributes);

            qvxTableHeader           = new QvxTableHeader();
            qvxTableHeader.TableName = type.Name;
            qvxTableHeader.Fields.AddRange(data.Item1);
            QvxHeader = Encoding.UTF8.GetBytes(qvxTableHeader.Serialize());



            #region Code Template
            string code = @"
namespace QvxLib { 
    using System; 
    using System.Collections.Generic;
    using System.Linq;
    using System.Text; 
    using System.Reflection;
    using System.Reflection.Emit;
    using System.IO; 


    public static class FieldInfoExtensions
    {
        public static DynamicMethod GetGetMethod(this FieldInfo fi)
        {       
            DynamicMethod dm = new DynamicMethod(""Get"" + fi.Name,
                fi.FieldType, new Type[] { fi.DeclaringType }, fi.DeclaringType);
            ILGenerator il = dm.GetILGenerator();          
            il.Emit(OpCodes.Ldarg_0);            
            il.Emit(OpCodes.Ldfld, fi);            
            il.Emit(OpCodes.Ret);
            return dm;
        }
    }

    public class QvxWriterClass 
    { 
        public static void QvxWriter(BinaryWriter bw, IEnumerable<object> list) 
        {           
            object tmpValue = null;    
            byte[] sbuf = null; 
            StringBuilder sb = null;    
                          
            Type T_base__ = list.GetType().GetInterface(typeof(IEnumerable<>).Name).GetGenericArguments()[0];
" + data.Item2 + @"                        
            foreach (var base__item in list) 
            {
" + data.Item3 + @"
            }
        }
    }
}";
            #endregion

            #region Compiler Paramater
            CompilerParameters compilerParams = new CompilerParameters()
            {
                CompilerOptions         = "/target:library /optimize /define:RELEASE",
                GenerateExecutable      = false,
                WarningLevel            = 3,
                GenerateInMemory        = true,
                IncludeDebugInformation = false,
                ReferencedAssemblies    = { "mscorlib.dll", "System.dll", "System.Core.dll" }
            };
#if DEBUG
            compilerParams.CompilerOptions         = "/target:library /define:DEBUG";
            compilerParams.GenerateInMemory        = false;
            compilerParams.IncludeDebugInformation = true;
            compilerParams.TempFiles.KeepFiles     = true;
            compilerParams.TempFiles = new TempFileCollection(Environment.GetEnvironmentVariable("TEMP"), true);
#endif
            #endregion

            var provOptions = new Dictionary <string, string>()
            {
                { "CompilerVersion", "v3.5" }
            };

            CodeDomProvider codeProvider = new CSharpCodeProvider(provOptions);
            CompilerResults results      = codeProvider.CompileAssemblyFromSource(compilerParams, code);

            if (!results.Errors.HasErrors)
            {
                var QvxWriterClassType = results.CompiledAssembly.GetType("QvxLib.QvxWriterClass");
                QvxWriterMethod = QvxWriterClassType.GetMethod("QvxWriter", BindingFlags.Static | BindingFlags.Public);
            }
            else
            {
                throw new Exception("Compilation Error" + results.Output.ToString());
            }
        }
Ejemplo n.º 9
0
 public static bool LoadFromFile(string fileName, out QvxTableHeader obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Ejemplo n.º 10
0
 public static bool Deserialize(string xml, out QvxTableHeader obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }