public override int GetHashCode() { int hash = 1; if (ResourceName.Length != 0) { hash ^= ResourceName.GetHashCode(); } if (ExtensionType != global::Google.Ads.GoogleAds.V3.Enums.ExtensionTypeEnum.Types.ExtensionType.Unspecified) { hash ^= ExtensionType.GetHashCode(); } if (campaign_ != null) { hash ^= Campaign.GetHashCode(); } hash ^= extensionFeedItems_.GetHashCode(); if (Device != global::Google.Ads.GoogleAds.V3.Enums.ExtensionSettingDeviceEnum.Types.ExtensionSettingDevice.Unspecified) { hash ^= Device.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (ResourceName.Length != 0) { hash ^= ResourceName.GetHashCode(); } if (ExtensionType != 0) { hash ^= ExtensionType.GetHashCode(); } if (adGroup_ != null) { hash ^= AdGroup.GetHashCode(); } hash ^= extensionFeedItems_.GetHashCode(); if (Device != 0) { hash ^= Device.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { unchecked { int hash = ExtensionType.GetHashCode() ^ StartOffset.GetHashCode() ^ EndOffset.GetHashCode(); foreach (var value in PositionalArguments) { hash ^= value.GetHashCode(); } foreach (var pair in NamedArguments) { hash = hash ^ pair.Key.GetHashCode() ^ pair.Value.GetHashCode(); } return(hash); } }
/// <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; }
/// <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(); } } }
/// <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; }
/// <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(); } } } }
/// <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(); } } } }
/// <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(); } } }
/// <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; }
public override int GetHashCode() { int hash = 1; if (ResourceName.Length != 0) { hash ^= ResourceName.GetHashCode(); } if (ExtensionType != 0) { hash ^= ExtensionType.GetHashCode(); } if (startDateTime_ != null) { hash ^= StartDateTime.GetHashCode(); } if (endDateTime_ != null) { hash ^= EndDateTime.GetHashCode(); } hash ^= adSchedules_.GetHashCode(); if (Device != 0) { hash ^= Device.GetHashCode(); } if (Status != 0) { hash ^= Status.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.SitelinkFeedItem) { hash ^= SitelinkFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.StructuredSnippetFeedItem) { hash ^= StructuredSnippetFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.AppFeedItem) { hash ^= AppFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.CallFeedItem) { hash ^= CallFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.CalloutFeedItem) { hash ^= CalloutFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.TextMessageFeedItem) { hash ^= TextMessageFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.PriceFeedItem) { hash ^= PriceFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.PromotionFeedItem) { hash ^= PromotionFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.LocationFeedItem) { hash ^= LocationFeedItem.GetHashCode(); } if (extensionCase_ == ExtensionOneofCase.AffiliateLocationFeedItem) { hash ^= AffiliateLocationFeedItem.GetHashCode(); } hash ^= (int)extensionCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }