本文整理汇总了C#中IExtension类的典型用法代码示例。如果您正苦于以下问题:C# IExtension类的具体用法?C# IExtension怎么用?C# IExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IExtension类属于命名空间,在下文中一共展示了IExtension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Remove
/// <summary>
/// Removes an extension from the current session.
/// </summary>
/// <param name="extension">Extension</param>
public void Remove(IExtension extension)
{
var fullName = extension.Name + " (id: " + extension.UniqueId + ")";
if (!extensions.Contains(extension))
{
Log("ExtensionManager does not contain " + fullName + " extension");
return;
}
extensions.Remove(extension);
try
{
extension.Dispose();
}
catch (Exception ex)
{
Log(fullName + " extension cannot be disposed properly: " + ex.Message);
}
Log(fullName + " extension is removed");
if (ExtensionRemoved != null)
{
ExtensionRemoved(extension);
}
}
示例2: SongRequestsWindow
public SongRequestsWindow(IExtension sender)
{
extension = sender;
InitializeComponent();
ini = SongRequest.ini; new Settings(extension, "Settings.ini");
UI.CenterSpacer(RequestingRulesLabel, RequestingRulesSpacer, false, true);
ChargeRequest.Text = "Requesting costs " + Currency.Name;
ini.SetValue("Settings", "ChargeRequest", (ChargeRequest.Checked = (ini.GetValue("Settings", "ChargeRequest", "1") == "1")) ? "1" : "0");
int variable = Convert.ToInt32(ini.GetValue("Settings", "RequestPrice", "25"));
if (variable > RequestPrice.Maximum || variable < RequestPrice.Minimum)
{
variable = 25;
}
ini.SetValue("Settings", "RequestPrice", (RequestPrice.Value = variable).ToString());
ini.SetValue("Settings", "LimitRequests", (LimitRequests.Checked = (ini.GetValue("Settings", "LimitRequests", "1") == "1")) ? "1" : "0");
variable = Convert.ToInt32(ini.GetValue("Settings", "RequestsLimit", "2"));
if (variable > RequestsLimit.Maximum || variable < RequestsLimit.Minimum)
{
variable = 2;
}
ini.SetValue("Settings", "RequestsLimit", (RequestsLimit.Value = variable).ToString());
}
示例3: Assign
/// <inheritdoc />
public void Assign(IReflectExtensionProperties reflector, IExtension extension, IConsumeConfiguration consumer, IHaveConversionCallbacks conversionCallbacksProvider, IHaveDefaultConversionCallback defaultConversionCallbackProvider)
{
Ensure.ArgumentNotNull(reflector, "reflector");
Ensure.ArgumentNotNull(consumer, "consumer");
Ensure.ArgumentNotNull(conversionCallbacksProvider, "conversionCallbacksProvider");
Ensure.ArgumentNotNull(defaultConversionCallbackProvider, "defaultConversionCallbackProvider");
var properties = reflector.Reflect(extension).ToList();
IDictionary<string, IConversionCallback> conversionCallbacks = conversionCallbacksProvider.ConversionCallbacks;
IConversionCallback defaultCallback = defaultConversionCallbackProvider.DefaultConversionCallback;
foreach (KeyValuePair<string, string> keyValuePair in consumer.Configuration)
{
KeyValuePair<string, string> pair = keyValuePair;
var matchedProperty = properties.SingleOrDefault(property => property.Name.Equals(pair.Key, StringComparison.OrdinalIgnoreCase));
if (matchedProperty == null)
{
continue;
}
IConversionCallback conversionCallback;
if (!conversionCallbacks.TryGetValue(pair.Key, out conversionCallback))
{
conversionCallback = defaultCallback;
}
matchedProperty.SetValue(extension, conversionCallback.Convert(pair.Value, matchedProperty), null);
}
}
示例4: Assign
/// <inheritdoc />
public void Assign(IReflectExtensionProperties reflector, IExtension extension, IConsumeConfiguration consumer, IHaveConversionCallbacks callbackProvider)
{
Ensure.ArgumentNotNull(reflector, "reflector");
Ensure.ArgumentNotNull(consumer, "consumer");
Ensure.ArgumentNotNull(callbackProvider, "callbackProvider");
IEnumerable<PropertyInfo> properties = reflector.Reflect(extension);
IDictionary<string, Func<string, PropertyInfo, object>> conversionCallbacks = callbackProvider.ConversionCallbacks;
Func<string, PropertyInfo, object> defaultCallback = callbackProvider.DefaultConversionCallback;
foreach (KeyValuePair<string, string> keyValuePair in consumer.Configuration)
{
KeyValuePair<string, string> pair = keyValuePair;
var matchedProperty = properties.Where(property => property.Name.Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
.SingleOrDefault();
if (matchedProperty == null)
{
continue;
}
Func<string, PropertyInfo, object> conversionCallback;
if (!conversionCallbacks.TryGetValue(pair.Key, out conversionCallback))
{
conversionCallback = defaultCallback;
}
matchedProperty.SetValue(extension, conversionCallback(pair.Value, matchedProperty), null);
}
}
示例5: GetPackageFromExtension
public IPackage GetPackageFromExtension(IExtension extension)
{
string id = extension.AssemblyQualifiedName.Substring(0, extension.AssemblyQualifiedName.IndexOf(',')); // Grab the part prior to the first comma
id = id.Substring(0, id.LastIndexOf('.')); // Grab the part prior to the last period
var pack = packages.GetLocalPackage(id);
return pack;
}
示例6: RegisterViews
public void RegisterViews(IExtension owner, params View[] views)
{
foreach (var v in views)
{
RegisterView(owner, v);
}
}
示例7: ExtensionProviderExtensionsTest
public ExtensionProviderExtensionsTest()
{
this.provider = A.Fake<IExtensionProvider<IExtension>>();
this.extension = A.Fake<IExtension>();
this.exception = new Exception();
}
示例8: GiveawaysWindow
public GiveawaysWindow(IExtension sender)
{
InitializeComponent();
ini = new Settings(sender, "Settings.ini", "[Default]");
UI.CenterSpacer(GiveawayTypeLabel, GiveawayTypeSpacer);
UI.CenterSpacer(GiveawaySettingsLabel, GiveawaySettingsSpacer, false, true);
UI.CenterSpacer(GiveawayBansLabel, GiveawayBansSpacer);
UI.CenterSpacer(GiveawayUsersLabel, GiveawayUsersSpacer);
Panel panel = new Panel();
panel.Size = new Size(1, 1);
panel.Location = new Point(GiveawayTypeSpacer.Location.X + GiveawayTypeSpacer.Size.Width - 1, GiveawayTypeSpacer.Location.Y + 9);
Controls.Add(panel);
panel.BringToFront();
panel = new Panel();
panel.Size = new Size(1, 1);
panel.Location = new Point(GiveawayBansSpacer.Location.X + GiveawayBansSpacer.Size.Width - 1, GiveawayBansSpacer.Location.Y + 9);
Controls.Add(panel);
panel.BringToFront();
/*panel.BackColor = Color.Black;
panel.Size = new Size(Giveaway_AddPresent.Size.Width + Giveaway_RemovePresent.Size.Width, 1);
panel.Location = new Point(Giveaway_AddPresent.Location.X, Giveaway_AddPresent.Location.Y + 1);
Controls.Add(panel);
panel.BringToFront();*/
}
示例9: HaveDefaultConversionCallback
/// <summary>
/// Initializes a new instance of the <see cref="HaveDefaultConversionCallback"/> class.
/// </summary>
/// <param name="extension">The extension.</param>
public HaveDefaultConversionCallback(IExtension extension)
{
var callbacksProvider = extension as IHaveDefaultConversionCallback;
this.DefaultConversionCallback = callbacksProvider != null
? callbacksProvider.DefaultConversionCallback
: new DefaultConversionCallback();
}
示例10: HaveConversionCallbacks
/// <summary>
/// Initializes a new instance of the <see cref="HaveConversionCallbacks"/> class.
/// </summary>
/// <param name="extension">The extension.</param>
public HaveConversionCallbacks(IExtension extension)
{
var callbacksProvider = extension as IHaveConversionCallbacks;
this.ConversionCallbacks = callbacksProvider != null
? callbacksProvider.ConversionCallbacks
: new Dictionary<string, IConversionCallback>();
}
示例11: Load
public static void Load(IExtension sender)
{
extension = sender;
Events.Connected += Events_Connected;
Events.Currency.OnQueue += Events_OnCurrencyQueue;
Events.OnDisconnect += Events_OnDisconnect;
}
示例12: ConsumeConfiguration
/// <summary>
/// Initializes a new instance of the <see cref="ConsumeConfiguration"/> class.
/// </summary>
/// <param name="extension">The extension.</param>
public ConsumeConfiguration(IExtension extension)
{
var consumeConfiguration = extension as IConsumeConfiguration;
this.Configuration = consumeConfiguration != null
? consumeConfiguration.Configuration
: new Dictionary<string, string>();
}
示例13: GetPackageFromExtension
public IPackage GetPackageFromExtension(IExtension extension)
{
string id = extension.AssemblyQualifiedName.Substring(0, extension.AssemblyQualifiedName.IndexOf(',')); // Grab the part prior to the first comma
if (id.Contains("."))
id = id.Substring(0, id.LastIndexOf('.')); // Grab the part prior to the last period, only if id contains period (Changed by JLeiss)
var pack = packages.GetLocalPackage(id);
return pack;
}
示例14: SendMessage
public void SendMessage(IExtension sender, string receiver, string command, params object[] arguments)
{
if(sender==null)
throw new ArgumentNullException(nameof(sender));
if (_extensions.ContainsKey(receiver))
{
_extensions[receiver].ExtensionMessageReceived(sender,command,arguments);
}
}
示例15: Host
//private Scene m_scene;
public Host(IObject obj, Scene scene, IExtension extend, IMicrothreader threader)
{
this.m_obj = obj;
this.m_threader = new MicrothreaderWrapper(threader);
this.m_extend = new ExtensionWrapper(extend);
//this.m_scene = m_scene;
m_graphics = new GraphicsWrapper(new Graphics(scene, this));
}