|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CommandText is placed in the resx file[DesignTimeVisible(false), ToolboxItem(false), Designer("Agrovision.Data.Design.CommandDesigner, Agrovision.Data.Design, Version=3.0.3.0, Culture=neutral, PublicKeyToken=27bbda75f3eecde7", typeof(IDesigner))] public class CommandClass: Component { private string FCommandText; private string FConnectionName; private string FTableName; [DefaultValue(null), Editor("Agrovision.Data.Design.CommandTextEditor, Agrovision.Data.Design, Version=3.0.3.0, Culture=neutral, PublicKeyToken=27bbda75f3eecde7", typeof(UITypeEditor))] public string CommandText { get { return FCommandText; } set { if (FCommandText != value) { if (value == null || value.Trim() == String.Empty) FCommandText = null; else FCommandText = value; } } } [DefaultValue(null), Editor("Agrovision.Data.Design.ConnectionNameEditor, Agrovision.Data.Design, Version=3.0.3.0, Culture=neutral, PublicKeyToken=27bbda75f3eecde7", typeof(UITypeEditor))] public string ConnectionName { get { return FConnectionName; } set { if (FConnectionName != value) { if (value == null || value.Trim() == String.Empty) FConnectionName = null; else FConnectionName = value; } } } [DefaultValue(null)] public string TableName { get { return FTableName; } set { if (FTableName != value) { //Check is FTableName is unique if (value == null || value.Trim() == String.Empty) FTableName = null; else { FTableName = value; } } } } } When I place this component on a form which has the localizeble property set to true, the value of the CommandText property is saved to the resx file, while the values of the ConnectionName and TableName properties are saved in the Designer.cs file. What's the reason for this behaviour and how can I prevent that the value of the CommandText is saved in the resx, because it's not localizable, ofcours. -- Jaap Mosselman Hello,
The main difference between the "CommandText" and "ConnectionName" is their Editor attributes: Agrovision.Data.Design.CommandTextEditor Agrovision.Data.Design.ConnectionNameEditor Have you check the implemnents of these two Editors, to see if they cause the problem? Or you may post their code here so that we can build a similar component and test to see if we can reproduce the problem? Sincerely, Luke Zhang Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hello,
Here is the code of the CommandText and ConnectionName editors: public class ConnectionNameEditor: UITypeEditor { public ConnectionNameEditor() { } private ListBox FListBox; private IWindowsFormsEditorService edSvc; public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { ListBox oListBox = CreateListBox(value); edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { edSvc.DropDownControl(oListBox); return oListBox.SelectedItem; } return value; } public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { return UITypeEditorEditStyle.DropDown; } private ListBox CreateListBox(object aCurrentValue) { // if (FListBox == null) // { FListBox = new ListBox(); FListBox.BorderStyle = BorderStyle.None; FListBox.Click += new EventHandler(ListBox_Click); //Fill ConnectionNames FListBox.Items.AddRange(DesignTimeConnections.Connections.AllKeys); if (aCurrentValue == null) FListBox.SelectedIndex = -1; else FListBox.SelectedIndex = FListBox.Items.IndexOf(aCurrentValue); FListBox.Height = FListBox.PreferredHeight; // } return FListBox; } private void ListBox_Click(object sender, EventArgs e) { edSvc.CloseDropDown(); } } public class CommandTextEditor: UITypeEditor { private ListBox FListBox; private IWindowsFormsEditorService edSvc; public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { Type T1 = context.Instance.GetType(); Type T2 = typeof(CommandClass); if (!T1.Equals(T2)) MessageBox.Show("wrong Assembly referenced: "+T1.AssemblyQualifiedName); /* MessageBox.Show(T.AssemblyQualifiedName+"::"+T.Assembly.Location+"::"+T.Assembly.GetName().Name+"::"+T.Assembly.CodeBase); */ CommandClass command1 = context.Instance as Agrovision.Data.Server.CommandClass; if (command1.CommandType == CommandType.StoredProcedure) { ListBox oListBox = CreateListBox(command1,value); edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { edSvc.DropDownControl(oListBox); if (String.Compare(command1.CommandText,oListBox.SelectedItem.ToString(),true) != 0) { command1.CommandText = oListBox.SelectedItem.ToString(); RemoveParameters(command1); command1.TableName = command1.CommandText; if (command1.TableName != null && String.Compare(command1.TableName.Substring(0,2),"sp") == 0) command1.TableName = command1.TableName.Remove(0,2); CreateParameters(command1); return command1.CommandText; } } } if (command1.CommandType == CommandType.Text) { frmCommandTextEditor oForm = new frmCommandTextEditor(command1); if (oForm.ShowDialog() == DialogResult.OK) { command1.TableName = CommandClass.FindTableName(command1.CommandText); if (oForm.CreateParameters) CreateParameters(command1); return command1.CommandText; } } } return value; } public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { if ((context != null) && (context.Instance != null)) { Type T1 = context.Instance.GetType(); Type T2 = typeof(CommandClass); if (!T1.Equals(T2)) MessageBox.Show("wrong Assembly referenced: "+T1.AssemblyQualifiedName); CommandClass command1 = context.Instance as CommandClass; if ((command1.CommandType == CommandType.TableDirect) || (command1.CommandType == CommandType.StoredProcedure)) { return UITypeEditorEditStyle.DropDown; } } return UITypeEditorEditStyle.Modal; } private ListBox CreateListBox(CommandClass aCommand, object aCurrentValue) { // if (FListBox == null) // { FListBox = new ListBox(); FListBox.BorderStyle = BorderStyle.None; FListBox.Click += new EventHandler(ListBox_Click); //Fill ConnectionNames IDbLink oDbLink = DesignTimeConnections.CreateDbLink(aCommand.ConnectionName); DataTable oTable = oDbLink.DbInfoStoredProcedures(); if (oTable != null) { oTable.DefaultView.Sort = oTable.Columns[0].ColumnName; foreach (DataRowView oRow in oTable.DefaultView) { FListBox.Items.Add(oRow[0]); } if (aCurrentValue == null) FListBox.SelectedIndex = -1; else FListBox.SelectedIndex = FListBox.Items.IndexOf(aCurrentValue); } FListBox.Height = Math.Min(FListBox.Items.Count,10) * FListBox.ItemHeight; // } return FListBox; } private void ListBox_Click(object sender, EventArgs e) { edSvc.CloseDropDown(); } private void CreateParameters(CommandClass aCommand) { RemoveParameters(aCommand); IDbLink oDbLink = DesignTimeConnections.CreateDbLink(aCommand.ConnectionName); try { oDbLink.CreateParams(aCommand); } catch { } if (aCommand.Site != null) { IContainer oContainer = ((IDesignerHost)aCommand.Site.GetService(typeof(IDesignerHost))).Container; if (oContainer != null) { foreach (ParameterClass oParam in aCommand.Parameters) { oContainer.Add(oParam,"prm"+aCommand.TableName+oParam.ParameterName.Trim(new Char[]{'@'})); } } } } private void RemoveParameters(CommandClass aCommand) { IDesignerHost host = (IDesignerHost)aCommand.Site.GetService(typeof(IDesignerHost)); foreach (ParameterClass oParam in aCommand.Parameters) { host.DestroyComponent(oParam); } } } -- Show quoteJaap Mosselman "Luke Zhang [MSFT]" wrote: > Hello, > > The main difference between the "CommandText" and "ConnectionName" is their > Editor attributes: > > Agrovision.Data.Design.CommandTextEditor > Agrovision.Data.Design.ConnectionNameEditor > > Have you check the implemnents of these two Editors, to see if they cause > the problem? Or you may post their code here so that we can build a similar > component and test to see if we can reproduce the problem? > > Sincerely, > > Luke Zhang > > Microsoft Online Community Support > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Hello,
Thank you for the information. Because lacking of other parts of your code, like, definition of CommandClass, I cannot build a similiar sample on my side. Anyway, when you run the code in VS.NET, have you check the "value" passed into: public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) Is actual a string value? If it was possible, please email you a sample which can reproduce the issue completely, I may take a look at it on my side, to see what happened. (To get my actual email, please remove "online") If we can reproduce the problem, it will be a little easy to found its root cause. Sincerely, Luke Zhang Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hello,
I have examined it a little further. It appears that the commandtext is saved in the resource when it's length is more the 200 characters. This not only applies to the commandtext property, but to all string properties, e.g. the Label.Text. It's saved to the resouce even if the localizable property of the form, usercontrol or component is false. When you decrease the length of the string, the property is removed from the resource file and placed in the Designer.cs file. So it seems you have no control over the fact if a lengthy string is saved in the resource or not. In the case of the commandtext that's very dangerouse, because a translator of the resource could change the commandtext to a wrong statement. Regards, Jaap -- Show quoteJaap Mosselman "Luke Zhang [MSFT]" wrote: > Hello, > > Thank you for the information. Because lacking of other parts of your code, > like, definition of CommandClass, I cannot build a similiar sample on my > side. Anyway, when you run the code in VS.NET, have you check the "value" > passed into: > public override object > EditValue(System.ComponentModel.ITypeDescriptorContext context, > System.IServiceProvider provider, object value) > > Is actual a string value? > > If it was possible, please email you a sample which can reproduce the issue > completely, I may take a look at it on my side, to see what happened. (To > get my actual email, please remove "online") If we can reproduce the > problem, it will be a little easy to found its root cause. > > Sincerely, > > Luke Zhang > > Microsoft Online Community Support > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Hello,
Thank you for the information. This may benifit who has similar issue! Sincerely, Luke Zhang Microsoft Online Community Support This posting is provided "AS IS" with no warranties, and confers no rights. Hello,
But how can I prevent long strings from being saved in the resource file? I don't want them in my resource, because they are not localizable! -- Show quoteJaap Mosselman "Luke Zhang [MSFT]" wrote: > Hello, > > Thank you for the information. This may benifit who has similar issue! > > Sincerely, > > Luke Zhang > > Microsoft Online Community Support > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Hello Jaap,
You may perform the globalization with managed satellite DLLs : Walkthrough: Creating Managed Satellite DLLs http://msdn2.microsoft.com/en-us/library/e9zazcx5.aspx How to: Access Resources in Satellite DLLs http://msdn2.microsoft.com/en-us/library/ms165653.aspx Resources in .Resx File Format http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm l/cpconResourcesInResxFileFormat.asp Sincerely, Luke Zhang Microsoft Online Community Support This posting is provided "AS IS" with no warranties, and confers no rights. |
|||||||||||||||||||||||