internal FrmSettings(DesktopClientSettings settings, ExtensionManager extensionManager, StyleManager styleManager) { InitializeComponent(); this.settings = settings; this.extensionManager = extensionManager; this.styleManager = styleManager; }
/// <summary> /// When overridden in a derived class, allows a designer to emit code that configures the splash screen and main form. /// </summary> protected override void OnCreateMainForm() { var extensionManager = new ExtensionManager(); var styleManager = new StyleManager(); var settings = DesktopClientSettings.ReadSettings(); var loadExtensionTask = Task.Factory.StartNew(() => { // As the extensions are loaded in another thread, setting that thread's ui culture // to the one read from the setting preference. Thread.CurrentThread.CurrentUICulture = new CultureInfo(settings.General.Language); extensionManager.Load(); }); var loadStyleTask = Task.Factory.StartNew(() => styleManager.Load()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(settings.General.Language); var credential = LoginProvider.Login(Application.Exit, settings); if (credential != null) { Task.WaitAll(loadExtensionTask, loadStyleTask); // Instantiate your main application form this.MainForm = new FrmMain(credential, settings, extensionManager, styleManager); } }
public IDocumentFactory LookupDocumentFactory(string factoryName) { if (this.extensionManager == null) { this.extensionManager = (ExtensionManager)this.serviceProvider.GetService(typeof(ExtensionManager)); } return this.extensionManager.LookupDocumentFactory(factoryName); }
public AboutDialog(ExtensionManager manager) { _manager = manager; InitializeComponent(); SetupMuiComponents(); versionLabel.Text = Application.ProductVersion.ToString(); repositoryLinkLabel.Text = LiteDevelopApplication.SourceRepositoryUrl; foreach (var extension in manager.LoadedExtensions) { listView1.Items.Add(new ListViewItem(new string[] { extension.Name, extension.Version.ToString() } ) { Tag = extension }); } }
public void Init(ExtensionManager extensionManager, UiManager uiManager, Dispatcher dispatcher) { uiManager.RegisterView(this, new View(this, "Output", "FinalesFunkeln:Output", _textBox)); uiManager.RegisterView(this, new View(this, "Packets", "FinalesFunkeln:PacketOverview", _packetUi)); uiManager.RegisterView(this, new View(this, "Status", "FinalesFunkeln:ClientStatus", _clientStatus)); uiManager.RegisterView(this, new View(this, "Certificates", "FinalesFunkeln:Certificates", _certList)); _dispatcher = dispatcher; extensionManager.AcknowledgeMessageReceived += pm_AcknowledgeMessageReceived; extensionManager.AsyncMessageReceived += pm_AsyncMessageReceived; extensionManager.ErrorMessageReceived += pm_ErrorMessageReceived; extensionManager.LolClientInjected += pm_LolClientInjected; extensionManager.LolClientConnected += pm_LolClientConnected; extensionManager.LolClientDisconnected += pm_LolClientDisconnected; extensionManager.LolClientClosed += pm_LolClientClosed; }
/// <summary> /// Reads the attribute <c>customSession</c> /// from <see cref="MonoRailConfiguration"/> and /// instantiate it based on the type name provided. /// </summary> /// <exception cref="ConfigurationException"> /// If the typename was not provided or the type /// could not be instantiated/found /// </exception> /// <param name="manager">The Extension Manager</param> /// <param name="configuration">The configuration</param> private void Init(ExtensionManager manager, IMonoRailConfiguration configuration) { manager.AcquireSessionState += OnAdquireSessionState; manager.ReleaseSessionState += OnReleaseSessionState; var customSessionAtt = configuration.ConfigurationSection.Attributes["customSession"]; if (customSessionAtt == null) { var message = "The CustomSessionExtension requires that " + "the type that implements ICustomSessionFactory be specified through the " + "'customSession' attribute on 'monorail' configuration node"; throw new ConfigurationErrorsException(message); } var customSessType = TypeLoadUtil.GetType(customSessionAtt); if (customSessType == null) { var message = "The Type for the custom session could not be loaded. " + customSessionAtt; throw new ConfigurationErrorsException(message); } try { customSession = (ICustomSessionFactory) Activator.CreateInstance(customSessType); } catch(InvalidCastException) { var message = "The Type for the custom session must " + "implement ICustomSessionFactory. " + customSessionAtt; throw new ConfigurationErrorsException(message); } }
/// <summary> /// Initializes a new instance of the Extension class /// </summary> /// <param name="manager"></param> public Extension(ExtensionManager manager) { Manager = manager; }
/// <summary> /// Initializes a new instance of the OxideMod class /// </summary> public void Load() { RootDirectory = Environment.CurrentDirectory; if (RootDirectory.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))) { RootDirectory = AppDomain.CurrentDomain.BaseDirectory; } if (RootDirectory == null) { throw new Exception($"RootDirectory is null"); } InstanceDirectory = Path.Combine(RootDirectory, "oxide"); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Culture = CultureInfo.InvariantCulture }; CommandLine = new CommandLine(Environment.GetCommandLineArgs()); if (CommandLine.HasVariable("oxide.directory")) { string var, format; CommandLine.GetArgument("oxide.directory", out var, out format); if (string.IsNullOrEmpty(var) || CommandLine.HasVariable(var)) { InstanceDirectory = Path.Combine(RootDirectory, Utility.CleanPath(string.Format(format, CommandLine.GetVariable(var)))); } } ExtensionDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (ExtensionDirectory == null || !Directory.Exists(ExtensionDirectory)) { throw new Exception("Could not identify extension directory"); } PluginDirectory = Path.Combine(InstanceDirectory, Utility.CleanPath("plugins")); ConfigDirectory = Path.Combine(InstanceDirectory, Utility.CleanPath("config")); DataDirectory = Path.Combine(InstanceDirectory, Utility.CleanPath("data")); LangDirectory = Path.Combine(InstanceDirectory, Utility.CleanPath("lang")); LogDirectory = Path.Combine(InstanceDirectory, Utility.CleanPath("logs")); if (!Directory.Exists(InstanceDirectory)) { Directory.CreateDirectory(InstanceDirectory); } if (!Directory.Exists(PluginDirectory)) { Directory.CreateDirectory(PluginDirectory); } if (!Directory.Exists(ConfigDirectory)) { Directory.CreateDirectory(ConfigDirectory); } if (!Directory.Exists(DataDirectory)) { Directory.CreateDirectory(DataDirectory); } if (!Directory.Exists(LangDirectory)) { Directory.CreateDirectory(LangDirectory); } if (!Directory.Exists(LogDirectory)) { Directory.CreateDirectory(LogDirectory); } RegisterLibrarySearchPath(Path.Combine(ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")); var config = Path.Combine(InstanceDirectory, "oxide.config.json"); if (File.Exists(config)) { Config = ConfigFile.Load <OxideConfig>(config); } else { Config = new OxideConfig(config); Config.Save(); } if (CommandLine.HasVariable("rcon.port")) { Config.Rcon.Port = int.Parse(CommandLine.GetVariable("rcon.port")); } RootLogger = new CompoundLogger(); RootLogger.AddLogger(new RotatingFileLogger { Directory = LogDirectory }); if (debugCallback != null) { RootLogger.AddLogger(new CallbackLogger(debugCallback)); } LogInfo("Loading Oxide Core v{0}...", Version); RootPluginManager = new PluginManager(RootLogger) { ConfigPath = ConfigDirectory }; extensionManager = new ExtensionManager(RootLogger); DataFileSystem = new DataFileSystem(DataDirectory); extensionManager.RegisterLibrary("Covalence", covalence = new Covalence()); extensionManager.RegisterLibrary("Global", new Global()); extensionManager.RegisterLibrary("Lang", new Lang()); extensionManager.RegisterLibrary("Permission", new Permission()); extensionManager.RegisterLibrary("Plugins", new Libraries.Plugins(RootPluginManager)); extensionManager.RegisterLibrary("Time", new Time()); extensionManager.RegisterLibrary("Timer", libtimer = new Timer()); extensionManager.RegisterLibrary("WebRequests", new WebRequests()); LogInfo("Loading extensions..."); extensionManager.LoadAllExtensions(ExtensionDirectory); Cleanup.Run(); covalence.Initialize(); RemoteConsole = new RemoteConsole.RemoteConsole(); RemoteConsole?.Initalize(); if (getTimeSinceStartup == null) { timer = new Stopwatch(); timer.Start(); getTimeSinceStartup = () => (float)timer.Elapsed.TotalSeconds; LogWarning("A reliable clock is not available, falling back to a clock which may be unreliable on certain hardware"); } foreach (var ext in extensionManager.GetAllExtensions()) { ext.LoadPluginWatchers(PluginDirectory); } LogInfo("Loading plugins..."); LoadAllPlugins(true); foreach (var watcher in extensionManager.GetPluginChangeWatchers()) { watcher.OnPluginSourceChanged += watcher_OnPluginSourceChanged; watcher.OnPluginAdded += watcher_OnPluginAdded; watcher.OnPluginRemoved += watcher_OnPluginRemoved; } if (CommandLine.HasVariable("nolog")) { LogWarning("Usage of the 'nolog' variable will prevent logging"); } }
/// <summary> /// Initializes a new instance of the SevenDaysExtension class /// </summary> /// <param name="manager"></param> public SevenDaysExtension(ExtensionManager manager) : base(manager) { }
private void InitExtensibility() { var asmHelper = new AssemblyScanHelper(); // Добавляем собственную сборку asmHelper.AddAssembly(GetType().Assembly); // Добавляем Janus-Common asmHelper.AddAssembly(typeof(ExtensionInfoProviderBase).Assembly); // Добавляем сборки всех расширений var rootDir = EnvironmentHelper.GetJanusRootDir(); foreach (var asmPath in GetExtensionAssemblies(rootDir)) { asmHelper.AddAssembly(Assembly.LoadFrom(asmPath)); Trace.WriteLine($"Use extension assembly '{asmPath}'"); } //Ресолвинг сборок расширений foreach (var dir in GetExtensionDirs(rootDir).Select(Path.GetFileName)) #pragma warning disable 612,618 AppDomain.CurrentDomain.AppendPrivatePath(dir); #pragma warning restore 612,618 var extensionManager = new ExtensionManager(_serviceManager); StrategyFactoryStrategy.RegisterAndScan( _serviceManager, extensionManager, asmHelper.GetTypes()); }
/// <summary> /// Initializes a new instance of the InterstellarRiftExtension class /// </summary> /// <param name="manager"></param> public InterstellarRiftExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Handles the Click event of the btnAdd control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> private void BtnAddClick(object sender, EventArgs e) { if (!this.IsValidForm()) { return; } foreach (Control ctl in this.phAddForm.Controls) { switch (ctl.GetType().Name) { case "TextBox": { var txt = (TextBox)ctl; if (this.Settings.IsScalar) { this.Settings.UpdateScalarValue(txt.ID, txt.Text); } else { this.Settings.AddValue(txt.ID, txt.Text); } } break; case "CheckBox": { var cbx = (CheckBox)ctl; this.Settings.UpdateScalarValue(cbx.ID, cbx.Checked.ToString()); } break; case "DropDownList": { var dd = (DropDownList)ctl; this.Settings.UpdateSelectedValue(dd.ID, dd.SelectedValue); } break; case "ListBox": { var lb = (ListBox)ctl; this.Settings.UpdateSelectedValue(lb.ID, lb.SelectedValue); } break; case "RadioButtonList": { var rbl = (RadioButtonList)ctl; this.Settings.UpdateSelectedValue(rbl.ID, rbl.SelectedValue); } break; } } ExtensionManager.SaveSettings(this.SettingName, this.Settings); if (this.Settings.IsScalar) { this.InfoMsg.InnerHtml = labels.theValuesSaved; this.InfoMsg.Visible = true; } else { this.BindGrid(); } }
/// <summary> /// Initializes a new instance of the BlockstormExtension class /// </summary> /// <param name="manager"></param> public BlockstormExtension(ExtensionManager manager) : base(manager) { }
public void ExecuteCommand() { string configString = string.Empty; if (!string.IsNullOrEmpty(Configuration)) { configString = GeneralUtilities.GetConfiguration(Configuration); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { string errorConfigInput = null; if (!ExtensionManager.Validate(ExtensionConfiguration, out errorConfigInput)) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput)); } foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null && context.X509Certificate != null) { ExecuteClientActionNewSM( null, string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint), () => this.ComputeClient.ServiceCertificates.Create(this.ServiceName, CertUtilsNewSM.Create(context.X509Certificate))); } } var slotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true); DeploymentGetResponse d = null; InvokeInOperationContext(() => { try { d = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slotType); } catch (CloudException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false) { this.WriteExceptionDetails(ex); } } }); ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); extConfig = extensionMgr.Add(d, ExtensionConfiguration, this.Slot); } // Upgrade Parameter Set if (string.Compare(ParameterSetName, "Upgrade", StringComparison.OrdinalIgnoreCase) == 0) { bool removePackage = false; var storageName = CurrentSubscription.CurrentStorageAccountName; Uri packageUrl = null; if (Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(Package); } else { if (string.IsNullOrEmpty(storageName)) { throw new ArgumentException(Resources.CurrentStorageAccountIsNotSet); } var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; InvokeInOperationContext(() => packageUrl = RetryCall(s => AzureBlob.UploadPackageToBlob(this.StorageClient, storageName, Package, null))); } DeploymentUpgradeMode upgradeMode; if (!Enum.TryParse<DeploymentUpgradeMode>(Mode, out upgradeMode)) { upgradeMode = DeploymentUpgradeMode.Auto; } var upgradeDeploymentInput = new DeploymentUpgradeParameters { Mode = upgradeMode, Configuration = configString, ExtensionConfiguration = extConfig, PackageUri = packageUrl, Label = Label ?? ServiceName, Force = Force.IsPresent }; if (!string.IsNullOrEmpty(RoleName)) { upgradeDeploymentInput.RoleToUpgrade = RoleName; } InvokeInOperationContext(() => { try { ExecuteClientActionNewSM( upgradeDeploymentInput, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.UpgradeBySlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), upgradeDeploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.StorageClient, storageName, packageUrl)); } } catch (CloudException ex) { this.WriteExceptionDetails(ex); } }); } else if (string.Compare(this.ParameterSetName, "Config", StringComparison.OrdinalIgnoreCase) == 0) { // Config parameter set var changeDeploymentStatusParams = new DeploymentChangeConfigurationParameters { Configuration = configString, ExtensionConfiguration = extConfig }; ExecuteClientActionNewSM( changeDeploymentStatusParams, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.ChangeConfigurationBySlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), changeDeploymentStatusParams)); } else { // Status parameter set var updateDeploymentStatusParams = new DeploymentUpdateStatusParameters { Status = (UpdatedDeploymentStatus)Enum.Parse(typeof(UpdatedDeploymentStatus), this.NewStatus, true) }; ExecuteClientActionNewSM( null, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.UpdateStatusByDeploymentSlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), updateDeploymentStatusParams)); } }
private static bool AlterationHasDependency(ShapeAlteration item, ShapeAlteration subject) { return(ExtensionManager.HasDependency(item.Feature.Descriptor, subject.Feature.Descriptor)); }
private IEnumerable <Option> GetCSharpClassNameOptions() { return(ExtensionManager.GetImplementations <IDataSource>().Where(t => !t.GetTypeInfo().IsAbstract).Select( t => new Option(t.FullName) )); }
internal FrmAbout(ExtensionManager extensionManager) { this.InitializeComponent(); this.extensionManager = extensionManager; }
public void ExecuteCommand() { string configString = string.Empty; if (!string.IsNullOrEmpty(Configuration)) { configString = GeneralUtilities.GetConfiguration(Configuration); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { string errorConfigInput = null; if (!ExtensionManager.Validate(ExtensionConfiguration, out errorConfigInput)) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput)); } foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null && context.X509Certificate != null) { ExecuteClientActionNewSM( null, string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint), () => this.ComputeClient.ServiceCertificates.Create(this.ServiceName, CertUtilsNewSM.Create(context.X509Certificate))); } } Func <DeploymentSlot, DeploymentGetResponse> func = t => { DeploymentGetResponse d = null; try { d = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, t); } catch (CloudException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false) { WriteExceptionError(ex); } } return(d); }; var slotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true); DeploymentGetResponse currentDeployment = null; InvokeInOperationContext(() => currentDeployment = func(slotType)); var peerSlottype = slotType == DeploymentSlot.Production ? DeploymentSlot.Staging : DeploymentSlot.Production; DeploymentGetResponse peerDeployment = null; InvokeInOperationContext(() => peerDeployment = func(peerSlottype)); ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); extConfig = (ExtensionConfiguration[0].State == null) ? extensionMgr.Add(currentDeployment, peerDeployment, ExtensionConfiguration, this.Slot) : extensionMgr.UpdateExtensionState(ExtensionConfiguration[0]); } // Upgrade Parameter Set if (string.Compare(ParameterSetName, "Upgrade", StringComparison.OrdinalIgnoreCase) == 0) { bool removePackage = false; var storageName = Profile.Context.Subscription.GetStorageAccountName(); Uri packageUrl = null; if (Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(Package); } else { if (string.IsNullOrEmpty(storageName)) { throw new ArgumentException(Resources.CurrentStorageAccountIsNotSet); } var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; InvokeInOperationContext(() => packageUrl = RetryCall(s => AzureBlob.UploadPackageToBlob(this.StorageClient, storageName, Package, null))); } DeploymentUpgradeMode upgradeMode; if (!Enum.TryParse <DeploymentUpgradeMode>(Mode, out upgradeMode)) { upgradeMode = DeploymentUpgradeMode.Auto; } var upgradeDeploymentInput = new DeploymentUpgradeParameters { Mode = upgradeMode, Configuration = configString, ExtensionConfiguration = extConfig, PackageUri = packageUrl, Label = Label ?? ServiceName, Force = Force.IsPresent, ExtendedProperties = ExtendedProperty != null?ConvertToDictionary(ExtendedProperty) : null, }; if (!string.IsNullOrEmpty(RoleName)) { upgradeDeploymentInput.RoleToUpgrade = RoleName; } InvokeInOperationContext(() => { try { ExecuteClientActionNewSM( upgradeDeploymentInput, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.UpgradeBySlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), upgradeDeploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.StorageClient, storageName, packageUrl)); } } catch (CloudException ex) { WriteExceptionError(ex); } }); } else if (string.Compare(this.ParameterSetName, "Config", StringComparison.OrdinalIgnoreCase) == 0) { // Config parameter set var changeDeploymentStatusParams = new DeploymentChangeConfigurationParameters { Configuration = configString, ExtensionConfiguration = extConfig, ExtendedProperties = ExtendedProperty != null?ConvertToDictionary(ExtendedProperty) : null }; ExecuteClientActionNewSM( changeDeploymentStatusParams, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.ChangeConfigurationBySlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), changeDeploymentStatusParams)); } else { // Status parameter set var updateDeploymentStatusParams = new DeploymentUpdateStatusParameters { Status = (UpdatedDeploymentStatus)Enum.Parse(typeof(UpdatedDeploymentStatus), this.NewStatus, true) }; ExecuteClientActionNewSM( null, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.UpdateStatusByDeploymentSlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), updateDeploymentStatusParams)); } }
public TwitchAuth(ExtensionManager extensionManager) { this.extensionManager = extensionManager; }
internal static SageContext InitializeConfiguration(SageContext context) { string projectConfigPathBinDir = Path.Combine(Project.AssemblyCodeBaseDirectory, ProjectConfiguration.ProjectConfigName); string projectConfigPathProjDir = Path.Combine(Project.AssemblyCodeBaseDirectory, "..\\" + ProjectConfiguration.ProjectConfigName); string projectConfigPath = projectConfigPathBinDir; if (File.Exists(projectConfigPathProjDir)) { projectConfigPath = projectConfigPathProjDir; } var projectConfig = ProjectConfiguration.Create(); if (!File.Exists(projectConfigPath)) { log.Warn("Project configuration file not found; configuration initialized with default values"); return new SageContext(context); } installOrder = new List<string>(); extensions = new OrderedDictionary<string, ExtensionInfo>(); if (File.Exists(projectConfigPath)) projectConfig.Parse(projectConfigPath); if (projectConfig.Locales.Count == 0) { var defaultLocale = new LocaleInfo(); projectConfig.Locales.Add(defaultLocale.Name, defaultLocale); } var result = projectConfig.ValidationResult; if (!result.Success) { initializationError = result.Exception; initializationProblemInfo = new ProblemInfo(ProblemType.ProjectSchemaValidationError, result.SourceFile); } else { configuration = projectConfig; // this will ensure the new context uses the just // created configuration immediately context = new SageContext(context); var extensionManager = new ExtensionManager(); try { extensionManager.Initialize(context); } catch (ProjectInitializationException ex) { initializationError = ex; initializationProblemInfo = new ProblemInfo(ex.Reason, ex.SourceFile); if (ex.Reason == ProblemType.MissingExtensionDependency) { initializationProblemInfo.InfoBlocks .Add("Dependencies", ex.Dependencies.ToDictionary(name => name)); } } if (initializationError == null) { var missingDependencies = projectConfig.Dependencies .Where(name => extensionManager.Count(ex => ex.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)) == 0) .ToList(); var extraDependencies = extensionManager .Where(extension => projectConfig.Dependencies.Count(name => name.Equals(extension.Name, StringComparison.InvariantCultureIgnoreCase)) == 0) .ToList(); if (missingDependencies.Count != 0) { string errorMessage = string.Format("Project is missing one or more dependencies ({0}) - installation cancelled.", string.Join(", ", missingDependencies)); initializationError = new ProjectInitializationException(errorMessage); initializationProblemInfo = new ProblemInfo(ProblemType.MissingDependency); initializationProblemInfo.InfoBlocks .Add("Dependencies", missingDependencies.ToDictionary(name => name)); } if (extraDependencies.Count != 0) { log.WarnFormat("There are additional, unreferenced extensions in the extensions directory: {0}", string.Join(",", extraDependencies)); } foreach (var name in projectConfig.Dependencies) { var extension = extensionManager.First(ex => ex.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); installOrder.Add(extension.Config.Id); Project.RelevantAssemblies.AddRange(extension.Assemblies); projectConfig.RegisterExtension(extension.Config); extensions.Add(extension.Config.Id, extension); } // fire this event at the end rather than once for each extension var totalAssemblies = extensionManager.Sum(info => info.Assemblies.Count); if (totalAssemblies != 0) { if (Project.AssembliesUpdated != null) { log.DebugFormat("{0} extension assemblies loaded, triggering AssembliesUpdated event", totalAssemblies); Project.AssembliesUpdated(null, EventArgs.Empty); } } installOrder.Add(projectConfig.Id); projectConfig.RegisterRoutes(); context.LmCache.Put(ConfigWatchName, DateTime.Now, projectConfig.Files); } } return context; }
private IEnumerable <Option> GetCSharpClassNameOptions() { return(ExtensionManager.GetImplementations <IDataSource>().Where(t => t != typeof(DataSourceBase)).Select( t => new Option(t.FullName) )); }
public void ExecuteCommand() { string configString = string.Empty; if (!string.IsNullOrEmpty(Configuration)) { configString = General.GetConfiguration(Configuration); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { var roleList = (from c in ExtensionConfiguration where c != null from r in c.Roles select r).GroupBy(r => r.ToString()).Select(g => g.First()); foreach (var role in roleList) { var result = from c in ExtensionConfiguration where c != null && c.Roles.Any(r => r.ToString() == role.ToString()) select string.Format("{0}.{1}", c.ProviderNameSpace, c.Type); foreach (var s in result) { if (result.Count(t => t == s) > 1) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, s)); } } } Deployment deployment = Channel.GetDeploymentBySlot(CurrentSubscription.SubscriptionId, ServiceName, Slot); ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); ExtensionConfigurationBuilder configBuilder = extensionMgr.GetBuilder(); foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null) { if (context.X509Certificate != null) { var operationDescription = string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint); ExecuteClientActionInOCS(null, operationDescription, s => this.Channel.AddCertificates(s, this.ServiceName, CertUtils.Create(context.X509Certificate))); } ExtensionConfiguration currentConfig = extensionMgr.InstallExtension(context, Slot, deployment.ExtensionConfiguration); foreach (var r in currentConfig.AllRoles) { if (!extensionMgr.GetBuilder(deployment.ExtensionConfiguration).ExistAny(r.Id)) { configBuilder.AddDefault(r.Id); } } foreach (var r in currentConfig.NamedRoles) { foreach (var e in r.Extensions) { if (!extensionMgr.GetBuilder(deployment.ExtensionConfiguration).ExistAny(e.Id)) { configBuilder.Add(r.RoleName, e.Id); } } } } } extConfig = configBuilder.ToConfiguration(); } // Upgrade Parameter Set if (string.Compare(ParameterSetName, "Upgrade", StringComparison.OrdinalIgnoreCase) == 0) { bool removePackage = false; CurrentSubscription = this.GetCurrentSubscription(); var storageName = CurrentSubscription.CurrentStorageAccount; Uri packageUrl = null; if (Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(Package); } else { if (string.IsNullOrEmpty(storageName)) { throw new ArgumentException(Resources.CurrentStorageAccountIsNotSet); } var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; InvokeInOperationContext(() => packageUrl = RetryCall(s => AzureBlob.UploadPackageToBlob(this.Channel, storageName, s, Package, null))); } var upgradeDeploymentInput = new UpgradeDeploymentInput { Mode = Mode ?? UpgradeType.Auto, Configuration = configString, ExtensionConfiguration = extConfig, PackageUrl = packageUrl, Label = Label ?? ServiceName, Force = Force.IsPresent }; if (!string.IsNullOrEmpty(RoleName)) { upgradeDeploymentInput.RoleToUpgrade = RoleName; } using (new OperationContextScope(Channel.ToContextChannel())) { try { ExecuteClientAction(upgradeDeploymentInput, CommandRuntime.ToString(), s => this.Channel.UpgradeDeploymentBySlot(s, this.ServiceName, this.Slot, upgradeDeploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.Channel, storageName, s, packageUrl)); } } catch (ServiceManagementClientException ex) { this.WriteErrorDetails(ex); } } } else if (string.Compare(this.ParameterSetName, "Config", StringComparison.OrdinalIgnoreCase) == 0) { // Config parameter set var changeConfiguration = new ChangeConfigurationInput { Configuration = configString, ExtensionConfiguration = extConfig }; ExecuteClientActionInOCS(changeConfiguration, CommandRuntime.ToString(), s => this.Channel.ChangeConfigurationBySlot(s, this.ServiceName, this.Slot, changeConfiguration)); } else { // Status parameter set var updateDeploymentStatus = new UpdateDeploymentStatusInput { Status = this.NewStatus }; ExecuteClientActionInOCS(null, CommandRuntime.ToString(), s => this.Channel.UpdateDeploymentStatusBySlot(s, this.ServiceName, this.Slot, updateDeploymentStatus)); } }
/// <summary> /// Initializes a new instance of the RustExtension class /// </summary> /// <param name="manager"></param> public RustExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the FortressCraftExtension class /// </summary> /// <param name="manager"></param> public FortressCraftExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the SpaceEngineersExtension class /// </summary> /// <param name="manager"></param> public SpaceEngineersExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the TheForestExtension class /// </summary> /// <param name="manager"></param> public TheForestExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the HurtworldExtension class /// </summary> /// <param name="manager"></param> public HurtworldExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the UnturnedExtension class /// </summary> /// <param name="manager"></param> public UnturnedExtension(ExtensionManager manager) : base(manager) { }
protected override void OnStart(string[] _) { _envs = _descriptor.EnvironmentVariables; // TODO: Disabled according to security concerns in https://github.com/kohsuke/winsw/issues/54 // Could be restored, but unlikely it's required in event logs at all /** * foreach (string key in _envs.Keys) * { * LogEvent("envar " + key + '=' + _envs[key]); * }*/ HandleFileCopies(); // handle downloads foreach (Download d in _descriptor.Downloads) { String downloadMsg = "Downloading: " + d.From + " to " + d.To + ". failOnError=" + d.FailOnError; LogEvent(downloadMsg); Log.Info(downloadMsg); try { d.Perform(this); } catch (Exception e) { string errorMessage = "Failed to download " + d.From + " to " + d.To; LogEvent(errorMessage + ". " + e.Message); Log.Error(errorMessage, e); // TODO: move this code into the download logic if (d.FailOnError) { throw new IOException(errorMessage, e); } // Else just keep going } } string startarguments = _descriptor.Startarguments; if (startarguments == null) { startarguments = _descriptor.Arguments; } else { startarguments += " " + _descriptor.Arguments; } LogEvent("Starting " + _descriptor.Executable + ' ' + startarguments); Log.Info("Starting " + _descriptor.Executable + ' ' + startarguments); // Load and start extensions ExtensionManager.LoadExtensions(); ExtensionManager.FireOnWrapperStarted(); LogEvent("Starting " + _descriptor.Executable + ' ' + startarguments); Log.Info("Starting " + _descriptor.Executable + ' ' + startarguments); LogHandler executableLogHandler = CreateExecutableLogHandler(); StartProcess(_process, startarguments, _descriptor.Executable, executableLogHandler, true); ExtensionManager.FireOnProcessStarted(_process); _process.StandardInput.Close(); // nothing for you to read! }
/// <summary> /// Initializes a new instance of the NomadExtension class /// </summary> /// <param name="manager"></param> public NomadExtension(ExtensionManager manager) : base(manager) { }
public SQLiteExtension(ExtensionManager manager) : base(manager) { }
public SimpleExtensionManager(ExtensionManager extensionManager, ExtensionsSettingsMountPointProvider extensionsSettingsMountPointProvider) { this.extensionManager = extensionManager; this.extensionsSettingsMountPointProvider = extensionsSettingsMountPointProvider; }
public static IEnumerable <T> GetInstances <T>() { return(ExtensionManager.GetInstances <T>(null)); }
/// <summary> /// Initialize extensions and start the extension manager. /// </summary> public void StartExtensionManager() { extensionManager = new ExtensionManager( this ); AddService( typeof( ExtensionManager ), extensionManager ); var config = GetService<IMonoRailConfiguration>(); foreach( ExtensionEntry entry in config.ExtensionEntries ) { AssertImplementsService( typeof( IMonoRailExtension ), entry.ExtensionType ); var extension = ( IMonoRailExtension )CreateService( entry.ExtensionType ); extension.SetExtensionConfigNode( entry.ExtensionNode ); extensionManager.Extensions.Add( extension ); } }
public void NewPaaSDeploymentProcess() { bool removePackage = false; AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Production); AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Staging); var storageName = CurrentSubscription.CurrentStorageAccount; Uri packageUrl; if (this.Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || this.Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(this.Package); } else { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; packageUrl = this.RetryCall(s => AzureBlob.UploadPackageToBlob( this.Channel, storageName, s, this.Package, null)); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { var roleList = (from c in ExtensionConfiguration where c != null from r in c.Roles select r).GroupBy(r => r.ToString()).Select(g => g.First()); foreach (var role in roleList) { var result = from c in ExtensionConfiguration where c != null && c.Roles.Any(r => r.ToString() == role.ToString()) select string.Format("{0}.{1}", c.ProviderNameSpace, c.Type); foreach (var s in result) { if (result.Count(t => t == s) > 1) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, s)); } } } ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); Deployment currentDeployment = null; ExtensionConfiguration deploymentExtensionConfig = null; using (new OperationContextScope(Channel.ToContextChannel())) { try { currentDeployment = this.RetryCall(s => this.Channel.GetDeploymentBySlot(s, this.ServiceName, Slot)); deploymentExtensionConfig = currentDeployment == null ? null : extensionMgr.GetBuilder(currentDeployment.ExtensionConfiguration).ToConfiguration(); } catch (ServiceManagementClientException ex) { if (ex.HttpStatus != HttpStatusCode.NotFound && IsVerbose() == false) { this.WriteErrorDetails(ex); } } } ExtensionConfigurationBuilder configBuilder = extensionMgr.GetBuilder(); foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null) { if (context.X509Certificate != null) { var operationDescription = string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint); ExecuteClientActionInOCS(null, operationDescription, s => this.Channel.AddCertificates(s, this.ServiceName, CertUtils.Create(context.X509Certificate))); } ExtensionConfiguration currentConfig = extensionMgr.InstallExtension(context, Slot, deploymentExtensionConfig); foreach (var r in currentConfig.AllRoles) { if (currentDeployment == null || !extensionMgr.GetBuilder(currentDeployment.ExtensionConfiguration).ExistAny(r.Id)) { configBuilder.AddDefault(r.Id); } } foreach (var r in currentConfig.NamedRoles) { foreach (var e in r.Extensions) { if (currentDeployment == null || !extensionMgr.GetBuilder(currentDeployment.ExtensionConfiguration).ExistAny(e.Id)) { configBuilder.Add(r.RoleName, e.Id); } } } } } extConfig = configBuilder.ToConfiguration(); } var deploymentInput = new CreateDeploymentInput { PackageUrl = packageUrl, Configuration = General.GetConfiguration(this.Configuration), ExtensionConfiguration = extConfig, Label = this.Label, Name = this.Name, StartDeployment = !this.DoNotStart.IsPresent, TreatWarningsAsError = this.TreatWarningsAsError.IsPresent }; using (new OperationContextScope(Channel.ToContextChannel())) { try { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.CreatingNewDeployment); WriteProgress(progress); ExecuteClientAction(deploymentInput, CommandRuntime.ToString(), s => this.Channel.CreateOrUpdateDeployment(s, this.ServiceName, this.Slot, deploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.Channel, storageName, s, packageUrl)); } } catch (ServiceManagementClientException ex) { this.WriteErrorDetails(ex); } } }
public void ExecuteCommand() { string configString = string.Empty; if (!string.IsNullOrEmpty(Configuration)) { configString = General.GetConfiguration(Configuration); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { var roleList = (from c in ExtensionConfiguration where c != null from r in c.Roles select r).GroupBy(r => r.ToString()).Select(g => g.First()); foreach (var role in roleList) { var result = from c in ExtensionConfiguration where c != null && c.Roles.Any(r => r.ToString() == role.ToString()) select string.Format("{0}.{1}", c.ProviderNameSpace, c.Type); foreach (var s in result) { if (result.Count(t => t == s) > 1) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, s)); } } } Deployment deployment = Channel.GetDeploymentBySlot(CurrentSubscription.SubscriptionId, ServiceName, Slot); ExtensionManager extensionMgr = new ExtensionManager(Channel, CurrentSubscription.SubscriptionId, ServiceName); ExtensionConfigurationBuilder configBuilder = extensionMgr.GetBuilder(); foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null) { if (context.X509Certificate != null) { var operationDescription = string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint); ExecuteClientActionInOCS(null, operationDescription, s => this.Channel.AddCertificates(s, this.ServiceName, CertUtils.Create(context.X509Certificate))); } ExtensionConfiguration currentConfig = extensionMgr.InstallExtension(context, Slot, deployment.ExtensionConfiguration); foreach (var r in currentConfig.AllRoles) { if (!extensionMgr.GetBuilder(deployment.ExtensionConfiguration).ExistAny(r.Id)) { configBuilder.AddDefault(r.Id); } } foreach (var r in currentConfig.NamedRoles) { foreach (var e in r.Extensions) { if (!extensionMgr.GetBuilder(deployment.ExtensionConfiguration).ExistAny(e.Id)) { configBuilder.Add(r.RoleName, e.Id); } } } } } extConfig = configBuilder.ToConfiguration(); } // Upgrade Parameter Set if (string.Compare(ParameterSetName, "Upgrade", StringComparison.OrdinalIgnoreCase) == 0) { bool removePackage = false; CurrentSubscription = this.GetCurrentSubscription(); var storageName = CurrentSubscription.CurrentStorageAccount; Uri packageUrl = null; if (Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(Package); } else { if (string.IsNullOrEmpty(storageName)) { throw new ArgumentException(Resources.CurrentStorageAccountIsNotSet); } var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; InvokeInOperationContext(() => packageUrl = RetryCall(s => AzureBlob.UploadPackageToBlob(this.Channel, storageName, s, Package, null))); } var upgradeDeploymentInput = new UpgradeDeploymentInput { Mode = Mode ?? UpgradeType.Auto, Configuration = configString, ExtensionConfiguration = extConfig, PackageUrl = packageUrl, Label = Label ?? ServiceName, Force = Force.IsPresent }; if (!string.IsNullOrEmpty(RoleName)) { upgradeDeploymentInput.RoleToUpgrade = RoleName; } using (new OperationContextScope(Channel.ToContextChannel())) { try { ExecuteClientAction(upgradeDeploymentInput, CommandRuntime.ToString(), s => this.Channel.UpgradeDeploymentBySlot(s, this.ServiceName, this.Slot, upgradeDeploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.Channel, storageName, s, packageUrl)); } } catch (ServiceManagementClientException ex) { this.WriteErrorDetails(ex); } } } else if (string.Compare(this.ParameterSetName, "Config", StringComparison.OrdinalIgnoreCase) == 0) { // Config parameter set var changeConfiguration = new ChangeConfigurationInput { Configuration = configString, ExtensionConfiguration = extConfig }; ExecuteClientActionInOCS(changeConfiguration, CommandRuntime.ToString(), s => this.Channel.ChangeConfigurationBySlot(s, this.ServiceName, this.Slot, changeConfiguration)); } else { // Status parameter set var updateDeploymentStatus = new UpdateDeploymentStatusInput { Status = this.NewStatus }; ExecuteClientActionInOCS(null, CommandRuntime.ToString(), s => this.Channel.UpdateDeploymentStatusBySlot(s, this.ServiceName, this.Slot, updateDeploymentStatus)); } }
/// <summary> /// Initialises a new instance of the UnityExtension class /// </summary> /// <param name="manager"></param> public UnityExtension(ExtensionManager manager) : base(manager) { }
public virtual void NewPaaSDeploymentProcess() { bool removePackage = false; AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Production); AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Staging); var storageName = CurrentSubscription.CurrentStorageAccountName; Uri packageUrl; if (this.Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || this.Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(this.Package); } else { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; packageUrl = this.RetryCall(s => AzureBlob.UploadPackageToBlob( this.StorageClient, storageName, this.Package, null)); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { string errorConfigInput = null; if (!ExtensionManager.Validate(ExtensionConfiguration, out errorConfigInput)) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput)); } foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null && context.X509Certificate != null) { ExecuteClientActionNewSM( null, string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint), () => this.ComputeClient.ServiceCertificates.Create(this.ServiceName, CertUtilsNewSM.Create(context.X509Certificate))); } } var slotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true); DeploymentGetResponse d = null; InvokeInOperationContext(() => { try { d = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slotType); } catch (CloudException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false) { this.WriteExceptionDetails(ex); } } }); ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); extConfig = extensionMgr.Set(d, ExtensionConfiguration, this.Slot); } var deploymentInput = new DeploymentCreateParameters { PackageUri = packageUrl, Configuration = GeneralUtilities.GetConfiguration(this.Configuration), ExtensionConfiguration = extConfig, Label = this.Label, Name = this.Name, StartDeployment = !this.DoNotStart.IsPresent, TreatWarningsAsError = this.TreatWarningsAsError.IsPresent, }; InvokeInOperationContext(() => { try { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.CreatingNewDeployment); WriteProgress(progress); ExecuteClientActionNewSM( deploymentInput, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.Create( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), deploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.StorageClient, storageName, packageUrl)); } } catch (CloudException ex) { this.WriteExceptionDetails(ex); } }); }
/// <summary> /// Initializes a new instance of the OxideMod class /// </summary> public void Load() { RootDirectory = Environment.CurrentDirectory; if (RootDirectory.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))) { RootDirectory = AppDomain.CurrentDomain.BaseDirectory; } // Create the commandline commandline = new CommandLine(Environment.GetCommandLineArgs()); // Load the config var oxideConfig = Path.Combine(RootDirectory, "oxide.root.json"); if (!File.Exists(oxideConfig)) { throw new FileNotFoundException("Could not load Oxide root configuration", oxideConfig); } rootconfig = ConfigFile.Load <OxideConfig>(oxideConfig); // Work out the instance directory for (int i = 0; i < rootconfig.InstanceCommandLines.Length; i++) { string varname, format; rootconfig.GetInstanceCommandLineArg(i, out varname, out format); if (string.IsNullOrEmpty(varname) || commandline.HasVariable(varname)) { InstanceDirectory = Path.Combine(RootDirectory, CleanPath(string.Format(format, commandline.GetVariable(varname)))); break; } } if (InstanceDirectory == null) { throw new Exception("Could not identify instance directory"); } ExtensionDirectory = Path.Combine(RootDirectory, CleanPath(rootconfig.ExtensionDirectory)); PluginDirectory = Path.Combine(InstanceDirectory, CleanPath(rootconfig.PluginDirectory)); DataDirectory = Path.Combine(InstanceDirectory, CleanPath(rootconfig.DataDirectory)); LogDirectory = Path.Combine(InstanceDirectory, CleanPath(rootconfig.LogDirectory)); ConfigDirectory = Path.Combine(InstanceDirectory, CleanPath(rootconfig.ConfigDirectory)); if (!Directory.Exists(ExtensionDirectory)) { throw new Exception("Could not identify extension directory"); } if (!Directory.Exists(InstanceDirectory)) { Directory.CreateDirectory(InstanceDirectory); } if (!Directory.Exists(PluginDirectory)) { Directory.CreateDirectory(PluginDirectory); } if (!Directory.Exists(DataDirectory)) { Directory.CreateDirectory(DataDirectory); } if (!Directory.Exists(LogDirectory)) { Directory.CreateDirectory(LogDirectory); } if (!Directory.Exists(ConfigDirectory)) { Directory.CreateDirectory(ConfigDirectory); } RegisterLibrarySearchPath(Path.Combine(ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")); // Create the loggers RootLogger = new CompoundLogger(); RootLogger.AddLogger(new RotatingFileLogger { Directory = LogDirectory }); if (debugCallback != null) { RootLogger.AddLogger(new CallbackLogger(debugCallback)); } // Log Oxide core loading LogInfo("Loading Oxide core v{0}...", Version); // Create the managers RootPluginManager = new PluginManager(RootLogger) { ConfigPath = ConfigDirectory }; extensionmanager = new ExtensionManager(RootLogger); // Initialize other things DataFileSystem = new DataFileSystem(DataDirectory); // Register core libraries extensionmanager.RegisterLibrary("Global", new Global()); extensionmanager.RegisterLibrary("Time", new Time()); extensionmanager.RegisterLibrary("Timer", libtimer = new Timer()); extensionmanager.RegisterLibrary("Permission", new Permission()); extensionmanager.RegisterLibrary("Plugins", new Libraries.Plugins(RootPluginManager)); extensionmanager.RegisterLibrary("WebRequests", libwebrequests = new WebRequests()); extensionmanager.RegisterLibrary("Covalence", covalence = new Covalence()); // Load all extensions LogInfo("Loading extensions..."); extensionmanager.LoadAllExtensions(ExtensionDirectory); // Initialize covalence library after extensions (as it depends on things from within an ext) covalence.Initialize(); // If no clock has been defined, make our own if (getTimeSinceStartup == null) { timer = new Stopwatch(); timer.Start(); getTimeSinceStartup = () => (float)timer.Elapsed.TotalSeconds; } // Load all watchers foreach (var ext in extensionmanager.GetAllExtensions()) { ext.LoadPluginWatchers(PluginDirectory); } // Load all plugins LogInfo("Loading plugins..."); LoadAllPlugins(); // Hook all watchers foreach (var watcher in extensionmanager.GetPluginChangeWatchers()) { watcher.OnPluginSourceChanged += watcher_OnPluginSourceChanged; watcher.OnPluginAdded += watcher_OnPluginAdded; watcher.OnPluginRemoved += watcher_OnPluginRemoved; } }
public RootServiceProvider(ExtensionManager extensionManager) { this.extensionManager = extensionManager; this.serviceCache = new Dictionary<Type, object>(); this.serviceCache[typeof(ExtensionManager)] = extensionManager; }
/// <summary> /// Initializes a new instance of the GangBeastsExtension class /// </summary> /// <param name="manager"></param> public GangBeastsExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the SavageLandsExtension class /// </summary> /// <param name="manager"></param> public SavageLandsExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Usually filter implemented as extension and can be turned /// on and off. If it is not extension, defaulted to enabled. /// </summary> /// <param name="filter">Filter (extension) name</param> /// <returns>True if enabled</returns> public bool CustomFilterEnabled(string filter) { var ext = ExtensionManager.GetExtension(filter); return(ext == null ? true : ext.Enabled); }
public virtual void NewPaaSDeploymentProcess() { bool removePackage = false; AssertNoPersistenVmRoleExistsInDeployment(PVM.DeploymentSlotType.Production); AssertNoPersistenVmRoleExistsInDeployment(PVM.DeploymentSlotType.Staging); var storageName = CurrentContext.Subscription.GetProperty(Commands.Common.Models.AzureSubscription.Property.StorageAccount); Uri packageUrl; if (this.Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || this.Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(this.Package); } else { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; packageUrl = this.RetryCall(s => AzureBlob.UploadPackageToBlob( this.StorageClient, storageName, this.Package, null)); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { string errorConfigInput = null; if (!ExtensionManager.Validate(ExtensionConfiguration, out errorConfigInput)) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput)); } foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null && context.X509Certificate != null) { ExecuteClientActionNewSM( null, string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint), () => this.ComputeClient.ServiceCertificates.Create(this.ServiceName, CertUtilsNewSM.Create(context.X509Certificate))); } } var slotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true); DeploymentGetResponse d = null; InvokeInOperationContext(() => { try { d = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slotType); } catch (CloudException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false) { this.WriteExceptionDetails(ex); } } }); ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); extConfig = extensionMgr.Set(d, ExtensionConfiguration, this.Slot); } var deploymentInput = new DeploymentCreateParameters { PackageUri = packageUrl, Configuration = GeneralUtilities.GetConfiguration(this.Configuration), ExtensionConfiguration = extConfig, Label = this.Label, Name = this.Name, StartDeployment = !this.DoNotStart.IsPresent, TreatWarningsAsError = this.TreatWarningsAsError.IsPresent, }; InvokeInOperationContext(() => { try { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.CreatingNewDeployment); WriteProgress(progress); ExecuteClientActionNewSM( deploymentInput, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.Create( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), deploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.StorageClient, storageName, packageUrl)); } } catch (CloudException ex) { this.WriteExceptionDetails(ex); } }); }
/// <summary> /// Initializes a new instance of the ReignOfKingsExtension class /// </summary> /// <param name="manager"></param> public ReignOfKingsExtension(ExtensionManager manager) : base(manager) { }
/// <summary> /// Initializes a new instance of the Extension class /// </summary> /// <param name="manager"></param> public Extension(ExtensionManager manager) { Manager = manager; IsGameExtension = GetType().FullName.StartsWith("Oxide.Game."); }
public OpenModRustOxideDevExtension(ExtensionManager manager) : base(manager) { var assemblyVersion = GetType().Assembly.GetName().Version; Version = new VersionNumber(assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build); }