I was trying to convert c# file to cobra in order to learn it but got stuck
with following problems
1) a class is deriving from an abstract class but is unable to access the members in the abstract class
that are declared protected and even some public members from another abstract class which is
implemented in someclass in the hirarchy of the assemblies been referenced. it works well with c# compiler ,
compiles and program runs well. but converting the same code to Cobra gives errors as to cannot
find the Variables in question or suggesting other variables.below i am providing the problematic snippets
to keep precise
this is the abstract class i am talking about whose member "helper"
cobra is not allowing me to reference
First citation
- Code: Select all
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using System;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public abstract class AbstractProjectOptionPanel : AbstractOptionPanel, ICanBeDirty
{
protected ConfigurationGuiHelper helper; //cobra says another member with same name
"InitializeHelper" is there use it
protected MSBuildBasedProject project;
protected AbstractProjectOptionPanel();
public bool IsDirty { get; set; }
public event EventHandler IsDirtyChanged;
protected void InitializeHelper(); // cobra advocates for using this
public override bool StorePanelContents();
}
}
c# the above mentioned members are called like this and pose no problem
i am merely converting that to cobra which is shown below
- Code: Select all
protected virtual ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode)
{
return helper.BindString(control, property, textBoxEditMode);
}
protected virtual ConfigurationGuiBinding BindEnum<T>(string control, string property) where T : struct
{
return helper.BindEnum<T>(control, property);
}
///another snippet from some func
Get<TextBox>("projectFolder").Text = project.Directory;
Get<TextBox>("projectFile").Text = Path.GetFileName(project.FileName);
Get<TextBox>("projectFile").ReadOnly = true;
cobra code
- Code: Select all
use System
use System.IO
use System.Windows.Forms
# i tried this thinking maybe this outside namespace needs mention of its assembly
# but it did not work
use ICSharpCode.SharpDevelop.Gui.OptionPanels from ICSharpCode.SharpDevelop
use ICSharpCode.SharpDevelop.Project from ICSharpCode.SharpDevelop
namespace Testing
class ApplicationSettingsPanel
is public
inherits AbstractProjectOptionPanel
#i had to convert the name to small letter first
#because Cobra would not allow otherwise
def bindString(control as String, property as String,textBoxEditMode as TextBoxEditMode ) as ConfigurationGuiBinding is protected , virtual
# cobra error Cannot find "helper". There is a member named "initializeHelper" with a
# similar name that you can access with a leading period (".").
return helper.bindString(control, property, textBoxEditMode)
def bindEnum<of T>(control as String ,property as String) as ConfigurationGuiBinding is protected, virtual
where T must be struct
#same above error
return helper.bindEnum<of T>(control, property)
#below i think i can
# make Get<of to get<of because it is a methood in it class
# and since it is coming from a class i am deriving from
# i can even do .get<of
# but i have tried all the option Corba compiler says it cannot find it
# cobra error Cannot find "project".
# cobra error Cannot find type for "Get<of>".
Get<of TextBox>("projectFolder").text = project.directory
Get<of TextBox>("projectFile").text = Path.getFileName(project.fileName)
Get<of TextBox>("projectFile").readOnly = true
Get<of> is located in its class like this
- Code: Select all
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
namespace ICSharpCode.SharpDevelop.Gui.XmlForms
{
public abstract class XmlUserControl : UserControl
{
protected XmlLoader xmlLoader;
public XmlUserControl();
public Dictionary<string, Control> ControlDictionary { get; }
public T Get<T>(string name) where T : Control; /// <---
protected void SetupFromXmlResource(string resourceName);
protected void SetupFromXmlStream(Stream stream);
protected virtual void SetupXmlLoader();
}
}
few more questions please:-
1) is below conversion okay?
SetupFromXmlStream(typeof(CompilingOptionsPanel).Assembly.GetManifestResourceStream(resource));
.setupFromXmlStream(sharp'typeof(CompilingOptionsPanel)'.Assembly.getManifestResourceStream(resource))
i get if c# expression of type "(int)Var1" will become "Var1 to int" but what
about typeof as in above context
Thankyou
RIGHT_THEN