当前位置: 首页>>代码示例>>C#>>正文


C# Connection.Reset方法代码示例

本文整理汇总了C#中Connection.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Reset方法的具体用法?C# Connection.Reset怎么用?C# Connection.Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.Reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryPush

        public bool TryPush(Connection connection)
        {
            #if DEBUG
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (connection.SendQueue.Count > 0)
            {
                //TODO: Error
                return false;
            }
            #endif

            connection.Reset();

            lock (pool)
            {
                pool.Push(connection);
            }

            return true;
        }
开发者ID:HiWill,项目名称:SlimIOCP,代码行数:24,代码来源:ConnectionPool.cs

示例2: DereferenceConnectionAttribute

        // dereferences <ftp connection="fromRefID" /> and sets up the
        // internal Connection object accordingly.
        protected void DereferenceConnectionAttribute(string fromRefID)
        {
            _connection.RefID = fromRefID;

            // the following code block was modified from
            // from NAnt.Core\Element.cs:line 1247 {v0.85-rc1)
            if (Project.DataTypeReferences.Contains(_connection.RefID)
                && Project.DataTypeReferences[_connection.RefID] is Connection) {
                _connection = (Connection)Project.DataTypeReferences[_connection.RefID];
                // clear any instance specific state
                _connection.Reset();
            } else {

                //_connection = new Connection();

                // try to load the password from the file
                if (!_connection.LoadPasswords(_connection.RefID)) {

                    // reference not found exception
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                        "Connection '{0}' is not defined in the current project.", _connection.RefID),
                        this.Location);
                }
            }
        }
开发者ID:davidalpert,项目名称:NAntFTPTask,代码行数:27,代码来源:ftptask.cs

示例3: _UpdateStructure


//.........这里部分代码省略.........
            foreach (Trigger trig in createTriggers)
            {
                alterations.Add(conn.queryBuilder.CreateTrigger(trig));
            }
            alterations.Add(_COMMIT_STRING);

            foreach (IdentityField idf in createIdentities)
                alterations.Add(conn.queryBuilder.CreateIdentityField(idf));
            alterations.Add(_COMMIT_STRING);

            foreach (IdentityField idf in setIdentities)
                alterations.Add(conn.queryBuilder.SetIdentityFieldValue(idf));
            alterations.Add(_COMMIT_STRING);

            for (int x = 0; x < alterations.Count; x++)
            {
                if (alterations[x].Contains(";ALTER")&&!alterations[x].StartsWith("CREATE TRIGGER")
                    && !alterations[x].StartsWith("ALTER TRIGGER"))
                {
                    string tmp = alterations[x];
                    alterations.RemoveAt(x);
                    alterations.Insert(x, tmp.Substring(0, tmp.IndexOf(";ALTER") + 1));
                    alterations.Insert(x + 1, tmp.Substring(tmp.IndexOf(";ALTER") + 1));
                }
                else if (alterations[x].Contains(";\nALTER") && !alterations[x].StartsWith("CREATE TRIGGER")
                    && !alterations[x].StartsWith("ALTER TRIGGER"))
                {
                    string tmp = alterations[x];
                    alterations.RemoveAt(x);
                    alterations.Insert(x, tmp.Substring(0, tmp.IndexOf(";\nALTER") + 1));
                    alterations.Insert(x + 1, tmp.Substring(tmp.IndexOf(";\nALTER") + 1));
                }
                if (alterations[x].StartsWith("ALTER") && !alterations[x].TrimEnd(new char[] { '\n', ' ', '\t' }).EndsWith(";"))
                {
                    alterations[x] = alterations[x] + ";";
                }
            }

            Utility.RemoveDuplicateStrings(ref alterations, new string[] { _COMMIT_STRING });
            for (int x = 0; x < alterations.Count; x++)
            {
                if (x + 1 < alterations.Count)
                {
                    if (alterations[x + 1].Trim() == alterations[x].Trim() && alterations[x].Trim() == "COMMIT;")
                    {
                        alterations.RemoveAt(x);
                        x--;
                    }
                }
            }

            if (!Utility.OnlyContains(alterations,new string[]{_COMMIT_STRING}))
            {
                if (alterations[0].Trim() == _COMMIT_STRING)
                    alterations.RemoveAt(0);
                try
                {
                    if (_pool.DebugMode)
                    {
                        foreach (string str in alterations)
                        {
                            if (!str.EndsWith(";"))
                                Logger.LogLine(str + ";");
                            else
                                Logger.LogLine(str);
                        }
                    }
                    else
                    {
                        foreach (string str in alterations)
                        {
                            if (str.Length > 0)
                            {
                                if (str == _COMMIT_STRING)
                                    conn.Commit();
                                else if (str.EndsWith(_COMMIT_STRING))
                                {
                                    conn.ExecuteNonQuery(str.Substring(0, str.Length - 8));
                                    conn.Commit();
                                }
                                else
                                    conn.ExecuteNonQuery(str);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.LogLine(e.Message);
                    Logger.LogLine(e.StackTrace);
                    throw e;
                }
            }
            conn.Commit();
            conn.Reset();
            _pool.Translator.ApplyAllDescriptions(tables, triggers, generators, identities, views, procedures,conn);
            conn.Commit();

            return ret;
        }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:101,代码来源:StructureUpdater.cs


注:本文中的Connection.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。