public MenuService([NotNull] IServiceProvider serviceProvider) { if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); var menuProviders = new ExtensionsCache<MenuProviderInfo, IMenuProvider>(serviceProvider); _menuProvidersLookup = menuProviders .GetAllExtensions() .ToLookup( menuProvider => menuProvider.MenuName, StringComparer.OrdinalIgnoreCase); // WTF? menuProviders .GetAllExtensions() .OfType<IDynamicMenuProvider>() .Select( dynamicMenuProvider => { _menuCache.Drop(dynamicMenuProvider.MenuName); return dynamicMenuProvider.MenuChanged.Subscribe( arg => _menuChanged.OnNext(dynamicMenuProvider.MenuName)); }); _menuCache = new ElementsCache<string, IMenuRoot>(CreateMenu); }
public MenuService([NotNull] IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } var menuProviders = new ExtensionsCache <MenuProviderInfo, IMenuProvider>(serviceProvider); _menuProvidersLookup = menuProviders .GetAllExtensions() .ToLookup( menuProvider => menuProvider.MenuName, StringComparer.OrdinalIgnoreCase); // WTF? menuProviders .GetAllExtensions() .OfType <IDynamicMenuProvider>() .Select( dynamicMenuProvider => { _menuCache.Drop(dynamicMenuProvider.MenuName); return (dynamicMenuProvider.MenuChanged.Subscribe( arg => _menuChanged.OnNext(dynamicMenuProvider.MenuName))); }); _menuCache = new ElementsCache <string, IMenuRoot>(CreateMenu); }
public StatsFormatterManager(IServiceProvider provider) { _formatters = new ElementsCache<string, IStatisticsFormatter>( name => { var regSvc = provider.GetService<RegSvc>(); if (regSvc == null || !regSvc.ContainsElement(name)) return new DefaultFormatter(name); return (IStatisticsFormatter)regSvc.GetElement(name).Type.CreateInstance(provider); }); }
private void button5_Click(object sender, EventArgs e) { if (listBox1.SelectedIndices.Count != 3) { MessageBox.Show("Нужно выбрать 3 множества!", "Сообщение"); return; } int id = listBox1.SelectedIndices[0]; ContinuousFuzzySet <double, double> A = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id); id = listBox1.SelectedIndices[1]; ContinuousFuzzySet <double, double> B = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id); id = listBox1.SelectedIndices[2]; ContinuousFuzzySet <double, double> C = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id); if (A.Cardinality() + B.Cardinality() + C.Cardinality() != 3 * A.Cardinality()) { MessageBox.Show("Sets must have equals cardinality!!!", "Message"); return; } ContinuousFuzzySet <double, double> L = null; ContinuousFuzzySet <double, double> R = null; ViewSet(A, "Set A", chart11); ViewSet(B, "Set B", chart12); ViewSet(FuzzyOperations.Inversion(B), "not(B)", chart13); ViewSet(C, "Set C", chart14); ContinuousFuzzySet <double, double> Q = FuzzyOperations.Sum(C, FuzzyOperations.Inversion(B)); ViewSet(Q, "not(B) + C", chart15); L = FuzzyOperations.Multiply(A, Q); ViewSet(L, "A * (not(B) + C)", chart16); ContinuousFuzzySet <double, double> Op1 = FuzzyOperations.Multiply(A, FuzzyOperations.Inversion(B)); ContinuousFuzzySet <double, double> Op2 = FuzzyOperations.Multiply(A, C); ViewSet(Op1, "A * not(B)", chart17); ViewSet(Op2, "A * C", chart18); R = FuzzyOperations.Sum(Op1, Op2); ViewSet(R, "(A*not(B)+(A*C)", chart19); double d1 = FuzzySetDescriptor.EuclidianDistance(L, R); double d2 = FuzzySetDescriptor.HammingDistance(L, R); label8.Text = "Расстояние Эвклида: " + d1.ToString(); label9.Text = "Расстояние Хемминга: " + d2.ToString(); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } ContinuousFuzzySet <double, double> set = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(listBox1.SelectedIndex); ViewSet(set, chart1); }
public DBDriverManager(IServiceProvider provider) { _provider = provider; _cache = new ElementsCache<string, IDBDriver>( name => { var svc = _provider.GetService<DriverSvc>(); if (svc == null || !svc.ContainsElement(name)) throw new ArgumentException("Unknown driver '{0}'".FormatStr(name)); return (IDBDriver)svc.GetElement(name).Type.CreateInstance(_provider); }); }
public StatsFormatterManager(IServiceProvider provider) { _formatters = new ElementsCache <string, IStatisticsFormatter>( name => { var regSvc = provider.GetService <RegSvc>(); if (regSvc == null || !regSvc.ContainsElement(name)) { return(new DefaultFormatter(name)); } return((IStatisticsFormatter)regSvc.GetElement(name).Type.CreateInstance(provider)); }); }
private void button2_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } ElementsCache.RemoveAt(listBox1.SelectedIndex); listBox1.Items.RemoveAt(listBox1.SelectedIndex); if (listBox1.Items.Count == 0) { chart1.Series.Clear(); } }
public DBDriverManager(IServiceProvider provider) { _provider = provider; _cache = new ElementsCache <string, IDBDriver>( name => { var svc = _provider.GetService <DriverSvc>(); if (svc == null || !svc.ContainsElement(name)) { throw new ArgumentException("Unknown driver '{0}'".FormatStr(name)); } return((IDBDriver)svc.GetElement(name).Type.CreateInstance(_provider)); }); }
private void button1_Click(object sender, EventArgs e) { try { double left = Double.Parse(textBox1.Text); double right = Double.Parse(textBox2.Text); double step = Double.Parse(textBox3.Text); double a = Double.Parse(textBox4.Text); double b = Double.Parse(textBox5.Text); ContinuousFuzzySet <double, double> set = null; switch (comboBox1.SelectedIndex) { case 0: FuzzySetCreator <double, double> .MemberShipFunction3 SFunction = new FuzzySetCreator <double, double> .MemberShipFunction3(FuzzyHelper.SFunction); set = FuzzySetCreator <double, double> .CreateInstance(SFunction, left, right, step, a, b); ElementsCache.Add(set); break; case 1: FuzzySetCreator <double, double> .MemberShipFunction3 ZFunction = new FuzzySetCreator <double, double> .MemberShipFunction3(FuzzyHelper.ZFunction); set = FuzzySetCreator <double, double> .CreateInstance(ZFunction, left, right, step, a, b); ElementsCache.Add(set); break; case 2: FuzzySetCreator <double, double> .MemberShipFunction4 PFunction = new FuzzySetCreator <double, double> .MemberShipFunction4(FuzzyHelper.PFunction); double c = Double.Parse(textBox7.Text); set = FuzzySetCreator <double, double> .CreateInstance(PFunction, left, right, step, a, b, c); ElementsCache.Add(set); break; default: throw new Exception("The membership function hasn't been selected."); } listBox1.Items.Add("Set #" + ElementsCache.Count.ToString()); ViewSet(set, chart1); } catch (Exception ex) { string message = "An exception has occured. Details: " + ex.Message; MessageBox.Show(message, "Message"); } }
public ForumImageManager(IServiceProvider provider) { var styler = provider.GetRequiredService <IStyleImageManager>(); const string prefix = @"MessageTree\"; _msgImage = styler.GetImage(prefix + "Msg", StyleImageType.ConstSize); _msgUnreadImage = styler.GetImage(prefix + "MsgUnread", StyleImageType.ConstSize); _msgArticleImage = styler.GetImage(prefix + "MsgArticle", StyleImageType.ConstSize); _msgArticleUnreadImage = styler.GetImage(prefix + "MsgArticleUnread", StyleImageType.ConstSize); _mdrImage = styler.GetImage(prefix + "Moderatorial", StyleImageType.ConstSize); _mdrRepliesImage = styler.GetImage(prefix + "Moderatorials", StyleImageType.ConstSize); _closedImage = styler.GetImage(prefix + "Closed", StyleImageType.ConstSize); _unreadRepliesToMeImage = styler.GetImage(prefix + "UnreadRepliesToMe", StyleImageType.ConstSize); for (var i = 0; i < 7; i++) { var si = i.ToString(); _dayOfWeekImages[i] = styler.GetImage(prefix + "WD" + si, StyleImageType.ConstSize); _outdatedDayOfWeekImages[i] = styler.GetImage(prefix + "WDOUT" + si, StyleImageType.ConstSize); } //иконки для классов пользователей _userImages[UserClass.User] = styler.GetImage(prefix + "User", StyleImageType.ConstSize); _userImages[UserClass.Anonym] = styler.GetImage(prefix + "UserAnonym", StyleImageType.ConstSize); _userImages[UserClass.Team] = styler.GetImage(prefix + "UserTeam", StyleImageType.ConstSize); _userImages[UserClass.Moderator] = styler.GetImage(prefix + "UserModerator", StyleImageType.ConstSize); _userImages[UserClass.Admin] = styler.GetImage(prefix + "UserAdmin", StyleImageType.ConstSize); _userImages[UserClass.Expert] = styler.GetImage(prefix + "UserExpert", StyleImageType.ConstSize); _userImages[UserClass.Group] = styler.GetImage(prefix + "UserGroup", StyleImageType.ConstSize); _markImage = styler.GetImage(prefix + "Mark", StyleImageType.ConstSize); _marksImage = styler.GetImage(prefix + "Marks", StyleImageType.ConstSize); _autoReadImage = styler.GetImage(prefix + "ReadReplies", StyleImageType.ConstSize); const string navPrefix = @"NavTree\"; _forumImage = styler.GetImage(navPrefix + "Forum", StyleImageType.ConstSize); _forumUnreadImage = styler.GetImage(navPrefix + "ForumUnread", StyleImageType.ConstSize); _inTopImage = styler.GetImage(navPrefix + "InTopSign", StyleImageType.ConstSize); _images = new ElementsCache <MsgImageKey, Image>(CreateMsgImage); _forumImages = new ElementsCache <ForumImageKey, Image>(CreateForumImage); }
private void button4_Click(object sender, EventArgs e) { if (listBox1.SelectedIndices.Count != 2) { MessageBox.Show("Нужно выбрать 2 множества!", "Сообщение"); return; } int id = listBox1.SelectedIndices[0]; ContinuousFuzzySet <double, double> A = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id); id = listBox1.SelectedIndices[1]; ContinuousFuzzySet <double, double> B = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id); if (A.Cardinality() != B.Cardinality()) { MessageBox.Show("Sets must have equals cardinality!!!", "Message"); return; } ContinuousFuzzySet <double, double> Op1 = null; ContinuousFuzzySet <double, double> Op2 = null; ViewSet(A, "Set A", chart2); ViewSet(B, "Set B", chart3); ContinuousFuzzySet <double, double> C = FuzzyOperations.Sum(A, B); Op1 = FuzzyOperations.Inversion(C); ViewSet(C, "A + B", chart4); ViewSet(Op1, "not(A + B)", chart5); ViewSet(A, "Set A", chart6); ViewSet(B, "Set B", chart7); ViewSet(FuzzyOperations.Inversion(A), "not(A)", chart8); ViewSet(FuzzyOperations.Inversion(B), "not(B)", chart9); Op2 = FuzzyOperations.Multiply(FuzzyOperations.Inversion(A), FuzzyOperations.Inversion(B)); ViewSet(Op2, "not(A) * not(B)", chart10); double d1 = FuzzySetDescriptor.EuclidianDistance(Op1, Op2); double d2 = FuzzySetDescriptor.HammingDistance(Op1, Op2); label6.Text = "Расстояние Эвклида: " + d1.ToString(); label7.Text = "Расстояние Хемминга: " + d2.ToString(); }
private void button3_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } ListBox.SelectedIndexCollection items = listBox1.SelectedIndices; textBox6.Text = string.Empty; for (int i = 0; i < items.Count; i++) { ContinuousFuzzySet <double, double> set = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(i); double val = FuzzySetDescriptor.Entropy(set); textBox6.AppendText("Энтропия множества #" + i.ToString() + ": " + val.ToString() + "\r\n"); } for (int i = 0; i < items.Count; i++) { for (int j = i + 1; j < items.Count; j++) { textBox6.AppendText("Эвклидово расстояние между " + (i + 1).ToString() + " и " + (j + 1).ToString() + ": "); ContinuousFuzzySet <double, double> set1 = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(i); ContinuousFuzzySet <double, double> set2 = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(j); if (set1.Cardinality() != set2.Cardinality()) { textBox6.AppendText("Sets must have equals cardinality!!!"); return; } double distance = 0; distance = FuzzySetDescriptor.EuclidianDistance(set1, set2); textBox6.AppendText(distance.ToString() + "\r\n"); textBox6.AppendText("Расстояние Хемминга между " + (i + 1).ToString() + " и " + (j + 1).ToString() + ": "); distance = FuzzySetDescriptor.HammingDistance(set1, set2); textBox6.AppendText(distance.ToString() + "\r\n"); } } }
private void открытьToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.FileName = string.Empty; openFileDialog1.ShowDialog(); string file = openFileDialog1.FileName; try { StreamReader reader = new StreamReader(file); string line = string.Empty; ICollection <KeyValuePair <double, double> > list = new List <KeyValuePair <double, double> >(); while (!reader.EndOfStream) { line = reader.ReadLine(); string[] items = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (items.Length != 2) { throw new IOException("Incorrect number of arguments!"); } KeyValuePair <double, double> pair = new KeyValuePair <double, double>(Convert.ToDouble(items[0]), Convert.ToDouble(items[1])); list.Add(pair); } ContinuousFuzzySet <double, double> set = new ContinuousFuzzySet <double, double>(list); ElementsCache.Add(set); listBox1.Items.Add("Set #" + ElementsCache.Count.ToString()); ViewSet(set, chart1); } catch (Exception ex) { string message = "An exception has occured. Details: " + ex.Message; MessageBox.Show(message, "Message"); } }
private IHtmlAttributeValueType GetAttributeValueType(string name) { return(ElementsCache.GetAttributeValueType(name, null)); }