示例#1
0
        private ConstructorInfo ResolveConstructor(String path)
        {
            string importedClassName = SessionFactoryHelper.GetImportedClassName(path);
            string className         = StringHelper.IsEmpty(importedClassName) ? path : importedClassName;

            if (className == null)
            {
                throw new SemanticException("Unable to locate class [" + path + "]");
            }
            try
            {
                System.Type holderClass = ReflectHelper.ClassForName(className);
                return(ReflectHelper.GetConstructor(holderClass, _constructorArgumentTypes));
            }
            catch (TypeLoadException e)
            {
                throw new QueryException("Unable to locate class [" + className + "]", e);
            }
            catch (InstantiationException e)
            {
                // this is the exception returned by ReflectHelper.getConstructor() if it cannot
                // locate an appropriate constructor
                throw new QueryException("Unable to locate appropriate constructor on class [" + className + "]", e);
            }
        }
示例#2
0
        private void ProcessMetaTypeDiscriminatorIfNecessary(IASTNode lhs, IASTNode rhs)
        {
            // this method inserts the discriminator value for the rhs node so that .class queries on <any> mappings work with the class name
            var lhsNode = lhs as SqlNode;
            var rhsNode = rhs as SqlNode;

            if (lhsNode == null || rhsNode == null)
            {
                return;
            }
            if (rhsNode.Text == null)
            {
                var lhsNodeMetaType = lhsNode.DataType as MetaType;
                if (lhsNodeMetaType != null)
                {
                    string className = SessionFactoryHelper.GetImportedClassName(rhsNode.OriginalText);

                    object discriminatorValue = lhsNodeMetaType.GetMetaValue(TypeNameParser.Parse(className).Type);
                    rhsNode.Text = discriminatorValue.ToString();
                    return;
                }
            }
            if (lhsNode.Text == null)
            {
                var rhsNodeMetaType = rhsNode.DataType as MetaType;
                if (rhsNodeMetaType != null)
                {
                    string className = SessionFactoryHelper.GetImportedClassName(lhsNode.OriginalText);

                    object discriminatorValue = rhsNodeMetaType.GetMetaValue(TypeNameParser.Parse(className).Type);
                    lhsNode.Text = discriminatorValue.ToString();
                    return;
                }
            }
        }