public static void run(IDependent window, bool imposeSettings = true) { if (windows == null) { windows = new List <IDependent>(); } if (windows.Count > 0) { // Hide the previous window ((Window)windows.Last()).Hide(); // Pass down the database window.setDatabase(windows.Last().getDatabase()); } // Configure closing event ((Window)window).Closed += delegate(object sender, EventArgs args) { Linker.close(window, true); }; // Configure if (imposeSettings) { configure(window); } // Then add this window windows.Add(window); // Show that window ((Window)window).Show(); }
internal object Resolve(Type dependentType, IDependent dependent) { try { return(_register.Resolve(dependentType)); } catch (MissingServiceException) { throw new MissingDependencyException(dependentType, dependent); } }
public static void configure(IDependent window) { // Center the window Window actualWindow = (Window)window; actualWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen; actualWindow.WindowState = WindowState.Maximized; }
public Relationship(IPrincipal principal, IDependent dependent, Role role) { Principal = principal; Dependent = dependent; Role = role; Name = Role == Role.Dependent ? Principal.Name : Dependent.Name; JoinExpression = CreateJoinExpression(principal.PrimaryKeyColumns, dependent.ForeignKeyColumns); }
private static void Main(string[] args) { var useGui = args.Length == 0; switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: logger.Info("Found Windows"); dependent = new WindowsDependent(); break; case PlatformID.Unix: useGui = false; logger.Info("Found Unix"); dependent = new UnixDependent(); break; case PlatformID.MacOSX: logger.Fatal("Mac OS X is not supported yet"); return; case PlatformID.Xbox: logger.Fatal("Xbox is not supported yet"); return; default: logger.Fatal($"Platform [{Environment.OSVersion.Platform}] is not supported yet"); return; } dependent.GetRuntime().PreInit(useGui); logger.Info("Starting..."); AppDomain.CurrentDomain.UnhandledException += (s, e) => { logger.Fatal((Exception)e.ExceptionObject, $"UnhandledException from {e}"); }; TaskScheduler.UnobservedTaskException += (s, e) => { logger.Fatal(e.Exception, $"UnobservedTaskException from {e}"); }; client = new MainClient("config.json", dependent); dependent.GetGui().Start(client.Config); dependent.GetRuntime().PostInit(useGui); client.StartServers(); while (client.Running) { Thread.Sleep(1); } client.StopServers(); }
private static void InjectThis(IDependent dependentBehaviour) { if (_injector == null && _earlyDependents != null) { _earlyDependents.Enqueue(dependentBehaviour); } else { _injector?.InjectDependencies(dependentBehaviour); } }
public static void close(IDependent window, bool refreshPrevious = false) { // If the application is not activated, destroy application if (!window.getDatabase().settings.isActivated) { Message.show("البرنامج غير مفعل ,لذى سيتم اغلاق البرنامج", MessageBoxImage.Warning); Environment.Exit(0); } // Remove the current window if (windows != null) { if (windows.Contains(window)) { windows.Remove(window); } } // If this is the last window to be closed, save database if (windows.Count == 0) { Loader.save <Database>(Loader.getDataFilePath(), window.getDatabase()); } // Destroy it ((Window)window).Close(); // Show the last window if (windows.Count > 0) { // Configure before showing configure(windows.Last()); // Show ((Window)windows.Last()).Show(); // Refresh if required if (refreshPrevious) { windows.Last().refresh(); } } }
public MainClient(string configFile, IDependent dependent) { ConfigFile = configFile; Config = new MainConfig(); if (File.Exists(ConfigFile)) { Config = JsonConvert.DeserializeObject <MainConfig>(File.ReadAllText(ConfigFile)); } File.WriteAllText(ConfigFile, JsonConvert.SerializeObject(Config)); selfNodeData.DomainName = Config.TapConfig.SelfName; NetworkManager = new NetworkManager(Config.NetworksSaveConfig); TapMessageInterface = new TapMessageInterface(Config.TapConfig, dependent.GetTapInerface()); DnmpClient = new DnmpClient(TapMessageInterface, new OsUdpProtocol(Config.GeneralConfig.ReceiveBufferSize, Config.GeneralConfig.SendBufferSize), Config.ClientConfig); DnmpClient.OnDisconnected += () => CurrentNetworkId = Guid.Empty; DnmpClient.OnConnectionTimeout += () => CurrentNetworkId = Guid.Empty; WebSocketServer = new ClientWebSocketServer(this); HttpServer = new ClientHttpServer(this); }
private void SetParamDependencies(Parameter parameter) { IDependent dependent = parameter as IDependent; if (dependent is null) { return; } var types = dependent.DependsOn(); var dependencies = new List <object>(); foreach (var obj in parameters) { if (types.Contains(obj.GetType())) { dependencies.Add(obj); } } dependent.SetDependencies(dependencies); }
internal void InjectDependencies(IDependent dependent) { if (_container == null) { Debug.LogWarning( "Skipping Injection. " + "No UnityServiceContainer container found in scene."); return; } var publicMethods = dependent.GetType().GetMethods(); var privateMethods = dependent.GetType().GetMethods( BindingFlags.NonPublic | BindingFlags.Instance); var methods = publicMethods .Concat(privateMethods) .Distinct(); foreach (var injectMethod in methods) { if (injectMethod.Name != INJECT) { continue; } var typeDependencies = injectMethod .GetParameters() .Select(p => p.ParameterType) .ToArray(); var dependentServices = new List <object>(); foreach (var dependentType in typeDependencies) { var service = _container.Resolve(dependentType, dependent); dependentServices.Add(service); } injectMethod.Invoke(dependent, dependentServices.ToArray()); } }
public bool IsDependentOn(IDependent module) { return((Requires & module.Affects) > 0); }
public Node(IDependent module) { Module = module; }
public BaseClass(IDependent dependent) { _dependent = dependent; }
public MissingDependencyException(Type missingDependencyType, IDependent dependent) { _dependent = dependent; _missingDependencyType = missingDependencyType; }
public MyController2(IDependent dependent) { this.Dependent = dependent; }