Example #1
0
        public static void Test(string message, System.Linq.Expressions.Expression<Func<IEnumerable>> standardQuery, System.Linq.Expressions.Expression<Func<IEnumerable>> bindableQuery)
        {
            int count = 0;
            var standardCompiledQuery = standardQuery.Compile();
            var bindableCompiledQuery = bindableQuery.Compile();

            Trace.WriteLine(message);
            Trace.Indent();
            Trace.Write("Standard LINQ: ");

            var standardStopwatch = new Stopwatch();
            standardStopwatch.Start();
            foreach (var item in standardCompiledQuery())
            {
                count++;
            }
            if (count < 50) throw new Exception();
            count = 0;
            standardStopwatch.Stop();
            Trace.WriteLine(standardStopwatch.ElapsedMilliseconds.ToString("n0").PadLeft(15) + " ms");

            Trace.Write("Bindable LINQ: ");
            var bindableStopwatch = new Stopwatch();
            bindableStopwatch.Start();
            foreach (var item in bindableCompiledQuery())
            {
                count++;
            }
            if (count < 50) throw new Exception();
            bindableStopwatch.Stop();
            Trace.Write(bindableStopwatch.ElapsedMilliseconds.ToString("n0").PadLeft(15) + " ms (");
            Trace.WriteLine( (((double)bindableStopwatch.ElapsedMilliseconds / standardStopwatch.ElapsedMilliseconds ).ToString("n1")) + " times slower)");

            Trace.Unindent();
        }
Example #2
0
		private IAccessorLambda InvokeAccessor(System.Linq.Expressions.Expression<Func<IAccessorLambda, IAccessorLambda>> invokeExpression)
		{
			accessors.All(o => { invokeExpression.Compile()(o); return true; });

			//return this.typeLambda;
			return this;
		}
Example #3
0
		void Func(System.Linq.Expressions.Expression<Func<int, int>> func, int n)
		{
			if (f == null)
				f = func.Compile();

			n = f(n);

			Console.WriteLine(n);
		}
 public void Type(System.Linq.Expressions.Expression<Func<Type, bool>> rule)
 {
     mTypeRule = rule.Compile();
 }
 public void Name(System.Linq.Expressions.Expression<Func<string, bool>> rule)
 {
     mNameRule = rule.Compile();
 }
Example #6
0
        internal void AddCompilerError(Cursor cursor, System.Linq.Expressions.Expression<Func<string>> error, params object[] args)
        {
            var parts = ((System.Linq.Expressions.MemberExpression)error.Body).Member.Name.Split('_');
            var errorId = parts[0];

            bool isWarning;
            switch (parts[1])
            {
                case "ERROR":
                    isWarning = false;
                    break;

                case "WARNING":
                    isWarning = true;
                    break;

                default:
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Unknown error type '{0}'.", parts[1]), "error");
            }

            var errorFormat = error.Compile()();
            var errorText = string.Format(CultureInfo.CurrentCulture, errorFormat, args);
            this.Errors.Add(new CompilerError(cursor.FileName, cursor.Line, cursor.Column, errorId, errorText) { IsWarning = isWarning });
        }
Example #7
0
        static void LoadOperationalTemplateSchemas(System.Xml.Schema.XmlSchemaSet xs)
        {
            if (!xs.Contains(RmXmlSerializer.OpenEhrNamespace))
            {
                System.Xml.Schema.XmlSchema baseTypesSchema = RmXmlSerializer.GetOpenEhrSchema("BaseTypes");

                System.Xml.Schema.XmlSchema resourceSchema = RmXmlSerializer.GetOpenEhrSchema("Resource");
                resourceSchema.Includes.Clear();
                System.Xml.Schema.XmlSchemaInclude include = new System.Xml.Schema.XmlSchemaInclude();
                include.Schema = baseTypesSchema;
                resourceSchema.Includes.Add(include);

                System.Xml.Schema.XmlSchema archetypeSchema = RmXmlSerializer.GetOpenEhrSchema("Archetype");
                archetypeSchema.Includes.Clear();
                include = new System.Xml.Schema.XmlSchemaInclude();
                include.Schema = resourceSchema;
                archetypeSchema.Includes.Add(include);

                System.Xml.Schema.XmlSchema openEhrProfileSchema = RmXmlSerializer.GetOpenEhrSchema("OpenehrProfile");
                openEhrProfileSchema.Includes.Clear();
                include = new System.Xml.Schema.XmlSchemaInclude();
                include.Schema = archetypeSchema;
                openEhrProfileSchema.Includes.Add(include);

                System.Xml.Schema.XmlSchema templateSchema = RmXmlSerializer.GetOpenEhrSchema("Template");
                templateSchema.Includes.Clear();
                include = new System.Xml.Schema.XmlSchemaInclude();
                include.Schema = openEhrProfileSchema;
                templateSchema.Includes.Add(include);
                xs.Add(templateSchema);

                xs.Compile();
            }
        }
 /// <summary>
 /// Used to create: {ValueLeft}{ComparisonOperator}{ValueRight}
 /// Used to create: {UnaryOperation}{Value}
 /// Used to create: {Value[0]}{BinaryOperator}{Value[1]}...{Value[n]}
 /// </summary>
 public Expression(System.Linq.Expressions.Expression<Func<string>> operationExpression)
 {
     Func<string> deleg = operationExpression.Compile();
     this.Value = deleg();
 }
 public static bool Procesador4(System.Linq.Expressions.Expression<Func<Producto,bool>> exp)
 {
     Func<Producto,bool> del= exp.Compile();
     return del(P);
 }
Example #10
0
 public override void DefineFunc(object ID, System.Linq.Expressions.LambdaExpression Corpse)
 {
     Functions[ScopeFunctions[(int)ID].Name] = Corpse.Compile();
 }
Example #11
0
        public static void LoadArchetypeSchema(System.Xml.Schema.XmlSchemaSet xs)
        {
            if (!xs.Contains(OpenEhrNamespace))
            {
                archetypeSchema = GetOpenEhrSchema("Archetype");

                System.Xml.Schema.XmlSchema resourceSchema = GetOpenEhrSchema("Resource");
                System.Xml.Schema.XmlSchemaInclude schemaInclude;

                archetypeSchema.Includes.RemoveAt(0);

                foreach (System.Xml.Schema.XmlSchemaObject item in resourceSchema.Items)
                    archetypeSchema.Items.Add(item);

                System.Xml.Schema.XmlSchema baseTypesSchema = GetOpenEhrSchema("BaseTypes");

                foreach (System.Xml.Schema.XmlSchemaObject item in baseTypesSchema.Items)
                    archetypeSchema.Items.Add(item);

                xs.Add(archetypeSchema);

                xs.Compile();
            }
        }
 public IQueryable<Product> FindAll(System.Linq.Expressions.Expression<Func<Product, bool>> predicate)
 {
     return _products.Where(predicate.Compile()).AsQueryable();
 }
 public Product Find(System.Linq.Expressions.Expression<Func<Product, bool>> predicate)
 {
     return _products.SingleOrDefault(predicate.Compile());
 }
 public bool Any(System.Linq.Expressions.Expression<Func<Product, bool>> predicate)
 {
     return _products.Any(predicate.Compile());
 }