Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterMap"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="className">Name of the class.</param>
        /// <param name="extendMap">The extend map.</param>
        /// <param name="type">The type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="usePositionalParameters">if set to <c>true</c> [use positional parameters].</param>
        public ParameterMap(
            string id,
            string className,
            string extendMap,
            Type type,
            IDataExchange dataExchange,
            bool usePositionalParameters)
        {
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id in ParameterMap constructor");
            Contract.Require.That(dataExchange, Is.Not.Null & Is.Not.Empty).When("retrieving argument dataExchange in ParameterMap constructor for id " + id );

            HasOutputParameter = false;

            if (logger.IsInfoEnabled)
            {
                if (string.IsNullOrEmpty(className))
                {
                    logger.Info("The class attribute is recommended for better performance in a ParameterMap tag '" + id + "'.");
                }
            }

            this.id = id;
            this.className = className;
            this.usePositionalParameters = usePositionalParameters;
            parameterClass = type;
            this.dataExchange = dataExchange;
            this.extendMap = extendMap;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterMap"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="className">Name of the class.</param>
        /// <param name="extendMap">The extend map.</param>
        /// <param name="type">The type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="usePositionalParameters">if set to <c>true</c> [use positional parameters].</param>
        public ParameterMap(
            string id,
            string className,
            string extendMap,
            Type type,
            IDataExchange dataExchange,
            bool usePositionalParameters)
        {
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id");
            //Contract.Require.That(className, Is.Not.Null & Is.Not.Empty).When("retrieving argument className");

            if (logger.IsInfoEnabled)
            {
                if ((className == null) || (className.Length < 1))
                {
                    logger.Info("The class attribute is recommended for better performance in a ParameterMap tag '" + id + "'.");
                }
            }

            this.id        = id;
            this.className = className;
            this.usePositionalParameters = usePositionalParameters;
            this.parameterClass          = type;
            this.dataExchange            = dataExchange;
            this.extendMap = extendMap;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get a DataExchange object for the passed in Class
        /// </summary>
        /// <param name="clazz">The class to get a DataExchange object for</param>
        /// <returns>The IDataExchange object</returns>
        public IDataExchange GetDataExchangeForClass(Type clazz)
        {
            IDataExchange dataExchange = null;

            if (clazz == null)
            {
                dataExchange = _complexDataExchange;
            }
            else if (typeof(IList).IsAssignableFrom(clazz))
            {
                dataExchange = _listDataExchange;
            }
            else if (typeof(IDictionary).IsAssignableFrom(clazz))
            {
                dataExchange = _dictionaryDataExchange;
            }
            else if (_typeHandlerFactory.GetTypeHandler(clazz) != null)
            {
                dataExchange = _primitiveDataExchange;
            }
            else
            {
                dataExchange = new DotNetObjectDataExchange(clazz, this);
            }

            return(dataExchange);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterMap"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="className">Name of the class.</param>
        /// <param name="extendMap">The extend map.</param>
        /// <param name="type">The type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="usePositionalParameters">if set to <c>true</c> [use positional parameters].</param>
        public ParameterMap(
            string id,
            string className,
            string extendMap,
            Type type,
            IDataExchange dataExchange,
            bool usePositionalParameters)
        {
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id in ParameterMap constructor");
            Contract.Require.That(dataExchange, Is.Not.Null & Is.Not.Empty).When("retrieving argument dataExchange in ParameterMap constructor for id " + id);

            HasOutputParameter = false;

            if (logger.IsInfoEnabled)
            {
                if (string.IsNullOrEmpty(className))
                {
                    logger.Info("The class attribute is recommended for better performance in a ParameterMap tag '" + id + "'.");
                }
            }

            this.id        = id;
            this.className = className;
            this.usePositionalParameters = usePositionalParameters;
            parameterClass    = type;
            this.dataExchange = dataExchange;
            this.extendMap    = extendMap;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get a DataExchange object for the passed in Class
        /// </summary>
        /// <param name="clazz">The class to get a DataExchange object for</param>
        /// <returns>The IDataExchange object</returns>
        public IDataExchange GetDataExchangeForClass(Type clazz)
        {
            IDataExchange dataExchange = null;

            if (clazz == null)
            {
                //为null取ComplexDataExchange对象类
                dataExchange = _complexDataExchange;
            }
            else if (typeof(IList).IsAssignableFrom(clazz))
            {
                //如果是IList类形式
                dataExchange = _listDataExchange;
            }
            else if (typeof(IDictionary).IsAssignableFrom(clazz))
            {
                //如果是IDictionary类型
                dataExchange = _dictionaryDataExchange;
            }
            else if (_typeHandlerFactory.GetTypeHandler(clazz) != null)
            {
                //去TypeHandlerFactory工厂中去取类对象
                dataExchange = _primitiveDataExchange;
            }
            else
            {
                //最终默认的数据交换类型
                dataExchange = new DotNetObjectDataExchange(clazz, this);
            }

            return(dataExchange);
        }
Ejemplo n.º 6
0
        public void Open(object o)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                IDataExchange gvService  = ServiceContainer.CreateInstance().Resolve <IDataExchange>("DataExchangeService");
                string        selectPath = fbd.SelectedPath;
                string        treepath   = Path.Combine(selectPath, treeSvaeName);
                string        propPath   = Path.Combine(selectPath, prooertyName);
                string        dataPath   = Path.Combine(selectPath, data);
                if (File.Exists(treepath))
                {
                    service.Invoke("panel11", "LoadFromFile", new object[1] {
                        treepath
                    });
                }
                if (File.Exists(propPath))
                {
                    service.Invoke("panel12", "LoadFromFile", new object[1] {
                        propPath
                    });
                }
                if (File.Exists(dataPath))
                {
                    gvService.LoadFromFile(dataPath);
                }
                gvService["ProjectPath"] = fbd.SelectedPath;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Deserializes a ParameterMap object
        /// </summary>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="config">The config.</param>
        /// <param name="modelStore">The model store.</param>
        /// <returns></returns>
        public static ParameterMap Deserialize(
            DataExchangeFactory dataExchangeFactory,
            IConfiguration config,
            IModelStore modelStore)
        {
            Type          type         = null;
            IDataExchange dataExchange = null;

            string id        = config.Id;
            string className = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_CLASS);
            string extendMap = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS);

            if (className.Length > 0)
            {
                type         = dataExchangeFactory.TypeHandlerFactory.GetType(className);
                dataExchange = dataExchangeFactory.GetDataExchangeForClass(type);
            }
            else
            {
                // Get the ComplexDataExchange
                dataExchange = dataExchangeFactory.GetDataExchangeForClass(dataExchangeFactory.TypeHandlerFactory.GetTypeAlias(className).Type);
            }

            return(new ParameterMap(
                       id,
                       className,
                       extendMap,
                       type,
                       dataExchange,
                       modelStore.SessionFactory.DataSource.DbProvider.UsePositionalParameters));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialize the resultMap from an xmlNode..
        /// </summary>
        /// <param name="configScope"></param>
        public void Initialize(ConfigurationScope configScope)
        {
            try
            {
                _class        = configScope.SqlMapper.TypeHandlerFactory.GetType(_className);
                _dataExchange = _dataExchangeFactory.GetDataExchangeForClass(_class);

                // Load the child node
                GetChildNode(configScope);

                // Verify that that each groupBy element correspond to a class member
                // of one of result property
                for (int i = 0; i < _groupByProperties.Count; i++)
                {
                    string memberName = GroupByPropertyNames[i];
                    if (!_properties.Contains(memberName))
                    {
                        throw new ConfigurationException(
                                  string.Format(
                                      "Could not configure ResultMap named \"{0}\". Check the groupBy attribute. Cause: there's no result property named \"{1}\".",
                                      _id, memberName));
                    }
                }
            }
            catch (Exception e)
            {
                throw new ConfigurationException(
                          string.Format("Could not configure ResultMap named \"{0}\", Cause: {1}", _id, e.Message)
                          , e);
            }
        }
Ejemplo n.º 9
0
        void IDataExchange.Connect(string connectionInfo)
        {
            InstanceContext instanceContext = OperationContext.Current.InstanceContext;
            callback = OperationContext.Current.GetCallbackChannel<IDataExchange>();
            ((IServiceChannel)callback).Faulted += new EventHandler(StreamServer_Faulted);
            duplexStream = new CompositeDuplexStream(inputStream, new StreamOverWriteDelegate((buf, off, count) =>
                           {
                               try
                               {
                                   if (((IServiceChannel)callback).State == CommunicationState.Opened)
                                   {
                                       callback.Write(new TransferBuffer(buf, off, count));
                                   }
                               }
                               catch
                               {
                                   try
                                   {
                                       duplexStream.Close();
                                       if (instanceContext.State == CommunicationState.Opened)
                                       {
                                           instanceContext.ReleaseServiceInstance();
                                       }
                                   }
                                   catch
                                   {
                                       // absorb all errors here.
                                   }
                                   throw;
                               }
                           }));

            ((StreamServerHost)OperationContext.Current.Host).AvailableStreams.EnqueueAndDispatch(new StreamConnection(duplexStream, connectionInfo));
        }
Ejemplo n.º 10
0
        void IDataExchange.Connect(string connectionInfo)
        {
            InstanceContext instanceContext = OperationContext.Current.InstanceContext;

            callback = OperationContext.Current.GetCallbackChannel <IDataExchange>();
            ((IServiceChannel)callback).Faulted += new EventHandler(StreamServer_Faulted);
            duplexStream = new CompositeDuplexStream(inputStream, new StreamOverWriteDelegate((buf, off, count) =>
            {
                try
                {
                    if (((IServiceChannel)callback).State == CommunicationState.Opened)
                    {
                        callback.Write(new TransferBuffer(buf, off, count));
                    }
                }
                catch
                {
                    try
                    {
                        duplexStream.Close();
                        if (instanceContext.State == CommunicationState.Opened)
                        {
                            instanceContext.ReleaseServiceInstance();
                        }
                    }
                    catch
                    {
                        // absorb all errors here.
                    }
                    throw;
                }
            }));

            ((StreamServerHost)OperationContext.Current.Host).AvailableStreams.EnqueueAndDispatch(new StreamConnection(duplexStream, connectionInfo));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultMap"/> class.
        /// </summary>
        /// <param name="id">Identifier used to identify the resultMap amongst the others.</param>
        /// <param name="className">The output class name of the resultMap.</param>
        /// <param name="extendMap">The extend result map bame.</param>
        /// <param name="groupBy">The groupBy properties</param>
        /// <param name="keyColumns">The key columns.</param>
        /// <param name="type">The result type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="objectFactory">The object factory.</param>
        /// <param name="typeHandlerFactory">The type handler factory.</param>
        /// <param name="properties">The properties.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="discriminator">The discriminator.</param>
        public ResultMap(
            string id,
            string className,
            string extendMap,
            string groupBy,
            string keyColumns,
            Type type,
            IDataExchange dataExchange,
            IFactory objectFactory,
            TypeHandlerFactory typeHandlerFactory,
            ResultPropertyCollection properties,
            ArgumentPropertyCollection parameters,
            Discriminator discriminator)
        {
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id in ResultMap constructor");
            Contract.Require.That(className, Is.Not.Null & Is.Not.Empty).When("retrieving argument className in ResultMap constructor");
            Contract.Require.That(type, Is.Not.Null).When("retrieving argument type in ResultMap constructor");
            Contract.Require.That(typeHandlerFactory, Is.Not.Null).When("retrieving argument typeHandlerFactory in ResultMap constructor");

            nullResultMap = new NullResultMap();

            this.id            = id;
            this.className     = className;
            this.extendMap     = extendMap;
            this.type          = type;
            this.dataExchange  = dataExchange;
            this.properties    = properties;
            this.parameters    = parameters;
            this.discriminator = discriminator;
            this.objectFactory = objectFactory;
            isSimpleType       = typeHandlerFactory.IsSimpleType(type);

            //对groupBy属性值的处理
            if (!string.IsNullOrEmpty(groupBy))
            {
                string[] props = groupBy.Split(',');
                for (int i = 0; i < props.Length; i++)
                {
                    string memberName = props[i].Trim();
                    groupByPropertyNames.Add(memberName);
                }
                //完成对groupByProperties的初始化
                InitializeGroupByProperties();
                CheckGroupBy();
            }
            //对keyColumns属性值的处理
            if (!string.IsNullOrEmpty(keyColumns))
            {
                string[] columns = keyColumns.Split(',');
                for (int i = 0; i < columns.Length; i++)
                {
                    string column = columns[i].Trim();
                    keyPropertyNames.Add(column);
                }

                InitializeKeysProperties();
                CheckKeysProperties();
            }
        }
 public DataExchangeFactory(IBatisNet.DataMapper.TypeHandlers.TypeHandlerFactory typeHandlerFactory, IObjectFactory objectFactory, IBatisNet.Common.Utilities.Objects.Members.AccessorFactory accessorFactory)
 {
     this._objectFactory          = objectFactory;
     this._typeHandlerFactory     = typeHandlerFactory;
     this._accessorFactory        = accessorFactory;
     this._primitiveDataExchange  = new PrimitiveDataExchange(this);
     this._complexDataExchange    = new ComplexDataExchange(this);
     this._listDataExchange       = new ListDataExchange(this);
     this._dictionaryDataExchange = new DictionaryDataExchange(this);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AutoResultMap"/> class.
        /// </summary>
        /// <param name="resultClass">The result class.</param>
        /// <param name="resultClassFactory">The result class factory.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="isSimpleType">if set to <c>true</c> [is simple type].</param>
        public AutoResultMap(Type resultClass, IFactory resultClassFactory, IDataExchange dataExchange, bool isSimpleType)
        {
            Contract.Require.That(resultClass, Is.Not.Null).When("retrieving argument resultClass in AutoResultMap constructor");
            Contract.Require.That(dataExchange, Is.Not.Null).When("retrieving argument dataExchange in AutoResultMap constructor");
            Contract.Require.That(dataExchange, Is.Not.Null).When("retrieving argument typeHandlerFactory in AutoResultMap constructor");

            this.resultClass        = resultClass;
            this.resultClassFactory = resultClassFactory;
            this.dataExchange       = dataExchange;
            this.isSimpleType       = isSimpleType;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AutoResultMap"/> class.
        /// </summary>
        /// <param name="resultClass">The result class.</param>
        /// <param name="resultClassFactory">The result class factory.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="isSimpleType">if set to <c>true</c> [is simple type].</param>
        public AutoResultMap(Type resultClass, IFactory resultClassFactory, IDataExchange dataExchange, bool isSimpleType)
        {
            Contract.Require.That(resultClass, Is.Not.Null).When("retrieving argument resultClass in AutoResultMap constructor");
            Contract.Require.That(dataExchange, Is.Not.Null).When("retrieving argument dataExchange in AutoResultMap constructor");
            Contract.Require.That(dataExchange, Is.Not.Null).When("retrieving argument typeHandlerFactory in AutoResultMap constructor");

            this.resultClass = resultClass;
            this.resultClassFactory = resultClassFactory;
            this.dataExchange = dataExchange;
            this.isSimpleType = isSimpleType;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataExchangeFactory"/> class.
        /// </summary>
        /// <param name="typeHandlerFactory">The type handler factory.</param>
        /// <param name="objectFactory">The object factory.</param>
        /// <param name="accessorFactory">The accessor factory.</param>
        public DataExchangeFactory(TypeHandlerFactory typeHandlerFactory,
                                   IObjectFactory objectFactory,
                                   AccessorFactory accessorFactory)
        {
            _objectFactory      = objectFactory;
            _typeHandlerFactory = typeHandlerFactory;
            _accessorFactory    = accessorFactory;

            _primitiveDataExchange  = new PrimitiveDataExchange(this);
            _complexDataExchange    = new ComplexDataExchange(this);
            _listDataExchange       = new ListDataExchange(this);
            _dictionaryDataExchange = new DictionaryDataExchange(this);
        }
Ejemplo n.º 16
0
 public void Initialize(bool usePositionalParameters, IScope scope)
 {
     this._usePositionalParameters = usePositionalParameters;
     if (this._className.Length > 0)
     {
         this._parameterClass = this._dataExchangeFactory.TypeHandlerFactory.GetType(this._className);
         this._dataExchange   = this._dataExchangeFactory.GetDataExchangeForClass(this._parameterClass);
     }
     else
     {
         this._dataExchange = this._dataExchangeFactory.GetDataExchangeForClass(null);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataExchangeFactory"/> class.
        /// </summary>
        /// <param name="typeHandlerFactory">The type handler factory.</param>
        /// <param name="objectFactory">The object factory.</param>
        /// <param name="accessorFactory">The accessor factory.</param>
        public DataExchangeFactory(TypeHandlerFactory typeHandlerFactory,
			IObjectFactory objectFactory,
            AccessorFactory accessorFactory)
        {
            _objectFactory = objectFactory;
            _typeHandlerFactory = typeHandlerFactory;
            _accessorFactory = accessorFactory;

            _primitiveDataExchange = new PrimitiveDataExchange(this);
            _complexDataExchange = new ComplexDataExchange(this);
            _listDataExchange = new ListDataExchange(this);
            _dictionaryDataExchange = new DictionaryDataExchange(this);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Initialize the parameter properties child.
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="usePositionalParameters"></param>
 public void Initialize(bool usePositionalParameters, IScope scope)
 {
     _usePositionalParameters = usePositionalParameters;
     if (_className.Length > 0)
     {
         _parameterClass = _dataExchangeFactory.TypeHandlerFactory.GetType(_className);
         _dataExchange   = _dataExchangeFactory.GetDataExchangeForClass(_parameterClass);
     }
     else
     {
         // Get the ComplexDataExchange
         _dataExchange = _dataExchangeFactory.GetDataExchangeForClass(null);
     }
 }
Ejemplo n.º 19
0
        public void testDataExchange()
        {
            IDataExchange gvService = ServiceContainer.CreateInstance().Resolve <IDataExchange>("DataExchangeService");
            //获取值
            string projectPath = gvService["ProjectPath"];

            //设置值

            //保存到文件
            MessageBox.Show(projectPath);
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                gvService["ProjectPath"] = fbd.SelectedPath;
                gvService.SaveToFile(null);
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Initialize an statement for the sqlMap.
 /// </summary>
 /// <param name="configurationScope">The scope of the configuration</param>
 internal virtual void Initialize(ConfigurationScope configurationScope)
 {
     if (_resultMapName.Length > 0)
     {
         string[] names = _resultMapName.Split(',');
         for (int i = 0; i < names.Length; i++)
         {
             string name = configurationScope.ApplyNamespace(names[i].Trim());
             _resultsMap.Add(configurationScope.SqlMapper.GetResultMap(name));
         }
     }
     if (_parameterMapName.Length > 0)
     {
         _parameterMap = configurationScope.SqlMapper.GetParameterMap(_parameterMapName);
     }
     if (_resultClassName.Length > 0)
     {
         string[] classNames = _resultClassName.Split(',');
         for (int i = 0; i < classNames.Length; i++)
         {
             _resultClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(classNames[i].Trim());
             IFactory resultClassFactory = null;
             if (Type.GetTypeCode(_resultClass) == TypeCode.Object &&
                 (_resultClass.IsValueType == false))
             {
                 resultClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(_resultClass, Type.EmptyTypes);
             }
             IDataExchange dataExchange = configurationScope.DataExchangeFactory.GetDataExchangeForClass(_resultClass);
             IResultMap    autoMap      = new AutoResultMap(_resultClass, resultClassFactory, dataExchange);
             _resultsMap.Add(autoMap);
         }
     }
     if (_parameterClassName.Length > 0)
     {
         _parameterClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(_parameterClassName);
     }
     if (_listClassName.Length > 0)
     {
         _listClass        = configurationScope.SqlMapper.TypeHandlerFactory.GetType(_listClassName);
         _listClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(_listClass, Type.EmptyTypes);
     }
 }
Ejemplo n.º 21
0
 internal virtual void Initialize(ConfigurationScope configurationScope)
 {
     if (this._resultMapName.Length > 0)
     {
         string[] strArray = this._resultMapName.Split(new char[] { ',' });
         for (int i = 0; i < strArray.Length; i++)
         {
             string name = configurationScope.ApplyNamespace(strArray[i].Trim());
             this._resultsMap.Add(configurationScope.SqlMapper.GetResultMap(name));
         }
     }
     if (this._parameterMapName.Length > 0)
     {
         this._parameterMap = configurationScope.SqlMapper.GetParameterMap(this._parameterMapName);
     }
     if (this._resultClassName.Length > 0)
     {
         string[] strArray2 = this._resultClassName.Split(new char[] { ',' });
         for (int j = 0; j < strArray2.Length; j++)
         {
             this._resultClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(strArray2[j].Trim());
             IFactory resultClassFactory = null;
             if ((Type.GetTypeCode(this._resultClass) == TypeCode.Object) && !this._resultClass.IsValueType)
             {
                 resultClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(this._resultClass, Type.EmptyTypes);
             }
             IDataExchange dataExchangeForClass = configurationScope.DataExchangeFactory.GetDataExchangeForClass(this._resultClass);
             IResultMap    map = new AutoResultMap(this._resultClass, resultClassFactory, dataExchangeForClass);
             this._resultsMap.Add(map);
         }
     }
     if (this._parameterClassName.Length > 0)
     {
         this._parameterClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(this._parameterClassName);
     }
     if (this._listClassName.Length > 0)
     {
         this._listClass        = configurationScope.SqlMapper.TypeHandlerFactory.GetType(this._listClassName);
         this._listClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(this._listClass, Type.EmptyTypes);
     }
 }
Ejemplo n.º 22
0
 public void Initialize(ConfigurationScope configScope)
 {
     try
     {
         this._class        = configScope.SqlMapper.TypeHandlerFactory.GetType(this._className);
         this._dataExchange = this._dataExchangeFactory.GetDataExchangeForClass(this._class);
         this.GetChildNode(configScope);
         for (int i = 0; i < this._groupByProperties.Count; i++)
         {
             string propertyName = this.GroupByPropertyNames[i];
             if (!this._properties.Contains(propertyName))
             {
                 throw new ConfigurationException(string.Format("Could not configure ResultMap named \"{0}\". Check the groupBy attribute. Cause: there's no result property named \"{1}\".", this._id, propertyName));
             }
         }
     }
     catch (Exception exception)
     {
         throw new ConfigurationException(string.Format("Could not configure ResultMap named \"{0}\", Cause: {1}", this._id, exception.Message), exception);
     }
 }
Ejemplo n.º 23
0
        public void Save(object o)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                IDataExchange gvService = ServiceContainer.CreateInstance().Resolve <IDataExchange>("DataExchangeService");
                gvService["ProjectPath"] = fbd.SelectedPath;
                string treepath = Path.Combine(gvService["ProjectPath"], treeSvaeName);
                string propPath = Path.Combine(gvService["ProjectPath"], prooertyName);
                string dataPath = Path.Combine(gvService["ProjectPath"], data);

                service.Invoke("panel11_SaveToFile", new object[1] {
                    treepath
                });


                service.Invoke("panel12_SaveToFile", new object[1] {
                    propPath
                });

                gvService.SaveToFile(dataPath);
            }
        }
Ejemplo n.º 24
0
        public void StartWork(IDataExchange dataSource, IDataExchange eventSource = null)
        {
            if (dataSource == null)
            {
                throw new ArgumentException("dataSupplier is null");
            }

            //_recevDataThread = new Thread(
            //    () =>
            //    {
            //        SerialPortController spRecv = new SerialPortController();
            //        while ()
            //    });

            _recvDataTask = new Task(() =>
            {
                while (!_cancellationRecvData.IsCancellationRequested)
                {
                    byte[] ret = dataSource.ReadBytes(100);
                }
            });

            if (eventSource != null)
            {
                _recvEventTask = new Task(() =>
                {
                    while (!_cancellationRecvEvent.IsCancellationRequested)
                    {
                        byte[] ret = eventSource.ReadBytes(100);
                    }
                }

                                          );
            }
            _recvDataTask.Start();
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Initialize the resultMap from an xmlNode..
        /// </summary>
        /// <param name="configScope"></param>
        public void Initialize( ConfigurationScope configScope )
        {
            try
            {
                _class = configScope.SqlMapper.TypeHandlerFactory.GetType(_className);
                _dataExchange = _dataExchangeFactory.GetDataExchangeForClass(_class);

                // Load the child node
                GetChildNode(configScope);

                 // Verify that that each groupBy element correspond to a class member
                 // of one of result property
                for (int i = 0; i < _groupByProperties.Count; i++)
                {
                    string memberName = GroupByPropertyNames[i];
                    if (!_properties.Contains(memberName))
                    {
                         throw new ConfigurationException(
                             string.Format(
                                 "Could not configure ResultMap named \"{0}\". Check the groupBy attribute. Cause: there's no result property named \"{1}\".",
                                 _id, memberName));
                    }
                }
            }
            catch(Exception e)
            {
                throw new ConfigurationException(
                    string.Format("Could not configure ResultMap named \"{0}\", Cause: {1}", _id, e.Message)
                    , e);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Deserializes the specified config.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="waitResultPropertyResolution">The wait result property resolution delegate.</param>
        /// <param name="waitDiscriminatorResolution">The wait discriminator resolution.</param>
        /// <returns></returns>
        public static ResultMap Deserialize(
            IConfiguration config,
            DataExchangeFactory dataExchangeFactory,
            WaitResultPropertyResolution waitResultPropertyResolution,
            WaitDiscriminatorResolution waitDiscriminatorResolution
            )
        {
            /*resultMaps子节点信息格式
             *   <resultMap id="account-result-constructor"  class="Account" >
             *      <constructor>
             *          <argument argumentName="identifiant"	column="Account_ID"/>
             *          <argument argumentName="firstName"    column="Account_FirstName"/>
             *          <argument argumentName="lastName"     column="Account_LastName"/>
             *   </constructor>
             *   <result property="EmailAddress" column="Account_Email" nullValue="*****@*****.**"/>
             *   <result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="bool"/>
             *   <result property="CartOption"	  column="Account_Cart_Option" typeHandler="HundredsBool"/>
             * </resultMap>
             */
            //从config中对应的resultMap节点获取其属性
            string id         = config.Id;
            string className  = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_CLASS);
            string extends    = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS);
            string groupBy    = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_GROUPBY);
            string keyColumns = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_KEYS_PROPERTIES);
            string suffix     = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SUFFIX, string.Empty);
            string prefix     = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PREFIX, string.Empty);

            //从工厂类的别名字典中获取
            Type type = dataExchangeFactory.TypeHandlerFactory.GetType(className);
            //根据type类型获取IDataExchange类对象
            IDataExchange dataExchange = dataExchangeFactory.GetDataExchangeForClass(type);
            IFactory      factory      = null;
            //准备存储构造函数参数argument节点信息
            ArgumentPropertyCollection arguments = new ArgumentPropertyCollection();

            #region Get the constructor & associated parameters

            //获取config下节点构造函数constructor的集合
            ConfigurationCollection constructors = config.Children.Find(ConfigConstants.ELEMENT_CONSTRUCTOR);

            if (constructors.Count > 0)
            {
                //默认获取第一个构造函数constructor节点  因为是初始化一个类  一个构造函数就足够了
                IConfiguration constructor = constructors[0];

                Type[]   argumentsType = new Type[constructor.Children.Count];
                string[] argumentsName = new string[constructor.Children.Count];

                // Builds param name list
                //argument节点的个数
                for (int i = 0; i < constructor.Children.Count; i++)
                {
                    //argumentName属性的取值
                    argumentsName[i] = ConfigurationUtils.GetStringAttribute(constructor.Children[i].Attributes, ConfigConstants.ATTRIBUTE_ARGUMENTNAME);
                }

                // Find the constructor  匹配构造函数
                ConstructorInfo constructorInfo = GetConstructor(id, type, argumentsName);

                // Build ArgumentProperty and parameter type list
                //处理构造函数的参数 每一个参数添加到arguments参数列表中
                for (int i = 0; i < constructor.Children.Count; i++)
                {
                    ArgumentProperty argumentMapping = ArgumentPropertyDeSerializer.Deserialize(
                        constructor.Children[i], //第i个Argument节点配置类
                        type,                    //当前构造函数的类
                        constructorInfo,         //当前构造函数的信息
                        dataExchangeFactory);

                    arguments.Add(argumentMapping);

                    //此处NestedResultMapName字符串应该为空
                    if (argumentMapping.NestedResultMapName.Length > 0)
                    {
                        waitResultPropertyResolution(argumentMapping);
                    }
                    //保存当前参数的类型
                    argumentsType[i] = argumentMapping.MemberType;
                }
                // Init the object factory
                //构造函数参数信息分析完成   动态初始化这个构造函数
                factory = dataExchangeFactory.ObjectFactory.CreateFactory(type, argumentsType);
            }
            else
            {
                if (!dataExchangeFactory.TypeHandlerFactory.IsSimpleType(type) && type != typeof(DataRow))
                {
                    factory = dataExchangeFactory.ObjectFactory.CreateFactory(type, Type.EmptyTypes);
                }
            }

            #endregion

            //处理result所有节点
            ResultPropertyCollection properties = BuildResultProperties(
                id,
                config,
                type,
                prefix,
                suffix,
                dataExchangeFactory,
                waitResultPropertyResolution);
            //对discriminator鉴别器的分析
            Discriminator discriminator = BuildDiscriminator(config, type, dataExchangeFactory, waitDiscriminatorResolution);

            //子节点分析完毕 将这些信息加入到resultMap父节点中
            ResultMap resultMap = new ResultMap(
                id,
                className,
                extends,
                groupBy,
                keyColumns,
                type,
                dataExchange,
                factory,
                dataExchangeFactory.TypeHandlerFactory,
                properties,
                arguments,
                discriminator
                );

            return(resultMap);
        }
Ejemplo n.º 27
0
 public DataListener()
 {
     _dataExchange = IoC.Resolve <IDataExchange>(new ConstructorArgument("mineConfig", IoC.Resolve <MineConfig>()));
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Build inline paremeterMap
        /// </summary>
        /// <param name="statement">The statement.</param>
        /// <param name="sqlCommandText">The SQL command text.</param>
        /// <param name="newSqlCommandText">The newsql command text.</param>
        /// <returns></returns>
        public ParameterMap BuildInlineParemeterMap(IStatement statement, string sqlCommandText, out string newSqlCommandText)
        {
            newSqlCommandText = sqlCommandText;
            ParameterMap map = null;

            // Check the inline parameter
            if (statement.ParameterMap == null)
            {
                // Build a Parametermap with the inline parameters.
                // if they exist. Then delete inline infos from sqltext.

                SqlText sqlText = InlineParameterMapParser.ParseInlineParameterMap(modelStore.DataExchangeFactory, statement.Id, statement, newSqlCommandText);

                if (sqlText.Parameters.Length > 0)
                {
                    string        id           = statement.Id + "-InLineParameterMap";
                    string        className    = string.Empty;
                    Type          classType    = null;
                    IDataExchange dataExchange = null;

                    if (statement.ParameterClass != null)
                    {
                        className = statement.ParameterClass.Name;
                        classType = statement.ParameterClass;
                        //dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(classType);
                    }

                    if (statement.ParameterClass == null &&
                        sqlText.Parameters.Length == 1 && sqlText.Parameters[0].PropertyName == "value")    //#value# parameter with no parameterClass attribut
                    {
                        dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(typeof(int)); //Get the primitiveDataExchange
                    }
                    else
                    {
                        dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(statement.ParameterClass);
                    }

                    map = new ParameterMap(
                        id,
                        className,
                        string.Empty,
                        classType,
                        dataExchange,
                        modelStore.SessionFactory.DataSource.DbProvider.UsePositionalParameters
                        )
                    ;
                    int lenght = sqlText.Parameters.Length;
                    for (int index = 0; index < lenght; index++)
                    {
                        map.AddParameterProperty(sqlText.Parameters[index]);
                    }
                }
                newSqlCommandText = sqlText.Text;
            }

            if (statement is Procedure)
            {
                newSqlCommandText = newSqlCommandText.Replace(MARK_TOKEN, string.Empty).Replace(COMMA_TOKEN, string.Empty);
            }
            // newSqlCommandText = newSqlCommandText.Trim();

            return(map);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Deserializes the specified configuration in a Statement object.
        /// </summary>
        /// <param name="modelStore"></param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting">Default settings.</param>
        /// <returns></returns>
        /// <remarks>
        /// Updated By: Richard Beacroft
        /// Updated Date: 11\10\2013
        /// Description: configurationSetting can be null and therefore references to it have to assume that it could be null.
        /// </remarks>
        protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            // DefaultModelBuilderTest.Test_DefaultModelBuilder assumes that configurationSetting can be null - added code accordingly.
            // Typically, no public method should allow null to be passed-in, best handled by overloading method to exclude parameter, or in .NET 4, use optional parameter.
            var  preserveWhitespace     = (configurationSetting == null) ? false : configurationSetting.PreserveWhitespace;
            bool useStatementNamespaces = (configurationSetting == null) ? false : configurationSetting.UseStatementNamespaces;

            nameSpace          = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE);
            id                 = useStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id;
            cacheModelName     = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL);
            extendsName        = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS);
            listClassName      = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS);
            parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS);
            parameterMapName   = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP);
            resultClassName    = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS);
            resultMapName      = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP);
            remapResults       = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false);
            sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE);
            preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, preserveWhitespace);

            // Gets the results Map
            if (resultMapName.Length > 0)
            {
                string[] ids = resultMapName.Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    string name = ApplyNamespace(nameSpace, ids[i].Trim());
                    resultsMap.Add(modelStore.GetResultMap(name));
                }
            }

            // Gets the results class
            if (resultClassName.Length > 0)
            {
                string[] classNames = resultClassName.Split(',');
                for (int i = 0; i < classNames.Length; i++)
                {
                    resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim());
                    IFactory resultClassFactory = null;
                    if (Type.GetTypeCode(resultClass) == TypeCode.Object &&
                        (resultClass.IsValueType == false) && resultClass != typeof(DataRow))
                    {
                        resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes);
                    }
                    IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass);
                    bool          isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass);
                    IResultMap    autoMap      = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType);
                    resultsMap.Add(autoMap);
                }
            }

            // Gets the ParameterMap
            if (parameterMapName.Length > 0)
            {
                parameterMap = modelStore.GetParameterMap(parameterMapName);
            }

            // Gets the ParameterClass
            if (parameterClassName.Length > 0)
            {
                parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName);
            }

            // Gets the listClass
            if (listClassName.Length > 0)
            {
                listClass        = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName);
                listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes);
            }

            // Gets the CacheModel
            if (cacheModelName.Length > 0)
            {
                cacheModel = modelStore.GetCacheModel(cacheModelName);
            }

            // Gets the SqlSource
            if (sqlSourceClassName.Length > 0)
            {
                Type     sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName);
                IFactory factory       = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes);
                sqlSource = (ISqlSource)factory.CreateInstance(null);
            }
        }
        /// <summary>
        /// Deserializes the specified config.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="waitResultPropertyResolution">The wait result property resolution delegate.</param>
        /// <param name="waitDiscriminatorResolution">The wait discriminator resolution.</param>
        /// <returns></returns>
        public static ResultMap Deserialize(
            IConfiguration config,
            DataExchangeFactory dataExchangeFactory,
            WaitResultPropertyResolution waitResultPropertyResolution,
            WaitDiscriminatorResolution waitDiscriminatorResolution
            )
        {
            string id         = config.Id;
            string className  = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_CLASS);
            string extends    = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS);
            string groupBy    = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_GROUPBY);
            string keyColumns = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_KEYS_PROPERTIES);
            string suffix     = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SUFFIX, string.Empty);
            string prefix     = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PREFIX, string.Empty);

            Type          type                   = dataExchangeFactory.TypeHandlerFactory.GetType(className);
            IDataExchange dataExchange           = dataExchangeFactory.GetDataExchangeForClass(type);
            IFactory      factory                = null;
            ArgumentPropertyCollection arguments = new ArgumentPropertyCollection();

            #region Get the constructor & associated parameters

            ConfigurationCollection constructors = config.Children.Find(ConfigConstants.ELEMENT_CONSTRUCTOR);

            if (constructors.Count > 0)
            {
                IConfiguration constructor = constructors[0];

                Type[]   argumentsType = new Type[constructor.Children.Count];
                string[] argumentsName = new string[constructor.Children.Count];

                // Builds param name list
                for (int i = 0; i < constructor.Children.Count; i++)
                {
                    argumentsName[i] = ConfigurationUtils.GetStringAttribute(constructor.Children[i].Attributes, ConfigConstants.ATTRIBUTE_ARGUMENTNAME);
                }

                // Find the constructor
                ConstructorInfo constructorInfo = GetConstructor(id, type, argumentsName);

                // Build ArgumentProperty and parameter type list
                for (int i = 0; i < constructor.Children.Count; i++)
                {
                    ArgumentProperty argumentMapping = ArgumentPropertyDeSerializer.Deserialize(
                        constructor.Children[i],
                        type,
                        constructorInfo,
                        dataExchangeFactory);

                    arguments.Add(argumentMapping);

                    if (argumentMapping.NestedResultMapName.Length > 0)
                    {
                        waitResultPropertyResolution(argumentMapping);
                    }

                    argumentsType[i] = argumentMapping.MemberType;
                }
                // Init the object factory
                factory = dataExchangeFactory.ObjectFactory.CreateFactory(type, argumentsType);
            }
            else
            {
                if (!dataExchangeFactory.TypeHandlerFactory.IsSimpleType(type) && type != typeof(DataRow))
                {
                    factory = dataExchangeFactory.ObjectFactory.CreateFactory(type, Type.EmptyTypes);
                }
            }

            #endregion

            ResultPropertyCollection properties = BuildResultProperties(
                id,
                config,
                type,
                prefix,
                suffix,
                dataExchangeFactory,
                waitResultPropertyResolution);
            Discriminator discriminator = BuildDiscriminator(config, type, dataExchangeFactory, waitDiscriminatorResolution);

            ResultMap resultMap = new ResultMap(
                id,
                className,
                extends,
                groupBy,
                keyColumns,
                type,
                dataExchange,
                factory,
                dataExchangeFactory.TypeHandlerFactory,
                properties,
                arguments,
                discriminator
                );

            return(resultMap);
        }
Ejemplo n.º 31
0
 public StreamServer()
 {
     this.callback = null;
     this.inputStream = new ThrottledQueueBufferedStream(5);
 }
Ejemplo n.º 32
0
 public void GetDataFrom(IDataExchange source)
 {
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultMap"/> class.
        /// </summary>
        /// <param name="id">Identifier used to identify the resultMap amongst the others.</param>
        /// <param name="className">The output class name of the resultMap.</param>
        /// <param name="extendMap">The extend result map bame.</param>
        /// <param name="groupBy">The groupBy properties</param>
        /// <param name="keyColumns">The key columns.</param>
        /// <param name="type">The result type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="objectFactory">The object factory.</param>
        /// <param name="typeHandlerFactory">The type handler factory.</param>
        /// <param name="properties">The properties.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="discriminator">The discriminator.</param>
        public ResultMap(
            string id, 
            string className, 
            string extendMap, 
            string groupBy,
            string keyColumns,
            Type type,
            IDataExchange dataExchange,
            IFactory objectFactory,
            TypeHandlerFactory typeHandlerFactory,
            ResultPropertyCollection properties,
            ArgumentPropertyCollection parameters,
            Discriminator discriminator)
        {
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id in ResultMap constructor");
            Contract.Require.That(className, Is.Not.Null & Is.Not.Empty).When("retrieving argument className in ResultMap constructor");
            Contract.Require.That(type, Is.Not.Null).When("retrieving argument type in ResultMap constructor");
            Contract.Require.That(typeHandlerFactory, Is.Not.Null).When("retrieving argument typeHandlerFactory in ResultMap constructor");

            nullResultMap = new NullResultMap();

            this.id = id;
            this.className = className;
            this.extendMap = extendMap;
            this.type = type;
            this.dataExchange = dataExchange;
            this.properties = properties;
            this.parameters = parameters;
            this.discriminator = discriminator;
            this.objectFactory = objectFactory;
            isSimpleType = typeHandlerFactory.IsSimpleType(type);

            if (!string.IsNullOrEmpty(groupBy))
            {
                string[] props = groupBy.Split(',');
                for (int i = 0; i < props.Length; i++)
                {
                    string memberName = props[i].Trim();
                    groupByPropertyNames.Add(memberName);
                }

                InitializeGroupByProperties();
                CheckGroupBy();
            }

            if (!string.IsNullOrEmpty(keyColumns))
            {
                string[] columns = keyColumns.Split(',');
                for (int i = 0; i < columns.Length; i++)
                {
                    string column = columns[i].Trim();
                    keyPropertyNames.Add(column);
                }

                InitializeKeysProperties();
                CheckKeysProperties();
            }

       }
Ejemplo n.º 34
0
 /// <summary>
 /// Initialize the parameter properties child.
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="usePositionalParameters"></param>
 public void Initialize(bool usePositionalParameters, IScope scope)
 {
     _usePositionalParameters = usePositionalParameters;
     if (_className.Length>0 )
     {
         _parameterClass = _dataExchangeFactory.TypeHandlerFactory.GetType(_className);
         _dataExchange = _dataExchangeFactory.GetDataExchangeForClass(_parameterClass);
     }
     else
     {
         // Get the ComplexDataExchange
         _dataExchange = _dataExchangeFactory.GetDataExchangeForClass(null);
     }
 }
Ejemplo n.º 35
0
 public StreamServer()
 {
     this.callback    = null;
     this.inputStream = new ThrottledQueueBufferedStream(5);
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AutoResultMap"/> class.
 /// </summary>
 /// <param name="resultClass">The result class.</param>
 /// <param name="resultClassFactory">The result class factory.</param>
 /// <param name="dataExchange">The data exchange.</param>
 public AutoResultMap(Type resultClass, IFactory resultClassFactory, IDataExchange dataExchange)
 {
     _resultClass        = resultClass;
     _resultClassFactory = resultClassFactory;
     _dataExchange       = dataExchange;
 }
Ejemplo n.º 37
0
 public void BindDevice(IDataExchange device)
 {
     _device = device;
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterMap"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="className">Name of the class.</param>
        /// <param name="extendMap">The extend map.</param>
        /// <param name="type">The type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="usePositionalParameters">if set to <c>true</c> [use positional parameters].</param>
 		public ParameterMap(
            string id,
            string className,
            string extendMap,
            Type type,
            IDataExchange dataExchange,
            bool usePositionalParameters)
		{
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id");
            //Contract.Require.That(className, Is.Not.Null & Is.Not.Empty).When("retrieving argument className");

            if (logger.IsInfoEnabled)
            {
                if ((className == null) || (className.Length < 1))
                {
                    logger.Info("The class attribute is recommended for better performance in a ParameterMap tag '" + id + "'.");
                }
            }

            this.id = id;
            this.className = className;
            this.usePositionalParameters = usePositionalParameters;
            this.parameterClass = type;
            this.dataExchange = dataExchange;
            this.extendMap = extendMap;
		}
Ejemplo n.º 39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AutoResultMap"/> class.
 /// </summary>
 /// <param name="resultClass">The result class.</param>
 /// <param name="resultClassFactory">The result class factory.</param>
 /// <param name="dataExchange">The data exchange.</param>
 public AutoResultMap(Type resultClass, IFactory resultClassFactory, IDataExchange dataExchange)
 {
     _resultClass = resultClass;
     _resultClassFactory = resultClassFactory;
     _dataExchange = dataExchange;
 }
Ejemplo n.º 40
0
        /// <summary>
        /// Deserializes the specified configuration in a Statement object.
        /// </summary>
        /// <param name="modelStore"></param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting">Default settings.</param>
        /// <returns></returns>
        protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            nameSpace          = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE);
            id                 = configurationSetting.UseStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id;
            cacheModelName     = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL);
            extendsName        = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS);
            listClassName      = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS);
            parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS);
            parameterMapName   = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP);
            resultClassName    = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS);
            resultMapName      = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP);
            remapResults       = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false);
            sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE);
            preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace);

            // Gets the results Map
            if (resultMapName.Length > 0)
            {
                string[] ids = resultMapName.Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    string name = ApplyNamespace(nameSpace, ids[i].Trim());
                    resultsMap.Add(modelStore.GetResultMap(name));
                }
            }
            // Gets the results class
            if (resultClassName.Length > 0)
            {
                string[] classNames = resultClassName.Split(',');
                for (int i = 0; i < classNames.Length; i++)
                {
                    resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim());
                    IFactory resultClassFactory = null;
                    if (Type.GetTypeCode(resultClass) == TypeCode.Object &&
                        (resultClass.IsValueType == false) && resultClass != typeof(DataRow))
                    {
                        resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes);
                    }
                    IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass);
                    bool          isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass);
                    IResultMap    autoMap      = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType);
                    resultsMap.Add(autoMap);
                }
            }

            // Gets the ParameterMap
            if (parameterMapName.Length > 0)
            {
                parameterMap = modelStore.GetParameterMap(parameterMapName);
            }
            // Gets the ParameterClass
            if (parameterClassName.Length > 0)
            {
                parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName);
            }

            // Gets the listClass
            if (listClassName.Length > 0)
            {
                listClass        = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName);
                listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes);
            }

            // Gets the CacheModel
            if (cacheModelName.Length > 0)
            {
                cacheModel = modelStore.GetCacheModel(cacheModelName);
            }
            // Gets the SqlSource
            if (sqlSourceClassName.Length > 0)
            {
                Type     sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName);
                IFactory factory       = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes);
                sqlSource = (ISqlSource)factory.CreateInstance(null);
            }
        }