Ejemplo n.º 1
0
        public IEnumerable<IMessageHandlerInvoker> LoadMessageHandlerInvokers(TypeSource typeSource)
        {
            foreach (var handlerType in typeSource.GetTypes())
            {
                if (!handlerType.IsClass || handlerType.IsAbstract || !handlerType.IsVisible || !_handlerType.IsAssignableFrom(handlerType))
                    continue;

                var subscriptionMode = MessageHandlerInvoker.GetExplicitSubscriptionMode(handlerType);
                var interfaces = handlerType.GetInterfaces();

                var excludedMessageTypes = interfaces.Where(IsExtendedMessageHandlerInterface)
                                                     .Select(handleInterface => handleInterface.GetGenericArguments()[0])
                                                     .ToHashSet();

                var handleInterfaces = interfaces.Where(IsMessageHandlerInterface);
                foreach (var handleInterface in handleInterfaces)
                {
                    var messageType = handleInterface.GetGenericArguments()[0];
                    if (excludedMessageTypes.Contains(messageType))
                        continue;

                    var shouldBeSubscribedOnStartup = MessageHandlerInvoker.MessageShouldBeSubscribedOnStartup(messageType, subscriptionMode);
                    var invoker = BuildMessageHandlerInvoker(handlerType, messageType, shouldBeSubscribedOnStartup);
                    yield return invoker;
                }
            }
        }
Ejemplo n.º 2
0
 public CommandReader(string commands, Random random)
 {
     _animationFactory = new AnimationFactory(TypeSource <IAnimation> .FromThisAssembly());
     _patternFactory   = new PatternFactory(TypeSource <IPattern> .FromThisAssembly());
     _timingFactory    = new TimingFactory(TypeSource <ITiming> .FromThisAssembly());
     _commands         = commands;
 }
        public void should_load_queue_name()
        {
            var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
            var invoker       = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType <FakeHandlerWithQueueName1>()).ExpectedSingle();

            invoker.DispatchQueueName.ShouldEqual("DispatchQueue1");
        }
        public static bool GetAssetType(string assetPath, out Type type, out TypeSource source)
        {
            var ext = Path.GetExtension(assetPath);

            if (!string.IsNullOrEmpty(ext))
            {
                if (_knownTypes.TryGetValue(ext.ToLower(), out type))
                {
                    source = TypeSource.FileName;
                    return(true);
                }
            }

            if (AssetTypeCache.GetAssetType(assetPath, out type))
            {
                source = TypeSource.Cache;
                return(true);
            }

            source = TypeSource.Unity;
            var asset = AssetDatabase.LoadMainAssetAtPath(assetPath);

            if (asset == null)
            {
                TSLog.LogWarning(LogCategory.Trace, string.Format("Failed loading asset at path [{0}].", assetPath));
                type = null;
                return(false);
            }

            type = asset.GetType();
            AssetTypeCache.PostAssetType(assetPath, type);

            return(true);
        }
Ejemplo n.º 5
0
 public MetaAssertionsType([NotNull] Type codeType,
                           [NotNull] Assembly testAssembly)
 {
     mTestAssembly = testAssembly;
     mSource       = TypeSource.CodeAssembly;
     mTargetType   = codeType;
 }
        public void should_switch_to_auto_subscription_mode_when_specified()
        {
            var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
            var invoker       = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType <FakeRoutableHandlerWithAutoSubscriptionMode>()).ExpectedSingle();

            invoker.ShouldBeSubscribedOnStartup.ShouldBeTrue();
        }
Ejemplo n.º 7
0
        public IEnumerable <Instruction> Hydrate(IEnumerable <Instruction> nodes)
        {
            var processedNodes = new Collection <Instruction>();
            var skipNext       = false;

            foreach (var xamlNode in nodes)
            {
                var matchedInflatable = GetMatchedInflatable(xamlNode);

                if (matchedInflatable != null)
                {
                    var toAdd        = ReadNodes(xamlNode.XamlType.UnderlyingType);
                    var croppedNodes = Crop(toAdd, xamlNode.XamlType, TypeSource.GetByType((matchedInflatable)));

                    foreach (var croppedNode in croppedNodes)
                    {
                        processedNodes.Add(croppedNode);
                        skipNext = true;
                    }
                }
                else
                {
                    if (skipNext)
                    {
                        skipNext = false;
                    }
                    else
                    {
                        processedNodes.Add(xamlNode);
                    }
                }
            }

            return(processedNodes);
        }
Ejemplo n.º 8
0
        public TypeRestricted(TypeSource source, string value)
        {
            Source      = source;
            SourceValue = value;

            if (Source == TypeSource.Value)
            {
                Type = new SerializedType(value).Type;
            }
        }
Ejemplo n.º 9
0
        public void should_load_async_invoker()
        {
            var invokerLoader = new AsyncMessageHandlerInvokerLoader(new Container());
            var invokers      = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromAssembly(this)).ToList();

            var fakeHandlerInvoker = invokers.SingleOrDefault(x => x.MessageHandlerType == typeof(FakeHandler));

            fakeHandlerInvoker.ShouldNotBeNull();
            fakeHandlerInvoker.ShouldBeOfType <AsyncMessageHandlerInvoker>();
        }
Ejemplo n.º 10
0
        public static string GetSubFolder(TypeSource source)
        {
            switch (source)
            {
            case TypeSource.Wiki:
                return("LuaLibraries");

            case TypeSource.CPPHeader:
                return("NativeClasses");

            default:
                return("Unknown");
            }
        }
Ejemplo n.º 11
0
        public void Discovers_types_directly_or_implicitly()
        {
            var assemblies = new List<Assembly> {GetType().Assembly};
            var assemblySource = new Mock<IAssemblySource>();
            assemblySource.SetupGet(source => source.Assemblies).Returns(assemblies);

            var typeSource = new TypeSource(assemblySource.Object);

            var results = typeSource
                .Implementing<ITestTypeDiscoveryInterface>()
                .ToList();

            Assert.AreEqual(2, results.Count);
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.First()));
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.Last()));
        }
Ejemplo n.º 12
0
        public void Can_pass_desired_type_instead_of_using_generics()
        {
            var assemblies = new List<Assembly> { GetType().Assembly };
            var assemblySource = new Mock<IAssemblySource>();
            assemblySource.SetupGet(source => source.Assemblies).Returns(assemblies);

            var typeSource = new TypeSource(assemblySource.Object);

            var results = typeSource
                .Implementing(typeof(ITestTypeDiscoveryInterface))
                .ToList();

            Assert.AreEqual(2, results.Count);
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.First()));
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.Last()));
        }
Ejemplo n.º 13
0
        private TypeSource CreateTypeSource()
        {
            var typeSource = new TypeSource();

            if (_assemblyFilter != null)
            {
                typeSource.AssemblyFilter = _assemblyFilter;
            }

            if (_handlerFilter != null)
            {
                typeSource.TypeFilter = _handlerFilter;
            }

            return(typeSource);
        }
Ejemplo n.º 14
0
        public void Discovered_expected_number_of_types()
        {
            var assemblies = new List<Assembly> {GetType().Assembly};
            var assemblySource = new Mock<IAssemblySource>();
            assemblySource.SetupGet(source => source.Assemblies).Returns(assemblies);

            var typeSource = new TypeSource(assemblySource.Object);

            var expectedCount = GetType().Assembly.GetTypes().Where(type => !type.IsAbstract).Count();

            var count = typeSource
                .AllTypes()
                .Count();

            Assert.AreNotEqual(0, count);
            Assert.AreEqual(expectedCount, count);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="typeSource"></param>
        /// <returns></returns>
        public static Type FindType(this ServiceDescriptorConfiguration item, TypeSource typeSource)
        {
            Type returnValue = null;

            //
            // Get the actual type definition. The type definition
            // passed here can contain one or more aliases.
            //
            string actualTypeDefinition = item.TransformAlias(typeSource);

            //
            // Get the type.
            //
            returnValue = Type.GetType(actualTypeDefinition, true);

            return(returnValue);
        }
Ejemplo n.º 16
0
        public IEnumerable <Instruction> ParseMarkupExtensionNode(MarkupExtensionNode tree)
        {
            var identifierNode = tree.Identifier;
            var xamlType       = TypeSource.GetByPrefix(identifierNode.Prefix, identifierNode.TypeName);

            yield return(Inject.StartOfObject(xamlType));

            foreach (var instruction in ParseArguments(tree.Options.OfType <PositionalOption>()))
            {
                yield return(instruction);
            }
            foreach (var instruction in ParseProperties(tree.Options.OfType <PropertyOption>(), xamlType))
            {
                yield return(instruction);
            }

            yield return(Inject.EndOfObject());
        }
        public AutoPersistenceModel CreateModel()
        {
            var conventions = Conventions.ToArray <IConvention>();
            var theTypes    = TypeSource.GetTypes();

            return(AutoMap.Source(TypeSource)
                   // Ensure that namespaces of types are never auto-imported, so that
                   // identical type names from different namespaces can be mapped without ambiguity
                   .Conventions.Setup(x => x.Add(AutoImport.Never()))
                   .Conventions.Add(conventions)
                   .Alterations(alt =>
            {
                foreach (var recordAssembly in theTypes.Select(x => x.Assembly).Union(new[] { typeof(IExtensiblePersistenceModelFactory).Assembly }).Distinct())
                {
                    alt.Add(new AutoMappingOverrideAlteration(recordAssembly));
                }
                foreach (var custAlt in Alterations)
                {
                    alt.Add(custAlt);
                }
            }));
        }
Ejemplo n.º 18
0
            internal override SqlExpression VisitMethodCall(SqlMethodCall mc)
            {
                mc.Object = this.VisitExpression(mc.Object);
                for (int i = 0, n = mc.Arguments.Count; i < n; i++)
                {
                    mc.Arguments[i] = this.VisitExpression(mc.Arguments[i]);
                }
                if (mc.Method.IsStatic)
                {
                    if (mc.Method.Name == "Equals" && mc.Arguments.Count == 2)
                    {
                        return(sql.Binary(SqlNodeType.EQ2V, mc.Arguments[0], mc.Arguments[1], mc.Method));
                    }
                    if (mc.Method.DeclaringType == typeof(string) && mc.Method.Name == "Concat")
                    {
                        SqlClientArray       arr   = mc.Arguments[0] as SqlClientArray;
                        List <SqlExpression> exprs = null;
                        if (arr != null)
                        {
                            exprs = arr.Expressions;
                        }
                        else
                        {
                            exprs = mc.Arguments;
                        }
                        if (exprs.Count == 0)
                        {
                            return(sql.ValueFromObject("", false, mc.SourceExpression));
                        }
                        SqlExpression sum;
                        if (exprs[0].SqlType.IsString || exprs[0].SqlType.IsChar)
                        {
                            sum = exprs[0];
                        }
                        else
                        {
                            sum = sql.ConvertTo(typeof(string), exprs[0]);
                        }
                        for (int i = 1; i < exprs.Count; i++)
                        {
                            if (exprs[i].SqlType.IsString || exprs[i].SqlType.IsChar)
                            {
                                sum = sql.Concat(sum, exprs[i]);
                            }
                            else
                            {
                                sum = sql.Concat(sum, sql.ConvertTo(typeof(string), exprs[i]));
                            }
                        }
                        return(sum);
                    }
                    if (IsVbIIF(mc))
                    {
                        return(TranslateVbIIF(mc));
                    }
                    switch (mc.Method.Name)
                    {
                    case "op_Equality":
                        return(sql.Binary(SqlNodeType.EQ, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_Inequality":
                        return(sql.Binary(SqlNodeType.NE, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_LessThan":
                        return(sql.Binary(SqlNodeType.LT, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_LessThanOrEqual":
                        return(sql.Binary(SqlNodeType.LE, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_GreaterThan":
                        return(sql.Binary(SqlNodeType.GT, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_GreaterThanOrEqual":
                        return(sql.Binary(SqlNodeType.GE, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_Multiply":
                        return(sql.Binary(SqlNodeType.Mul, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_Division":
                        return(sql.Binary(SqlNodeType.Div, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_Subtraction":
                        return(sql.Binary(SqlNodeType.Sub, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_Addition":
                        return(sql.Binary(SqlNodeType.Add, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_Modulus":
                        return(sql.Binary(SqlNodeType.Mod, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_BitwiseAnd":
                        return(sql.Binary(SqlNodeType.BitAnd, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_BitwiseOr":
                        return(sql.Binary(SqlNodeType.BitOr, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_ExclusiveOr":
                        return(sql.Binary(SqlNodeType.BitXor, mc.Arguments[0], mc.Arguments[1], mc.Method, mc.ClrType));

                    case "op_UnaryNegation":
                        return(sql.Unary(SqlNodeType.Negate, mc.Arguments[0], mc.Method, mc.SourceExpression));

                    case "op_OnesComplement":
                        return(sql.Unary(SqlNodeType.BitNot, mc.Arguments[0], mc.Method, mc.SourceExpression));

                    case "op_False":
                        return(sql.Unary(SqlNodeType.Not, mc.Arguments[0], mc.Method, mc.SourceExpression));
                    }
                }
                else
                {
                    if (mc.Method.Name == "Equals" && mc.Arguments.Count == 1)
                    {
                        return(sql.Binary(SqlNodeType.EQ, mc.Object, mc.Arguments[0]));
                    }
                    if (mc.Method.Name == "GetType" && mc.Arguments.Count == 0)
                    {
                        MetaType mt = TypeSource.GetSourceMetaType(mc.Object, this.model);
                        if (mt.HasInheritance)
                        {
                            Type discriminatorType             = mt.Discriminator.Type;
                            SqlDiscriminatorOf discriminatorOf = new SqlDiscriminatorOf(mc.Object, discriminatorType, this.sql.TypeProvider.From(discriminatorType), mc.SourceExpression);
                            return(this.VisitExpression(sql.DiscriminatedType(discriminatorOf, mt)));
                        }
                        return(this.VisitExpression(sql.StaticType(mt, mc.SourceExpression)));
                    }
                }
                return(mc);
            }
Ejemplo n.º 19
0
            internal override SqlExpression VisitMethodCall(SqlMethodCall mc)
            {
                mc.Object = this.VisitExpression(mc.Object);
                int num   = 0;
                int count = mc.Arguments.Count;

                while (num < count)
                {
                    mc.Arguments[num] = this.VisitExpression(mc.Arguments[num]);
                    num++;
                }
                if (mc.Method.IsStatic)
                {
                    if ((mc.Method.Name == "Equals") && (mc.Arguments.Count == 2))
                    {
                        return(this.sql.Binary(SqlNodeType.EQ2V, mc.Arguments[0], mc.Arguments[1], mc.Method));
                    }
                    if ((mc.Method.DeclaringType == typeof(string)) && (mc.Method.Name == "Concat"))
                    {
                        SqlExpression expression;
                        var           array       = mc.Arguments[0] as SqlClientArray;
                        var           expressions = array != null ? array.Expressions : mc.Arguments;
                        if (expressions.Count == 0)
                        {
                            return(this.sql.ValueFromObject("", false, mc.SourceExpression));
                        }
                        if (expressions[0].SqlType.IsString || expressions[0].SqlType.IsChar)
                        {
                            expression = expressions[0];
                        }
                        else
                        {
                            expression = this.sql.ConvertTo(typeof(string), expressions[0]);
                        }
                        for (int i = 1; i < expressions.Count; i++)
                        {
                            if (expressions[i].SqlType.IsString || expressions[i].SqlType.IsChar)
                            {
                                expression = this.sql.Concat(new SqlExpression[] { expression, expressions[i] }, mc.SourceExpression);
                            }
                            else
                            {
                                expression =
                                    this.sql.Concat(new SqlExpression[]
                                {
                                    expression, this.sql.ConvertTo(typeof(string), expressions[i])
                                }, mc.SourceExpression);
                            }
                        }
                        return(expression);
                    }
                    if (PreBindDotNetConverter.IsVbIIF(mc))
                    {
                        return(this.TranslateVbIIF(mc));
                    }
                    switch (mc.Method.Name)
                    {
                    case "op_Equality":
                        return(this.sql.Binary(SqlNodeType.EQ, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_Inequality":
                        return(this.sql.Binary(SqlNodeType.NE, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_LessThan":
                        return(this.sql.Binary(SqlNodeType.LT, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_LessThanOrEqual":
                        return(this.sql.Binary(SqlNodeType.LE, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_GreaterThan":
                        return(this.sql.Binary(SqlNodeType.GT, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_GreaterThanOrEqual":
                        return(this.sql.Binary(SqlNodeType.GE, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_Multiply":
                        return(this.sql.Binary(SqlNodeType.Mul, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_Division":
                        return(this.sql.Binary(SqlNodeType.Div, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_Subtraction":
                        return(this.sql.Binary(SqlNodeType.Sub, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_Addition":
                        return(this.sql.Binary(SqlNodeType.Add, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_Modulus":
                        return(this.sql.Binary(SqlNodeType.Mod, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_BitwiseAnd":
                        return(this.sql.Binary(SqlNodeType.BitAnd, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_BitwiseOr":
                        return(this.sql.Binary(SqlNodeType.BitOr, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_ExclusiveOr":
                        return(this.sql.Binary(SqlNodeType.BitXor, mc.Arguments[0], mc.Arguments[1], mc.Method,
                                               mc.ClrType));

                    case "op_UnaryNegation":
                        return(this.sql.Unary(SqlNodeType.Negate, mc.Arguments[0], mc.Method, mc.SourceExpression));

                    case "op_OnesComplement":
                        return(this.sql.Unary(SqlNodeType.BitNot, mc.Arguments[0], mc.Method, mc.SourceExpression));

                    case "op_False":
                        return(this.sql.Unary(SqlNodeType.Not, mc.Arguments[0], mc.Method, mc.SourceExpression));
                    }
                    return(mc);
                }
                if ((mc.Method.Name == "Equals") && (mc.Arguments.Count == 1))
                {
                    return(this.sql.Binary(SqlNodeType.EQ, mc.Object, mc.Arguments[0]));
                }
                if (!(mc.Method.Name == "GetType") || (mc.Arguments.Count != 0))
                {
                    return(mc);
                }
                MetaType sourceMetaType = TypeSource.GetSourceMetaType(mc.Object, this.model);

                if (sourceMetaType.HasInheritance)
                {
                    Type type          = sourceMetaType.Discriminator.Type;
                    var  discriminator = new SqlDiscriminatorOf(mc.Object, type,
                                                                this.sql.TypeProvider.From(type),
                                                                mc.SourceExpression);
                    return(this.VisitExpression(this.sql.DiscriminatedType(discriminator, sourceMetaType)));
                }
                return(this.VisitExpression(this.sql.StaticType(sourceMetaType, mc.SourceExpression)));
            }
Ejemplo n.º 20
0
 public MetaAssertionsType([NotNull] Type testType)
 {
     mSource     = TypeSource.TestAssembly;
     mTargetType = testType;
 }
Ejemplo n.º 21
0
 public PatternFactory(TypeSource <IPattern> typeSource)
     : base(typeSource)
 {
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="typeSource"></param>
        /// <returns></returns>
        public static string ExtractTypeDefinition(this ServiceDescriptorConfiguration item, TypeSource typeSource)
        {
            string returnValue = null;

            if (typeSource == TypeSource.Implemenation)
            {
                returnValue = item.ImplementationType;
            }
            else
            {
                returnValue = item.ServiceType;
            }

            return(returnValue);
        }
Ejemplo n.º 23
0
 public SceneRandom()
 {
     _animationFactory = new AnimationFactory(TypeSource <IAnimation> .FromThisAssembly());
     _patternFactory   = new PatternFactory(TypeSource <IPattern> .FromThisAssembly().Exclude <PatternSolidColor>());
     _timingFactory    = new TimingFactory(TypeSource <ITiming> .FromThisAssembly());
 }
        public void should_throw_exception_if_method_is_async_void()
        {
            var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());

            Assert.Throws <InvalidProgramException>(() => invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType <WrongAsyncHandler>()).ToList());
        }
Ejemplo n.º 25
0
        private TypeSource CreateTypeSource()
        {
            var typeSource = new TypeSource();

            if (_assemblyFilter != null)
                typeSource.AssemblyFilter = _assemblyFilter;

            if (_handlerFilter != null)
                typeSource.TypeFilter = _handlerFilter;

            return typeSource;
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <param name="typeSource"></param>
 /// <returns></returns>
 public static string TransformAlias(this ServiceDescriptorConfiguration item, TypeSource typeSource)
 {
     return(TransformAlias(item.ExtractTypeDefinition(typeSource)));
 }
Ejemplo n.º 27
0
 public TypeNode()
 {
     MethodNodes   = new List <MethodNode>();
     PropertyNodes = new List <PropertyNode>();
     Source        = new TypeSource();
 }
Ejemplo n.º 28
0
        internal SqlExpression TranslateEquals(SqlBinary expr)
        {
            IList <SqlExpression> keyExpressions;
            IList <SqlExpression> identityExpressions;
            SqlExpression         left  = expr.Left;
            SqlExpression         right = expr.Right;

            if (right.NodeType == SqlNodeType.Element)
            {
                var select    = (SqlSubSelect)right;
                var alias     = new SqlAlias(select.Select);
                var selection = new SqlAliasRef(alias);
                var select2   = new SqlSelect(selection, alias, expr.SourceExpression)
                {
                    Where = sql.Binary(expr.NodeType, sql.DoNotVisitExpression(left), selection)
                };
                return(sql.SubSelect(SqlNodeType.Exists, select2));
            }
            if (left.NodeType == SqlNodeType.Element)
            {
                var select3 = (SqlSubSelect)left;
                var alias2  = new SqlAlias(select3.Select);
                var ref3    = new SqlAliasRef(alias2);
                var select4 = new SqlSelect(ref3, alias2, expr.SourceExpression)
                {
                    Where = sql.Binary(expr.NodeType, sql.DoNotVisitExpression(right), ref3)
                };
                return(sql.SubSelect(SqlNodeType.Exists, select4));
            }
            var sourceMetaType = TypeSource.GetSourceMetaType(left, services.Model);
            var type           = TypeSource.GetSourceMetaType(right, services.Model);

            if (left.NodeType == SqlNodeType.TypeCase)
            {
                left = BestIdentityNode((SqlTypeCase)left);
            }
            if (right.NodeType == SqlNodeType.TypeCase)
            {
                right = BestIdentityNode((SqlTypeCase)right);
            }
            if ((sourceMetaType.IsEntity && type.IsEntity) && (sourceMetaType.Table != type.Table))
            {
                throw Error.CannotCompareItemsAssociatedWithDifferentTable();
            }
            if (((!sourceMetaType.IsEntity && !type.IsEntity) && ((left.NodeType != SqlNodeType.New) || left.SqlType.CanBeColumn)) && ((right.NodeType != SqlNodeType.New) || right.SqlType.CanBeColumn))
            {
                if ((expr.NodeType == SqlNodeType.EQ2V) || (expr.NodeType == SqlNodeType.NE2V))
                {
                    return(TranslateEqualsOp(expr.NodeType, sql.DoNotVisitExpression(expr.Left),
                                             sql.DoNotVisitExpression(expr.Right), false));
                }
                return(expr);
            }
            if ((sourceMetaType != type) && (sourceMetaType.InheritanceRoot != type.InheritanceRoot))
            {
                return(this.sql.Binary(SqlNodeType.EQ, sql.ValueFromObject(0, expr.SourceExpression), this.sql.ValueFromObject(1, expr.SourceExpression)));
            }
            var link = left as SqlLink;

            if (((link != null) && link.Member.IsAssociation) && link.Member.Association.IsForeignKey)
            {
                keyExpressions = link.KeyExpressions;
            }
            else
            {
                keyExpressions = this.GetIdentityExpressions(sourceMetaType, this.sql.DoNotVisitExpression(left));
            }
            var link2 = right as SqlLink;

            if (((link2 != null) && link2.Member.IsAssociation) && link2.Member.Association.IsForeignKey)
            {
                identityExpressions = link2.KeyExpressions;
            }
            else
            {
                identityExpressions = this.GetIdentityExpressions(type, sql.DoNotVisitExpression(right));
            }
            SqlExpression expression3 = null;
            SqlNodeType   op          = ((expr.NodeType == SqlNodeType.EQ2V) || (expr.NodeType == SqlNodeType.NE2V)) ? SqlNodeType.EQ2V : SqlNodeType.EQ;
            int           num         = 0;
            int           count       = keyExpressions.Count;

            while (num < count)
            {
                SqlExpression expression4 = this.TranslateEqualsOp(op, keyExpressions[num], identityExpressions[num], !sourceMetaType.IsEntity);
                if (expression3 == null)
                {
                    expression3 = expression4;
                }
                else
                {
                    expression3 = this.sql.Binary(SqlNodeType.And, expression3, expression4);
                }
                num++;
            }
            if ((expr.NodeType != SqlNodeType.NE) && (expr.NodeType != SqlNodeType.NE2V))
            {
                return(expression3);
            }
            return(this.sql.Unary(SqlNodeType.Not, expression3, expression3.SourceExpression));
        }
 public ConfigurationItemFactory()
 {
     _demonstrations = TypeSource <IDemonstrationProxy> .From(Assembly.GetExecutingAssembly());
 }
        public void should_not_throw_if_scanning_handler_with_several_handle_methods()
        {
            var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());

            Assert.DoesNotThrow(() => invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType <FakeHandler>()).ToList());
        }
Ejemplo n.º 31
0
 public TimingFactory(TypeSource <ITiming> typeSource)
     : base(typeSource)
 {
 }
Ejemplo n.º 32
0
 public TypeRestricted(Type type)
 {
     Type   = type;
     Source = TypeSource.Value;
 }
Ejemplo n.º 33
0
 public AnimationFactory(TypeSource <IAnimation> typeSource)
     : base(typeSource)
 {
 }