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


C# ExtensionType.GetHashCode方法代码示例

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


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

示例1: SaveToDataStore

        /// <summary>
        /// Save to DataStore
        /// </summary>
        /// <param name="exType">type of info</param>
        /// <param name="exId">id of info</param>
        /// <param name="settings">data of info</param>
        public override void SaveToDataStore(ExtensionType exType, string exId, object settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            // Save
            string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString;
            string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName;
            DbProviderFactory provider = DbProviderFactories.GetFactory(providerName);

            XmlSerializer xs = new XmlSerializer(settings.GetType());
            string objectXML = string.Empty;
            using (StringWriter sw = new StringWriter())
            {
              xs.Serialize(sw, settings);
              objectXML = sw.ToString();
            }

            using (DbConnection conn = provider.CreateConnection())
            {
                conn.ConnectionString = connString;
                conn.Open();
                using (DbCommand cmd = conn.CreateCommand())
                {
                    string sqlQuery = "DELETE FROM " + tablePrefix + "DataStoreSettings " +
                                      "WHERE ExtensionType = @type AND ExtensionId = @id; ";

                    if (parmPrefix != "@")
                        sqlQuery = sqlQuery.Replace("@", parmPrefix);
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    DbParameter dpID = provider.CreateParameter();
                    dpID.ParameterName = parmPrefix + "type";
                    dpID.Value = exType.GetHashCode();
                    cmd.Parameters.Add(dpID);
                    DbParameter dpType = provider.CreateParameter();
                    dpType.ParameterName = parmPrefix + "id";
                    dpType.Value = exId;
                    cmd.Parameters.Add(dpType);

                    cmd.ExecuteNonQuery();

                    sqlQuery = "INSERT INTO " + tablePrefix + "DataStoreSettings " +
                        "(ExtensionType, ExtensionId, Settings) " +
                        "VALUES (@type, @id, @file)";
                    if (parmPrefix != "@")
                        sqlQuery = sqlQuery.Replace("@", parmPrefix);
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    DbParameter dpFile = provider.CreateParameter();
                    dpFile.ParameterName = parmPrefix + "file";
                    dpFile.Value = objectXML; // settings.ToString(); // file;
                    cmd.Parameters.Add(dpFile);

                    cmd.ExecuteNonQuery();
                }
            }
        }
开发者ID:rajgit31,项目名称:RajBlog,代码行数:66,代码来源:DbBlogProvider.cs

示例2: LoadFromDataStore

        /// <summary>
        /// Load user data from DataStore
        /// </summary>
        /// <param name="exType">type of info</param>
        /// <param name="exId">id of info</param>
        /// <returns>stream of detail data</returns>
        public override object LoadFromDataStore(ExtensionType exType, string exId)
        {
            //MemoryStream stream;
            object o = null;
            string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString;
            string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName;
            DbProviderFactory provider = DbProviderFactories.GetFactory(providerName);

            using (DbConnection conn = provider.CreateConnection())
            {
                conn.ConnectionString = connString;

                using (DbCommand cmd = conn.CreateCommand())
                {
                    string sqlQuery = "SELECT Settings FROM " + tablePrefix + "DataStoreSettings " +
                                        "WHERE ExtensionType = " + parmPrefix + "etype AND ExtensionId = " + parmPrefix + "eid";
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;
                    conn.Open();

                    DbParameter dpeType = provider.CreateParameter();
                    dpeType.ParameterName = parmPrefix + "etype";
                    dpeType.Value = exType.GetHashCode();
                    cmd.Parameters.Add(dpeType);
                    DbParameter dpeId = provider.CreateParameter();
                    dpeId.ParameterName = parmPrefix + "eid";
                    dpeId.Value = exId;
                    cmd.Parameters.Add(dpeId);

                    o = cmd.ExecuteScalar();
                }
            }
            return o;
        }
开发者ID:rajgit31,项目名称:RajBlog,代码行数:40,代码来源:DbBlogProvider.cs

示例3: LoadFromDataStore

        /// <summary>
        /// Load user data from DataStore
        /// </summary>
        /// <param name="extensionType">
        /// type of info
        /// </param>
        /// <param name="extensionId">
        /// id of info
        /// </param>
        /// <returns>
        /// stream of detail data
        /// </returns>
        public override object LoadFromDataStore(ExtensionType extensionType, string extensionId)
        {
            // MemoryStream stream;
            object o = null;

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("SELECT Settings FROM {0}DataStoreSettings WHERE BlogId = {1}blogid AND ExtensionType = {1}etype AND ExtensionId = {1}eid", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {

                        var parms = cmd.Parameters;
                        parms.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
                        parms.Add(conn.CreateParameter(FormatParamName("etype"), extensionType.GetHashCode()));
                        parms.Add(conn.CreateParameter(FormatParamName("eid"), extensionId));

                        o = cmd.ExecuteScalar();
                    }
                }
            }

            return o;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:37,代码来源:DbBlogProvider.cs

示例4: SaveToDataStore

        /// <summary>
        /// Save to DataStore
        /// </summary>
        /// <param name="extensionType">
        /// type of info
        /// </param>
        /// <param name="extensionId">
        /// id of info
        /// </param>
        /// <param name="settings">
        /// data of info
        /// </param>
        public override void SaveToDataStore(ExtensionType extensionType, string extensionId, object settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            // Save

            var xs = new XmlSerializer(settings.GetType());
            string objectXml;
            using (var sw = new StringWriter())
            {
                xs.Serialize(sw, settings);
                objectXml = sw.ToString();
            }

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("DELETE FROM {0}DataStoreSettings WHERE BlogId = {1}blogid AND ExtensionType = {1}type AND ExtensionId = {1}id; ", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {

                        var p = cmd.Parameters;

                        p.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
                        p.Add(conn.CreateParameter(FormatParamName("type"), extensionType.GetHashCode()));
                        p.Add(conn.CreateParameter(FormatParamName("id"), extensionId));

                        cmd.ExecuteNonQuery();

                        cmd.CommandText = string.Format("INSERT INTO {0}DataStoreSettings (BlogId, ExtensionType, ExtensionId, Settings) VALUES ({1}blogid, {1}type, {1}id, {1}file)", this.tablePrefix, this.parmPrefix);

                        p.Add(conn.CreateParameter(FormatParamName("file"), objectXml));

                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:55,代码来源:DbBlogProvider.cs

示例5: RemoveFromDataStore

        /// <summary>
        /// Deletes an item from the dataStore
        /// </summary>
        /// <param name="extensionType">
        /// type of item
        /// </param>
        /// <param name="extensionId">
        /// id of item
        /// </param>
        public override void RemoveFromDataStore(ExtensionType extensionType, string extensionId)
        {
            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("DELETE FROM {0}DataStoreSettings WHERE BlogId = {1}blogId AND ExtensionType = {1}type AND ExtensionId = {1}id", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {

                        var p = cmd.Parameters;
                        p.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
                        p.Add(conn.CreateParameter(FormatParamName("type"), extensionType.GetHashCode()));
                        p.Add(conn.CreateParameter(FormatParamName("id"), extensionId));

                        cmd.ExecuteNonQuery();
                    }

                }
            }
        }
开发者ID:CharlesZHENG,项目名称:BlogEngine.NET,代码行数:30,代码来源:DbBlogProvider.cs

示例6: SaveToDataStore

        /// <summary>
        /// Save to DataStore
        /// </summary>
        /// <param name="extensionType">
        /// type of info
        /// </param>
        /// <param name="extensionId">
        /// id of info
        /// </param>
        /// <param name="settings">
        /// data of info
        /// </param>
        public override void SaveToDataStore(ExtensionType extensionType, string extensionId, object settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            // Save
            var connString = ConfigurationManager.ConnectionStrings[this.connStringName].ConnectionString;
            var providerName = ConfigurationManager.ConnectionStrings[this.connStringName].ProviderName;
            var provider = DbProviderFactories.GetFactory(providerName);

            var xs = new XmlSerializer(settings.GetType());
            string objectXml;
            using (var sw = new StringWriter())
            {
                xs.Serialize(sw, settings);
                objectXml = sw.ToString();
            }

            using (var conn = provider.CreateConnection())
            {
                if (conn == null)
                {
                    return;
                }

                conn.ConnectionString = connString;
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    var sqlQuery = string.Format("DELETE FROM {0}DataStoreSettings WHERE ExtensionType = @type AND ExtensionId = @id; ", this.tablePrefix);

                    if (this.parmPrefix != "@")
                    {
                        sqlQuery = sqlQuery.Replace("@", this.parmPrefix);
                    }

                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    var id = provider.CreateParameter();
                    if (id != null)
                    {
                        id.ParameterName = string.Format("{0}type", this.parmPrefix);
                        id.Value = extensionType.GetHashCode();
                        cmd.Parameters.Add(id);
                    }

                    var type = provider.CreateParameter();
                    if (type != null)
                    {
                        type.ParameterName = string.Format("{0}id", this.parmPrefix);
                        type.Value = extensionId;
                        cmd.Parameters.Add(type);
                    }

                    cmd.ExecuteNonQuery();

                    sqlQuery = string.Format("INSERT INTO {0}DataStoreSettings (ExtensionType, ExtensionId, Settings) VALUES (@type, @id, @file)", this.tablePrefix);
                    if (this.parmPrefix != "@")
                    {
                        sqlQuery = sqlQuery.Replace("@", this.parmPrefix);
                    }

                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    var fileDp = provider.CreateParameter();
                    if (fileDp != null)
                    {
                        fileDp.ParameterName = string.Format("{0}file", this.parmPrefix);
                        fileDp.Value = objectXml; // settings.ToString(); // file;
                        cmd.Parameters.Add(fileDp);
                    }

                    cmd.ExecuteNonQuery();
                }
            }
        }
开发者ID:karanbhasin,项目名称:blogEngine.Common,代码行数:92,代码来源:DbBlogProvider.cs

示例7: LoadFromDataStore

        /// <summary>
        /// Load user data from DataStore
        /// </summary>
        /// <param name="extensionType">
        /// type of info
        /// </param>
        /// <param name="extensionId">
        /// id of info
        /// </param>
        /// <returns>
        /// stream of detail data
        /// </returns>
        public override object LoadFromDataStore(ExtensionType extensionType, string extensionId)
        {
            // MemoryStream stream;
            object o = null;
            var connString = ConfigurationManager.ConnectionStrings[this.connStringName].ConnectionString;
            var providerName = ConfigurationManager.ConnectionStrings[this.connStringName].ProviderName;
            var provider = DbProviderFactories.GetFactory(providerName);

            using (var conn = provider.CreateConnection())
            {
                if (conn == null)
                {
                    return o;
                }

                conn.ConnectionString = connString;

                using (var cmd = conn.CreateCommand())
                {
                    var sqlQuery = string.Format("SELECT Settings FROM {0}DataStoreSettings WHERE ExtensionType = {1}etype AND ExtensionId = {2}eid", this.tablePrefix, this.parmPrefix, this.parmPrefix);
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;
                    conn.Open();

                    var dpeType = provider.CreateParameter();
                    if (dpeType != null)
                    {
                        dpeType.ParameterName = string.Format("{0}etype", this.parmPrefix);
                        dpeType.Value = extensionType.GetHashCode();
                        cmd.Parameters.Add(dpeType);
                    }

                    var dpeId = provider.CreateParameter();
                    if (dpeId != null)
                    {
                        dpeId.ParameterName = string.Format("{0}eid", this.parmPrefix);
                        dpeId.Value = extensionId;
                        cmd.Parameters.Add(dpeId);
                    }

                    o = cmd.ExecuteScalar();
                }
            }

            return o;
        }
开发者ID:karanbhasin,项目名称:blogEngine.Common,代码行数:58,代码来源:DbBlogProvider.cs


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