/// <summary> /// Initializes the remotable object. /// </summary> /// <param name="remote">Remote object used for communication with the client-side object.</param> /// <param name="config">Configuration of the object to be created on the client side.</param> public virtual void InitRemotable(DextopRemote remote, DextopConfig config) { Remote = remote; config.Add("direct", GetDirectConfig()); var appPath = DextopEnvironment.VirtualAppPath; if (!appPath.EndsWith("/")) { appPath += "/"; } config.Add("virtualAppPath", appPath); DextopConfig modules = new DextopConfig(); foreach (var m in DextopApplication.GetModules()) { var r = m.RegisterSession(this); if (r != null) { modules.Add(m.ModuleName, Remote.TrackRemotableComponent(r)); } } if (modules.Count > 0) { config.Add("modules", modules); } }
/// <summary> /// Gets the localized session variable. /// </summary> /// <param name="sessionVariableName">Name of the session variable.</param> /// <returns></returns> public object GetLocalizedVariable(string sessionVariableName) { if (Culture == null) { return(null); } return(DextopApplication.GetLocalizedVariable(Culture, sessionVariableName)); }
/// <summary> /// Sets the localized session variable. /// </summary> /// <param name="sessionVariableName">Name of the session variable.</param> /// <param name="value">The value.</param> public void SetLocalizedVariable(string sessionVariableName, object value) { if (Culture == null) { throw new DextopException("Session culture not set."); } DextopApplication.SetLocalizedVariable(Culture, sessionVariableName, value); }
public void ProcessAssemblies(DextopApplication application, IList<System.Reflection.Assembly> assemblies, System.IO.Stream outputStream) { var root = new Model { children = new List<Model>() }; foreach (var assembly in assemblies) { var dict = Codaxy.Common.Reflection.AssemblyHelper.GetTypeAttributeDictionaryForAssembly<CandyAttribute>(assembly, false); foreach (var v in dict.OrderBy(a => a.Value.Category).ThenBy(a => a.Value.Title)) { Model parent; if (String.IsNullOrEmpty(v.Value.Category)) parent = root; else { parent = root; var crumbs = v.Value.Category.Split('\\', '/'); foreach (var crumb in crumbs) { if (parent.children == null) parent.children = new List<Model>(); var node = parent.children.FirstOrDefault(a => a.text == crumb); if (node == null) { node = new Model { text = crumb }; parent.children.Add(node); } node.leaf = false; parent = node; } } var m = new Model { tooltip = v.Value.Description, text = v.Value.Title, windowType = v.Value.WindowType, leaf = true, }; if (parent.children == null) parent.children = new List<Model>(); parent.children.Add(m); } } using (var w = new StreamWriter(outputStream)) { w.WriteLine("Ext.ns('CandyShop');"); w.Write("CandyShop.Candies = "); w.Write(DextopUtil.Encode(root.children)); w.WriteLine(";"); } }
/// <summary> /// Initialize sesssions. /// </summary> /// <param name="application">The application.</param> /// <param name="sessionId">The session id.</param> /// <returns></returns> protected virtual internal DextopConfig Initialize(DextopApplication application, String sessionId) { SessionId = sessionId; DextopApplication = application; Context = new DextopContext { //Application = session.DextopApplication, ModelManager = DextopApplication.ModelManager, Session = this, }; RegisterDependencies(); ExtendSession(); return(InitRemoting()); }
/// <summary> /// Initialize sesssions. /// </summary> /// <param name="application">The application.</param> /// <param name="sessionId">The session id.</param> /// <returns></returns> protected virtual internal DextopConfig Initialize(DextopApplication application, String sessionId) { SessionId = sessionId; DextopApplication = application; Context = new DextopContext { //Application = session.DextopApplication, ModelManager = DextopApplication.ModelManager, Session = this, }; RegisterDependencies(); ExtendSession(); return InitRemoting(); }
/// <summary> /// Registers the application. /// </summary> /// <param name="application">The application.</param> public static void RegisterApplication(DextopApplication application) { if (applications == null) { applications = new ConcurrentDictionary <string, DextopApplication>(); } if (application.AppKey == null) { application.AppKey = String.Empty; } if (!applications.TryAdd(application.AppKey, application)) { throw new DextopException("Dextop application with the same key already exists."); } }
internal List <ClientLookupData> PrepareLookupData(params String[] names) { var res = new List <ClientLookupData>(); LookupData d; foreach (var name in names) { var clientVersion = GetLookupDataClientVersion(name); if (!TryGetLookupData(name, out d) || d.ServerVersion != clientVersion) { if (d == null) { int version = DextopApplication.GetNextSharedLookupVersionNumber(); DextopSessionVariableSharing sharing; var data = BuildLookupData(name, out sharing); d = new LookupData { Data = data, ServerVersion = version }; SetLookupData(name, d, sharing); } res.Add(new ClientLookupData { name = name, data = d.Data, version = d.ServerVersion }); } else { res.Add(new ClientLookupData { name = name, version = d.ServerVersion }); } } return(res); }
/// <summary> /// Removes the localized session variable. /// </summary> /// <param name="sessionVariableName">Name of the session variable.</param> public void RemoveLocalizedVariable(String sessionVariableName) { DextopApplication.RemoveLocalizedVariable(Culture, sessionVariableName); }
/// <summary> /// Removes the global session variable. /// </summary> /// <param name="sessionVariableName">Name of the session variable.</param> public void RemoveGlobalVariable(String sessionVariableName) { DextopApplication.RemoveGlobalVariable(sessionVariableName); }
/// <summary> /// Gets the global session variable. /// </summary> /// <param name="sessionVariableName">Name of the session variable.</param> /// <returns></returns> public object GetGlobalVariable(string sessionVariableName) { return(DextopApplication.GetGlobalVariable(sessionVariableName)); }
/// <summary> /// Sets the global session variable. /// </summary> /// <param name="sessionVariableName">Name of the session variable.</param> /// <param name="value">The value.</param> public void SetGlobalVariable(string sessionVariableName, object value) { DextopApplication.SetGlobalVariable(sessionVariableName, value); }
/// <summary> /// Registers the application. /// </summary> /// <param name="application">The application.</param> public static void RegisterApplication(DextopApplication application) { if (applications == null) applications = new ConcurrentDictionary<string, DextopApplication>(); if (application.AppKey == null) application.AppKey = String.Empty; if (!applications.TryAdd(application.AppKey, application)) throw new DextopException("Dextop application with the same key already exists."); }
internal DextopConfig Register(DextopRemote parent, IDextopRemotable remotable, String remoteId = null, bool subRemote = true) { if (remotable == null) { throw new ArgumentNullException("remotable"); } bool isClientInitiated; if (remoteId == null) { remoteId = Interlocked.Increment(ref nextRemoteId).ToString(); isClientInitiated = parent != null && parent.IsClientInitiated; } else if (subRemote) { if (parent == null) { throw new DextopInternalException(); } remoteId = parent.RemoteId + '.' + remoteId; isClientInitiated = parent.IsClientInitiated; } else { isClientInitiated = true; } var context = new RemotableContext { Remotable = remotable }; var remote = new DextopRemote(Context, remoteId, isClientInitiated); var clientTypeName = DextopApplication.MapTypeName(remotable.GetType()); try { var config = new DextopConfig(); remotable.InitRemotable(remote, config); if (!remote.IsClientInitiated) { DextopConfig remoteProxyConfig; var remoteTypeName = remote.RemoteHostType ?? clientTypeName; if (remoteTypeName != null) { config.Add("alias", remoteTypeName); remoteProxyConfig = new DextopConfig(); config.Add("remote", remoteProxyConfig); } else { remoteProxyConfig = config; } remoteProxyConfig.Add("remoteId", remoteId); remoteProxyConfig.Add("alias", DextopUtil.GetRemotingProxyTypeName(clientTypeName)); if (remote.componentsConfig != null) { remoteProxyConfig.Add("components", remote.componentsConfig); //config not needed anymore - free memory remote.componentsConfig = null; } } if (!remotables.TryAdd(remoteId, context)) { throw new DextopInternalException(); } return(config); } catch { remote.Dispose(); remotable.Dispose(); throw; } }