public PowerGeneratedPair(IResourceSupplier key, PowerGenerated value) { Key = key; Value = value; }
public double managedPowerSupplyPerSecond(IResourceSupplier pm, double power) { return(managedPowerSupplyPerSecondWithMinimumRatio(pm, power, 0)); }
public ErrorDetails(IResourceSupplier resourceSupplier, string baseName, string resourceId, params object[] args) { this._message = ""; this._recommendedAction = ""; this._message = this.BuildMessage(resourceSupplier, baseName, resourceId, args); }
private string BuildMessage(IResourceSupplier resourceSupplier, string baseName, string resourceId, params object[] args) { if (resourceSupplier == null) { throw PSTraceSource.NewArgumentNullException("resourceSupplier"); } if (string.IsNullOrEmpty(baseName)) { throw PSTraceSource.NewArgumentNullException("baseName"); } if (string.IsNullOrEmpty(resourceId)) { throw PSTraceSource.NewArgumentNullException("resourceId"); } string template = ""; try { template = resourceSupplier.GetResourceString(baseName, resourceId); } catch (MissingManifestResourceException exception) { this._textLookupError = exception; return ""; } catch (ArgumentException exception2) { this._textLookupError = exception2; return ""; } return this.BuildMessage(template, baseName, resourceId, args); }
} // BuildMessage private string BuildMessage( IResourceSupplier resourceSupplier, string baseName, string resourceId, params object[] args) { if (null == resourceSupplier) throw PSTraceSource.NewArgumentNullException("resourceSupplier"); if (String.IsNullOrEmpty(baseName)) throw PSTraceSource.NewArgumentNullException("baseName"); if (String.IsNullOrEmpty(resourceId)) throw PSTraceSource.NewArgumentNullException("resourceId"); string template = ""; try { template = resourceSupplier.GetResourceString(baseName, resourceId); } catch (MissingManifestResourceException e) { _textLookupError = e; return ""; // fallback to Exception.Message } catch (ArgumentException e) { _textLookupError = e; return ""; // fallback to Exception.Message } return BuildMessage(template, baseName, resourceId, args); } // BuildMessage
/// <summary> /// Creates an instance of ErrorDetails specifying a Message. /// This variant is used by CmdletProviders. /// </summary> /// <param name="resourceSupplier"> /// Resource supplier, most often an instance of /// <see cref="Provider.CmdletProvider"/>. /// </param> /// <param name="baseName">by default, the /// <see cref="System.Resources.ResourceManager"/> /// name</param> /// <param name="resourceId"> /// by default, the resourceId in the /// <see cref="System.Resources.ResourceManager"/> /// </param> /// <param name="args"> /// <see cref="System.String.Format(IFormatProvider,string,object[])"/> /// insertion parameters /// </param> /// <remarks> /// This variant is a shortcut to build an instance of /// <see cref="System.Management.Automation.ErrorDetails"/> /// reducing the steps which localizable code generally has to duplicate when it /// generates a localizable string. This variant is preferred over /// <see cref="System.Management.Automation.ErrorDetails(string)"/>, /// since the improved /// information about the error may help enable future scenarios. /// /// This constructor first loads a template string using /// <see cref="System.Management.Automation.IResourceSupplier.GetResourceString"/>. /// The default implementation of /// <see cref="Provider.CmdletProvider.GetResourceString"/> /// will load a string resource from the CmdletProvider assembly using /// <paramref name="baseName"/> and <paramref name="resourceId"/>; /// however, specific CmdletProviders can override this behavior /// by overriding virtual method /// <see cref="Provider.CmdletProvider.GetResourceString"/>, /// and it is also possible that PSSnapin custom classes /// which are not instances of /// <see cref="Provider.CmdletProvider"/> /// will implement /// <see cref="IResourceSupplier"/>. /// The constructor then inserts the specified args using /// <see cref="System.String.Format(IFormatProvider,string,object[])"/>. /// </remarks> public ErrorDetails( IResourceSupplier resourceSupplier, string baseName, string resourceId, params object[] args) { _message = BuildMessage(resourceSupplier, baseName, resourceId, args); }
public double PowerSupplyPerSecondWithMax(IResourceSupplier pm, double power, double maxPower) { return(PowerSupplyPerSecondWithMaxAndEfficiency(pm, power, maxPower, 1.0)); }
public double PowerSupplyFixedWithMax(IResourceSupplier pm, double power, double maxPower) { double timeWarpDt = Math.Min(PluginSettings.Config.MaxResourceProcessingTimewarp, (double)(decimal)TimeWarp.fixedDeltaTime); return(PowerSupplyPerSecondWithMaxAndEfficiency(pm, power / timeWarpDt, maxPower / timeWarpDt, 1.0)); }