Hello,
can you please provice singleton domain component example for DC way?
Thanks.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Igor,
We are working on your issue and will answer you as soon as possible. We are sorry for the delay.
Thanks,
Michael.
Hello Igor,
You cannot define logic for the static interface' property. You will need to implement an additional helper class to do this. This class should use the ObjectSpace to create or load the singleton object. The other implementation should be the same as in persistent classes.
Thanks,
Anatol
Hello,
may I have a simple example of this to make sure best way is used.
Thanks
Hi Igor,
I have created a project based on example How to Implement a Singleton class, which uses the DC technology. It is attached. The essential code follows:
public sealed partial class SolutionModule : ModuleBase { ... public override void Setup(XafApplication application) { if (!XafTypesInfo.IsInitialized) { XafTypesInfo.Instance.RegisterEntity("Singleton", typeof(ISingleton)); } base.Setup(application); } } [DomainComponent] public interface ISingleton { string Name { get; set; } string Description { get; set; } } [DomainLogic(typeof(ISingleton))] public class SingletonLogic { public static ISingleton GetInstance(IObjectSpace objectSpace) { ISingleton result = objectSpace.FindObject<ISingleton>(null); if (result == null) { result = objectSpace.CreateObject<ISingleton>(); result.Name = "My Singleton"; result.Description = "Empty"; } return result; } public static void OnDeleting(ISingleton instance) { throw new Exception("Cannot be deleted"); } } public partial class ShowSingletonController : ViewController { public ShowSingletonController() { PopupWindowShowAction action = new PopupWindowShowAction(this, "ShowSingleton", DevExpress.Persistent.Base.PredefinedCategory.Unspecified); action.CustomizePopupWindowParams += new CustomizePopupWindowParamsEventHandler(action_CustomizePopupWindowParams); } void action_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { IObjectSpace objectSpace = Application.CreateObjectSpace(); e.View = Application.CreateDetailView(objectSpace, SingletonLogic.GetInstance(objectSpace)); } }
Thanks,
Michael.
Hello,
thanks for example. But it's not fully that thing I needed.
I don't need additional action on the bar. I need the functionality which is behaves the same as with business objects example:
Can you redesign your solution in this way?
Igor
Hello,
I've managed this behaviour using properties by defining Detail View instead of List View and disabling New/Delete actions.
Thanks.
Hi Igor,
I am glad to hear that you have found a solution. Please feel free to contact us if you need a further assistance.
Thanks,
Michael.