private void btnOK_Click(object sender, EventArgs e) { Resources.Resource resource = null; switch (this.cmbResourceType.SelectedItem.ToString()) { case "Sequence File": resource = new Resources.SeqFileResource( txtDisplayName.Text, txtFilename.Text); break; case "Weight File": resource = new Resources.WgtFileResource( txtDisplayName.Text, txtFilename.Text); break; case "PSSM": break; case "Family": resource = new Resources.CompositeResource(txtFilename.Text); break; } resource.Notes = txtNotes.Text; Program.CurrentResources.Root.Add(resource, txtFamily.Text); this.DialogResult = DialogResult.OK; Close(); }
public DynResourceForm(Resources.Resource resource) { InitializeComponent(); this.cmbResourceType.Items.Add(resource.ResourceType); cmbResourceType.SelectedIndex = 0; /// this must be after the combobox item is changed /// because the combobox item change deletes the current resource /// and generates a new default resource of the given type SelectedResource = resource; fieldFamily.Readonly = true; fieldFamily.SelectedResource = resource.Parent; fieldName.Readonly = true; fieldName.FieldText = resource.Name; textField1.Readonly = true; textField1.FieldText = resource.ID.ToString(); /// now fill in the field values foreach (FieldValueList fieldValue in SelectedResource.Fields.Values) { this.Fields[fieldValue.Type.Name].LoadFromFieldValue(fieldValue); } }
private void btnWgtBrowse_Click(object sender, EventArgs e) { FamiliesForm familiesForm = new FamiliesForm(); if (familiesForm.ShowDialog() == DialogResult.OK) { Weights = familiesForm.SelectedResource; txtWgtFile.Text = familiesForm.SelectedResource.QualifiedName; } }
private TreeNode CreateTreeNode(Resources.Resource resource) { TreeNode treeNode = new TreeNode(); treeNode.Tag = resource; SetupNode(treeNode); return(treeNode); }
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { Resources.Resource resource = (Resources.Resource)e.Node.Tag; DynResourceForm form = new DynResourceForm(resource); if (form.ShowDialog() == DialogResult.OK) { Controller.CurrentResources.SaveResources(); SetupNode(e.Node); BuildTree(e.Node); } }
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { Resources.Resource resource = (Resources.Resource)e.Node.Tag; DynResourceForm form = new DynResourceForm(resource); if (form.ShowDialog() == DialogResult.OK) { Controller.CurrentResources.SaveResources(); // TODO: do this more economically, since only one resource has to be updated BuildTree(); } }
private void btnSelect_Click(object sender, EventArgs e) { if (SelectedResource == null) { SelectedResource = Controller.CurrentResources.FindResource(this.txtFamilyName.Text); if (SelectedResource == null) { return; } } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnRemove_Click(object sender, EventArgs e) { Resources.Resource resource = (Resources.Resource)treeView1.SelectedNode.Tag; string qualifiedname = resource.QualifiedName; if (System.Windows.Forms.MessageBox.Show(this, "This will remove the " + qualifiedname + " resource and all its sub-resources. Are you sure?", "Removing resources", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2 ) == DialogResult.OK) { resource.MyParent.Children.Remove(resource.Name); treeView1.SelectedNode.Remove(); } }
private void btnSelect_Click(object sender, EventArgs e) { if (SelectedResource == null) { SelectedResource = Controller.CurrentResources.FindResource(this.txtFamilyName.Text); if (SelectedResource == null) { return; } } InternalRefFieldType.Mask mask = (InternalRefFieldType.Mask) this.comboBox1.SelectedItem; if (mask.IsAccepted(SelectedResource.MyType)) { this.DialogResult = DialogResult.OK; this.Close(); } }
public ResourceForm(Resources.Resource resource) { InitializeComponent(); if (resource.Parent != null) { Family = resource.Parent.QualifiedName; } btnFamilyBrowse.Enabled = false; /// name and notes are subject to change DisplayName = resource.Name; Notes = resource.Notes; btnFilenameBrowse.Enabled = false; if (resource is Resources.FileResource) { Filename = (resource as Resources.FileResource).Filename; } cmbResourceType.Items.Add(new ResourceTypeItem(resource)); cmbResourceType.SelectedIndex = 0; }
public DynResourceForm(Resources.Resource resource) { InitializeComponent(); InitStaticFields( resource.Name, (resource.MyParent != null) ? resource.MyParent.QualifiedName : string.Empty ); this.cmbResourceType.Items.Add(resource.MyType); cmbResourceType.SelectedIndex = 0; /// this must be after the combobox item is changed /// because the combobox item change deletes the current resource /// and generates a new default resource of the given type SelectedResource = resource; //fieldFamily.Readonly = true; //fieldName.Readonly = true; //fieldParent.Readonly = true; //fieldName.Readonly = true; //textField1.Readonly = true; //textField1.FieldText = resource.ID.ToString(); }
private TreeNode CreateTreeNode(Resources.Resource resource) { TreeNode treeNode = new TreeNode(resource.Name); treeNode.Name = resource.QualifiedName; treeNode.Tag = resource; switch (resource.GetType().Name) { case "CompositeResource": treeNode.BackColor = this.lblFamilyColor.BackColor; break; case "SeqFileResource": treeNode.BackColor = this.lblSequenceColor.BackColor; break; case "WgtFileResource": treeNode.BackColor = this.lblWeightColor.BackColor; break; } // TODO: change the color of node according to type return(treeNode); }
private void button6_Click(object sender, EventArgs e) { Resources.Resource parent = null; /// only composite resources can have a sub-resource if (treeView1.SelectedNode != null) { parent = ((Resources.Resource)treeView1.SelectedNode.Tag); } else { parent = (Resources.Resource) this.treeView1.Nodes[0].Tag; } Resources.Resource resource = new Resources.Resource( Guid.NewGuid(), Controller.CurrentResources.ResourceTypes["Family"], "new family"); int attempt = 2; while (parent.Children[resource.Name] != null) { /// this family already exists in the parent, try another one resource.Name = "new family " + attempt++; } parent.Children.Add(resource); TreeNode treeNode = CreateTreeNode(resource); AddNode(treeView1.SelectedNode, treeNode); treeView1.SelectedNode.Expand(); treeNode.BeginEdit(); // TODO: add this to the resource tree? }
private void btnSelect_Click(object sender, EventArgs e) { if (SelectedResource == null) { SelectedResource = Controller.CurrentResources.FindResource(this.txtFamilyName.Text); if (SelectedResource == null) return; } this.DialogResult = DialogResult.OK; this.Close(); }
public ResourceTypeItem(Resources.Resource resource) { _resource = resource; }
private static void ValidateHttpWebRequestActivity(Activity activityToValidate, Resources.Resource expectedResource, bool responseExpected) { Assert.Equal(ActivityKind.Client, activityToValidate.Kind); Assert.Equal(expectedResource, activityToValidate.GetResource()); }
public void ToOtlpResourceSpansTest(bool addResource, string optionsServiceName) { var evenTags = new[] { new KeyValuePair <string, object>("k0", "v0") }; var oddTags = new[] { new KeyValuePair <string, object>("k1", "v1") }; var sources = new[] { new ActivitySource("even", "2.4.6"), new ActivitySource("odd", "1.3.5"), }; var builder = Sdk.CreateTracerProviderBuilder() .AddSource(sources[0].Name) .AddSource(sources[1].Name); Resources.Resource resource = null; if (addResource) { resource = new Resources.Resource( new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(Resources.Resource.ServiceNameKey, "service-name"), new KeyValuePair <string, object>(Resources.Resource.ServiceNamespaceKey, "ns1"), }); builder.SetResource(resource); } using var openTelemetrySdk = builder.Build(); var processor = new BatchExportProcessor <Activity>(new TestExporter <Activity>(RunTest)); const int numOfSpans = 10; bool isEven; for (var i = 0; i < numOfSpans; i++) { isEven = i % 2 == 0; var source = sources[i % 2]; var activityKind = isEven ? ActivityKind.Client : ActivityKind.Server; var activityTags = isEven ? evenTags : oddTags; using Activity activity = source.StartActivity($"span-{i}", activityKind, parentContext: default, activityTags); processor.OnEnd(activity); } processor.Shutdown(); void RunTest(Batch <Activity> batch) { var request = new OtlpCollector.ExportTraceServiceRequest(); request.AddBatch( new OtlpExporter( new OtlpExporterOptions { ServiceName = optionsServiceName, }, new NoopTraceServiceClient()), batch); Assert.Single(request.ResourceSpans); var oltpResource = request.ResourceSpans.First().Resource; if (addResource) { Assert.Contains(oltpResource.Attributes, (kvp) => kvp.Key == Resources.Resource.ServiceNameKey && kvp.Value.StringValue == "service-name"); Assert.Contains(oltpResource.Attributes, (kvp) => kvp.Key == Resources.Resource.ServiceNamespaceKey && kvp.Value.StringValue == "ns1"); } else { Assert.Contains(oltpResource.Attributes, (kvp) => kvp.Key == Resources.Resource.ServiceNameKey && kvp.Value.StringValue == optionsServiceName); } foreach (var instrumentationLibrarySpans in request.ResourceSpans.First().InstrumentationLibrarySpans) { Assert.Equal(numOfSpans / 2, instrumentationLibrarySpans.Spans.Count); Assert.NotNull(instrumentationLibrarySpans.InstrumentationLibrary); var expectedSpanNames = new List <string>(); var start = instrumentationLibrarySpans.InstrumentationLibrary.Name == "even" ? 0 : 1; for (var i = start; i < numOfSpans; i += 2) { expectedSpanNames.Add($"span-{i}"); } var otlpSpans = instrumentationLibrarySpans.Spans; Assert.Equal(expectedSpanNames.Count, otlpSpans.Count); var kv0 = new OtlpCommon.KeyValue { Key = "k0", Value = new OtlpCommon.AnyValue { StringValue = "v0" } }; var kv1 = new OtlpCommon.KeyValue { Key = "k1", Value = new OtlpCommon.AnyValue { StringValue = "v1" } }; var expectedTag = instrumentationLibrarySpans.InstrumentationLibrary.Name == "even" ? kv0 : kv1; foreach (var otlpSpan in otlpSpans) { Assert.Contains(otlpSpan.Name, expectedSpanNames); Assert.Contains(expectedTag, otlpSpan.Attributes); } } } }
private static void ValidateAspNetCoreActivity(Activity activityToValidate, string expectedHttpPath, Resources.Resource expectedResource) { Assert.Equal(ActivityKind.Server, activityToValidate.Kind); Assert.Equal(expectedHttpPath, activityToValidate.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpPathKey).Value); Assert.Equal(expectedResource, activityToValidate.GetResource()); var request = activityToValidate.GetCustomProperty(HttpInListener.RequestCustomPropertyName); Assert.NotNull(request); Assert.True(request is HttpRequest); var response = activityToValidate.GetCustomProperty(HttpInListener.ResponseCustomPropertyName); Assert.NotNull(response); Assert.True(response is HttpResponse); }
private static void ValidateHttpWebRequestActivity(Activity activityToValidate, Resources.Resource expectedResource, bool responseExpected) { Assert.Equal(ActivityKind.Client, activityToValidate.Kind); Assert.Equal(expectedResource, activityToValidate.GetResource()); var request = activityToValidate.GetCustomProperty(HttpWebRequestActivitySource.RequestCustomPropertyName); Assert.NotNull(request); Assert.True(request is HttpWebRequest); if (responseExpected) { var response = activityToValidate.GetCustomProperty(HttpWebRequestActivitySource.ResponseCustomPropertyName); Assert.NotNull(response); Assert.True(response is HttpWebResponse); } }
private static void ValidateAspNetCoreActivity(Activity activityToValidate, string expectedHttpPath, Resources.Resource expectedResource) { Assert.Equal(ActivityKind.Server, activityToValidate.Kind); Assert.Equal(expectedHttpPath, activityToValidate.GetTagValue(SpanAttributeConstants.HttpPathKey) as string); Assert.Equal(expectedResource, activityToValidate.GetResource()); }
private void btnSelect_Click(object sender, EventArgs e) { if (SelectedResource == null) { SelectedResource = Controller.CurrentResources.FindResource(this.txtFamilyName.Text); if (SelectedResource == null) return; } InternalRefFieldType.Mask mask = (InternalRefFieldType.Mask) this.comboBox1.SelectedItem; if (mask.IsAccepted(SelectedResource.MyType)) { this.DialogResult = DialogResult.OK; this.Close(); } }
public void ToOtlpResourceSpansTest() { var evenTags = new[] { new KeyValuePair <string, object>("k0", "v0") }; var oddTags = new[] { new KeyValuePair <string, object>("k1", "v1") }; var sources = new[] { new ActivitySource("even", "2.4.6"), new ActivitySource("odd", "1.3.5"), }; var resource = new Resources.Resource( new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(Resources.Resource.ServiceNamespaceKey, "ns1"), }); // This following is done just to set Resource to Activity. using var openTelemetrySdk = Sdk.CreateTracerProviderBuilder() .AddSource(sources[0].Name) .AddSource(sources[1].Name) .SetResource(resource) .Build(); var activities = new List <Activity>(); Activity activity = null; const int numOfSpans = 10; bool isEven; for (var i = 0; i < numOfSpans; i++) { isEven = i % 2 == 0; var source = sources[i % 2]; var activityKind = isEven ? ActivityKind.Client : ActivityKind.Server; var activityTags = isEven ? evenTags : oddTags; activity = source.StartActivity($"span-{i}", activityKind, activity?.Context ?? default, activityTags); activities.Add(activity); } activities.Reverse(); var otlpResourceSpans = activities.ToOtlpResourceSpans(); Assert.Single(otlpResourceSpans); var oltpResource = otlpResourceSpans.First().Resource; Assert.Equal(resource.Attributes.First().Key, oltpResource.Attributes.First().Key); Assert.Equal(resource.Attributes.First().Value, oltpResource.Attributes.First().Value.StringValue); foreach (var instrumentationLibrarySpans in otlpResourceSpans.First().InstrumentationLibrarySpans) { Assert.Equal(numOfSpans / 2, instrumentationLibrarySpans.Spans.Count); Assert.NotNull(instrumentationLibrarySpans.InstrumentationLibrary); var expectedSpanNames = new List <string>(); var start = instrumentationLibrarySpans.InstrumentationLibrary.Name == "even" ? 0 : 1; for (var i = start; i < numOfSpans; i += 2) { expectedSpanNames.Add($"span-{i}"); } var otlpSpans = instrumentationLibrarySpans.Spans; Assert.Equal(expectedSpanNames.Count, otlpSpans.Count); var kv0 = new OtlpCommon.KeyValue { Key = "k0", Value = new AnyValue { StringValue = "v0" } }; var kv1 = new OtlpCommon.KeyValue { Key = "k1", Value = new AnyValue { StringValue = "v1" } }; var expectedTag = instrumentationLibrarySpans.InstrumentationLibrary.Name == "even" ? kv0 : kv1; foreach (var otlpSpan in otlpSpans) { Assert.Contains(otlpSpan.Name, expectedSpanNames); Assert.Contains(expectedTag, otlpSpan.Attributes); } } }
private void button6_Click(object sender, EventArgs e) { Resources.Resource parent = null; /// only composite resources can have a sub-resource if (treeView1.SelectedNode != null) parent = ((Resources.Resource)treeView1.SelectedNode.Tag); else parent = (Resources.Resource)this.treeView1.Nodes[0].Tag; Resources.Resource resource = new Resources.Resource ( Guid.NewGuid (), Controller.CurrentResources.ResourceTypes["Family"], "new family"); int attempt = 2; while(parent.Children[resource.Name] != null) { /// this family already exists in the parent, try another one resource.Name = "new family " + attempt++; } parent.Children.Add(resource); TreeNode treeNode = CreateTreeNode(resource); AddNode(treeView1.SelectedNode, treeNode); treeView1.SelectedNode.Expand(); treeNode.BeginEdit(); // TODO: add this to the resource tree? }