How to get interface builder to recognise receiving action method in delegate - macruby

NEWBIE QUESTION ALERT!
I have a brand new macruby application in Xcode 4.1.
In my application delegate I add this method:
def receiveSomeEventFromXib(sender)
puts "receiveSomeEventFromXib"
end
In interface builder, I right click on the delegate object icon and I do not see the above method (there is no Received Action category in the popup).
The delegate object also defines (straight out of the new project box):
attr_accessor :window
but interface builder complains that the delegate object does not have an outlet named window.
I am able to set the delegate object as the window's delegate and if I include a windowWillClose method in the delegate object is does get called.
What is the simple thing that I am missing (naming convention?) that I need to do in order to have interface builder recognise my outlets and received actions?
cheers,
--Ben
Edit
This has been asked before: Interface Builder not Seeing Outlets with MacRuby

It is a known bug brought by Xcode 4.1. It looks like it depends on Xcode more than on MacRuby, i.e. we have to wait for Apple solving it, not for the MacRuby guys.
Look here http://www.macruby.org/trac/ticket/1322 for more and for a workaround.

Related

Concord (VS debugger) method chaining question

I try to uinderstand how method chaining (calling previous or default implementation) works (https://github.com/Microsoft/ConcordExtensibilitySamples/wiki/Component-discovery-and-configuration) but still have many doubts.
DkmExample seems to be dispatcher, but how this class is defined ? Can I define such class ?
Concord interfaces (Microsoft.VisualStudio.Debugger.ComponentInterfaces) do not pass dispatcher in their methods, so how it can be added in implementation ? Do any Concord interface can be chained this way ?
can anyone show how to implement method chaining in https://github.com/microsoft/ConcordExtensibilitySamples/tree/master/HelloWorld/Cs (show how to call default implementation), or provide other real exapmle ?
Thanks in advance
In the Method Chaining Example IDkmExample represents an interface that is part of the Concord API. This is the interface you, as the developer, are implementing. In the method call itself, DkmExample is not the dispatcher but rather a dispatcher object that the dispatcher knows how to handle. These are defined by the dispatcher and cannot be defined externally.
The method chaining example is there to show that if the implementation does not want to handle the call of the interface method, then it can call the method of the same name on the dispatcher object (first item in the API method signature), passing in all the parameters that are taken by the method signature minus the dispatcher object itself. This will allow the dispatcher to pass the call, based on filtering and priority, to the next implementation of the interface that it can find.
For a concrete example, we can look at the following block from the Microsoft.VisualStudio.Debugger.Engine.xml from the microsoft.visualstudio.debugger.engine nuget package:
<member name="M:Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmStartDebuggingOperations.LaunchDebuggedProcess(Microsoft.VisualStudio.Debugger.Start.DkmProcessLaunchRequest)">
<summary>
Causes the debug monitor to create a new process under the debugger. The process
should be left suspended until ResumeDebuggedProcess is called. The debug monitor
must wait for ResumeDebuggedProcess before creating the DkmProcess object since
it needs the UniqueProcessId value from the AD7 Layer.
Note that this method may only be called in response to the Visual Studio
debugger package requesting a launch. Components that wish to launch another
process under the debugger should send a custom event to a visual studio package.
From a package, a launch can be requested through the
IVsDebugger.LaunchDebugTargets API.
</summary>
<param name="request">
[In] DkmProcessLaunchRequest is used to describe the process that debugger should
launch.
</param>
<returns>
[Out] DkmLaunchedProcessInfo is returned from APIs that launch a process.
</returns>
</member>
The interface we are overriding is IDkmStartDebuggingOperations and the method is LaunchDebuggedProcess which in the implementation will take a DkmProcessLaunchRequest, which is a dispatcher object. If the implementation does not want to handle the call, it can call the next implementation by taking the dispatcher object and calling the method of the same name on it, passing the necessary parameters.
For example:
internal class MyStartDebuggingOperations : IDkmStartDebuggingOperations
{
public DkmLaunchedProcessInfo LaunchDebuggedProcess(DkmProcessLaunchRequest request)
{
if (/* custom check that this class is to handle it */)
{
// Handle custom implementation here
}
else
{
// This calls the base implementation
return request.LaunchDebuggedProcess();
}
}
}

I can't understand a weird behavior, subclassing tablet widget

Using qooxdoo 5.0.2 (or previous version) I subclass a tablet widget and override _onKeyPress method.
Then, generating source I get a correct behavior, but with generate build the behavior is different.
I simplified my question, with this example below.
I subclass table widget and override _onKeyPress method WITH THE SAME CODE from qooxdoo 5.0.2 table widget source.
Run the example, edit a cell, and press enter.
Using
var tbl = new qx.ui.table.TableModified(tableModel)
the behavior is bad.
Using
var tbl = new qx.ui.table.Table(tableModel)
the behavior is correct.
If you put the example in a blank 5.0.2 project, using qx.ui.table.TableModified, you get a behavior if compile source, and another with compile build.
What is wrong with this? Where is my error?
Playground example
In qooxdoo there are, per convention, protected and private class members like methods or instance variables. Protected members start with an underscore like _myProtectedMethod, private members start with two underscores like __myPrivateMethod. The protected members are not affected by the build process and left as they are. This way they are override-able by derived classes.
Private members are obfuscated by the compiler to a random name, so that trying to access the private method or variable outside the class where they are defined leads to an exception.
In your playground example you've overridden the method _onKeyPress which per se is OK to be overridden as it is a protected member.
But within the overridden code you're using private members like this.__focusedRow which fails, because in the build version there is no more __focusedRow member as it got obfuscated. There are more private members in the code like __focusedCol, __selectionManager etc.
To successfully override the method, you have to replace those private members by their accessors, like this.getFocusedRow() instead of this.__focusedRow, this.getFocusedColum() instead of this._focusedCol etc.

Episerver - Why BlockData doesn't implement IContent

Does anybody knows why BlockData class doesn't directly implement IContent?
I know that during BlockData is being retrieve from database, proxy created by Castle implements IContent.
If StackOverflow isn't suitable place for this kind of a question, please move it.
Johan Björnfot at EPiServer explains some of the details in this post.
Excerpt:
"In previous versions of CMS was pages (PageData) the only content type that the content repository (traditionally DataFactory) handled. In CMS7 this has changed so now content repository (IContentRepository) handles IContent instances. This means that the requirement for a .NET type to be possible to save/load from content repository is that it implements the interface EPiServer.Core.IContent.
There are some implementations of IContent built into CMS like PageData and ContentFolder (used to group shared block instances) and it is also possible to register custom IContent implementations.If you look at BlockData though you will notice that it doesn’t implement IContent, how is then shared block instances handled?
The answer is that during runtime when a shared block instance is created (e.g. through a call to IContentRepository.GetDefault where T is a type inheriting from BlockData) the CMS will create a new .NET type inheriting T using a technic called mixin where the new generated subclass will implement some extra interfaces (including IContent)."
BlockData does implement IContent as it is intended to work both when added to another content item such as a PageData instance (a.k.a. Local Block), and as a standalone instance (a.k.a.Shared Block). In latter case the interface is added by using a mix-in though Castle Windsor so that it can be referenced.
The decision for this construct was based on wanting to be able to use the same rendering templates regardless if a block is local or shared. Therefor the choice stood between having a large number of empty properties on local blocks or the current solution using mixins. Both options were tested and mixins was selected as the preferred solution even though it's not a perfect one.
BlockData "does implement IContent", just do:
var myContent = (IContent)myBlock;
But, if you're by any chance handling a Block which itself is a property (not a ContentReference), that cast will throw an exception.
This will be true for 100% of all cases (... using Math.Round).

Have a module dependent Injection for State in PRISM WPF application

hi we have a PRISM WPF MVP application, we would like to have a state to share data between the views in the same module. Since PRISM by default doesnt have a state, was wondering if there is any way i could implement this. Presently i have injected a State with Dictionary as back-store, but the problem is its Global i.e available across the modules. i would really like to scope this injection being module specific.
I believe unity allows registering different classes to the same interface based on name, not sure if the only choice i have is to leverage that for my scenario.
Any help would be great! Thanks!
-ioWint
I would agree, scoping Unity's type registration with the ModuleName would be a place to start.
Inject a local(module level) state object into all the views that want to have share state. If the interface that defines the state object is local to your module then other modules won't be able to reference the state object because they can't reference the interface.
So: If Module A has 3 views that take an object implementing IStatefulContainer (also declared in Module A) and IStatefulContainer is registered with Unity using RegisterInstance rather than just RegisterType you'll have a singleton that is scoped to the module.
My preference would be to have a "State" service that managed state. This could allow you to add more functionality here if you needed it and is a more "Prismy" approach.
EDIT
If you're using this state object across modules then you can do the following:
1)Put the interface in an assembly that will be referenced by any module that wants to use it.
Assembly A
public interface IBlah
{
string Add(string stateKey, string stateValue);
}
Assembly B (referencing Assembly A)
public class Module:IModule
{
private IUnityContainer _container;
public Module(IUnityContainer container)
{
_container=container;
}
public void Initialize()
{
IBlah blah1=new BlahContainer();
IBlah blah2=new BlahContainer();
_container.RegisterInstance<IBlah>(blah1,"BlahContainer1");
_container.RegisterInstance<IBlah>(blah2,"BlahContainer2");
}
}
Module C(references assembly A)
_container.Resolve<IBlah>("BlahContainer1");
_container.Resolve<IBlah>("BlahContainer2");
Basically, we define the interface in an assembly we're happy to share between modules. Some projects have "Infrastructure" or Common assemblies that contain service interfaces that are used by other modules - this would fit well here.
We then have our module reference the assembly with the contract in it.
At the moment I'm relying on "magic strings" here but there are lots of ways around this.
Hope this is a little more clear.
thanks for your updated solution. I was trying to avoid a name based Unity registration, which would force my Presenter in knowing the Modules State registration Key.
I was reading stackoverflow posts on Unity and found the discussion over here Is it possible to override parameter values when using Method Injection with Unity? .
After couple of hours of trial and errors, i ended up achieving the desired functionality.
What i have done:
I have a BaseClass for my Modules -> BaseModule:IModule i have a State Property in it which conforms to my IStateService defined in the Infrastructure.Interface. I Instantiate this State property in the BaseModule() constructor.
Note: to go with this approach i have to make my Presenter's have a public IStateService State; property..
At the time of registering the Presenter in the module, i am specifying
<UnityContainer>.RegisterType<MyPresenter, new InjectionProperty("State", State).
Am overriding a public property in Presenter which has name "State" with the State instance value defined in the Module.
this way i am able to get the Modules State as the State for each of the View's presenter.
Thanks guys for directing me towards a solution.
-ioWint

Silverlight 4 Get Current User

I have seen this question posed regarding Silverlight 2 but I have not seen any questions about Silverlight 4.
Is there a way to get the current user running an application in Silverlight 4.0? I thought I remember seeing that as one of the features of 4.0 but I cannot find it. (Maybe it was just wishful thinking on my part.) I would imagine it would have to come from the OS running the browser or the browser itself. (The application is not being installed locally, it's running in the browser)
I have a solution where I call web service method that just does the following to get the users name. However, I would like to not have to call a web service
HttpContext.Current.User.Identity.Name.ToUpper();
Thanks in advance!
Getting the Username client-side in standard Inbrowser silverlight app just isn't going to happen, it would be a really bad thing security wise if it were possible.
Personally if I had this requirement I would probably use some web service, WCF or a simple IHttpHandler server-side. However I would be in inclined to call it something like "UserContext" and send XML. The XML would contain the Username. This would allow for additional user specific state to be added to the XML later as further requirements become clear. Adding these new chunks of info would be easy.
You might find it easier just to pass the name into the silverlight app as a parameter
In your Silverlight object tag add a new param with name as initParam (note the casing). Through this you can pass values as key=value[,key=value,...] pairs.
Here I am passing a key of usrIdentity and value as the Current User Identity Name.
<param name="initParams" value='usrIdentity=#HttpContext.Current.User.Identity.Name'/>
In your App.xaml.cs in the Application_StartUp you would have the following code
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
if (e.InitParams.ContainsKey("usrIdentity"))
{
//I have a public static string WindowsUser on my MainPage.xaml.cs
MainPage.WindowsUser = e.InitParams["usrIdentity"];
}
}
This is from hewstone's suggestion. The MS link is http://msdn.microsoft.com/en-us/library/cc189004(v=vs.95).aspx
Correction to #Vishnoo Rath; you should try this:
<param name="initParams"
value="usrIdentity=<%=HttpContext.Current.User.Identity.Name%>"/>

Resources