public void HandleExceptionEvent_RecordsStats() { var options = new MetricsOptions(); var stats = new OpenCensusStats(); var tags = new OpenCensusTags(); var observer = new HttpClientCoreObserver(options, stats, tags, null); var req = GetHttpRequestMessage(); var resp = GetHttpResponseMessage(HttpStatusCode.InternalServerError); Activity act = new Activity("Test"); act.Start(); Thread.Sleep(1000); act.SetEndTime(DateTime.UtcNow); observer.HandleExceptionEvent(act, req); observer.HandleExceptionEvent(act, req); var reqData = stats.ViewManager.GetView(ViewName.Create("http.client.requests")); var aggData1 = reqData.SumWithTags() as IDistributionData; Assert.InRange(aggData1.Mean, 995.0, 1005.0); Assert.InRange(aggData1.Max, 995.0, 1005.0); reqData = stats.ViewManager.GetView(ViewName.Create("http.client.requests.count")); var aggData2 = reqData.SumWithTags() as ISumDataLong; Assert.Equal(2, aggData2.Sum); act.Stop(); }
public void HandleStopEvent_RecordsStats() { var options = new MetricsEndpointOptions(); var stats = new OpenCensusStats(); var tags = new OpenCensusTags(); var observer = new HttpClientDesktopObserver(options, stats, tags, null); var req = GetHttpRequestMessage(); Activity act = new Activity("Test"); act.Start(); Thread.Sleep(1000); act.SetEndTime(DateTime.UtcNow); observer.HandleStopEvent(act, req, HttpStatusCode.InternalServerError); observer.HandleStopEvent(act, req, HttpStatusCode.OK); var reqData = stats.ViewManager.GetView(ViewName.Create("http.desktop.client.request.time")); var aggData1 = MetricsHelpers.SumWithTags(reqData) as IDistributionData; Assert.InRange(aggData1.Mean, 990.0, 1025.0); Assert.InRange(aggData1.Max, 990.0, 1025.0); reqData = stats.ViewManager.GetView(ViewName.Create("http.desktop.client.request.count")); var aggData2 = MetricsHelpers.SumWithTags(reqData) as ISumDataLong; Assert.Equal(2, aggData2.Sum); act.Stop(); }
public void GetAllExportedViews() { IViewManager viewManager = NoopStats.NewNoopViewManager(); Assert.Empty(viewManager.AllExportedViews); IView cumulativeView1 = View.Create( ViewName.Create("View 1"), VIEW_DESCRIPTION, MEASURE, AGGREGATION, new List <ITagKey> { KEY }); IView cumulativeView2 = View.Create( ViewName.Create("View 2"), VIEW_DESCRIPTION, MEASURE, AGGREGATION, new List <ITagKey> { KEY }); viewManager.RegisterView(cumulativeView1); viewManager.RegisterView(cumulativeView2); // Only cumulative views should be exported. Assert.Equal(2, viewManager.AllExportedViews.Count); Assert.Contains(cumulativeView1, viewManager.AllExportedViews); Assert.Contains(cumulativeView2, viewManager.AllExportedViews); }
public override void WriteGroupCodes() { WriteGroupCodeValue(2, ViewName.Trim()); WriteGroupCodeValue(40, ViewHeight.ToString().Trim()); WriteGroupCodeValue(41, ViewWidth.ToString().Trim()); WriteGroupCodeValue(10, ViewCenterX.ToString().Trim()); WriteGroupCodeValue(20, ViewCenterY.ToString().Trim()); WriteGroupCodeValue(11, ViewDirectionX.ToString().Trim()); WriteGroupCodeValue(21, ViewDirectionY.ToString().Trim()); WriteGroupCodeValue(31, ViewDirectionZ.ToString().Trim()); WriteGroupCodeValue(12, ViewTargetX.ToString().Trim()); WriteGroupCodeValue(22, ViewTargetY.ToString().Trim()); WriteGroupCodeValue(32, ViewTargetZ.ToString().Trim()); WriteGroupCodeValue(42, LensLength.ToString().Trim()); WriteGroupCodeValue(43, FrontClippingPlaneOffset.ToString().Trim()); WriteGroupCodeValue(44, BackClippingPlaneOffset.ToString().Trim()); WriteGroupCodeValue(50, TwistAngle.ToString().Trim()); WriteGroupCodeValue(70, GetStandardFlags().ToString().Trim()); }
public async Task ShouldReturnTheAccountLinkSuccessView( string code, string accessToken, string idToken, string discordToken, Models.User discordUser, Guid identityUserId, [Substitute] HttpContext httpContext, [Frozen, Substitute] IUserService userService, [Target] OAuth2Controller controller ) { controller.ControllerContext = new ControllerContext { HttpContext = httpContext }; userService.GetDiscordUserInfo(Is(discordToken), Any <CancellationToken>()).Returns(discordUser); userService.GetUserIdFromIdentityToken(Is(idToken)).Returns(identityUserId); userService.ExchangeOAuth2CodeForToken(Is(code), Any <CancellationToken>()).Returns(discordToken); SetupHttpContext(httpContext, accessToken, idToken); SetupTempData(controller); var result = await controller.Callback(code) as ViewResult; result.Should().NotBeNull(); result !.ViewName.Should().Be("~/Users/Views/AccountLink.cshtml"); }
public OwinHostingObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <OwinHostingObserver> logger) : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger) { PathMatcher = new Regex(options.IngressIgnorePattern); responseTimeMeasure = MeasureDouble.Create("server.owin.totalTime", "Total request time", MeasureUnit.MilliSeconds); serverCountMeasure = MeasureLong.Create("server.owin.totalRequests", "Total request count", "count"); var view = View.Create( ViewName.Create("http.server.request.time"), "Total request time", responseTimeMeasure, Distribution.Create(BucketBoundaries.Create(new List <double>() { 0.0, 1.0, 5.0, 10.0, 100.0 })), new List <ITagKey>() { statusTagKey, exceptionTagKey, methodTagKey, uriTagKey }); ViewManager.RegisterView(view); view = View.Create( ViewName.Create("http.server.request.count"), "Total request counts", serverCountMeasure, Sum.Create(), new List <ITagKey>() { statusTagKey, exceptionTagKey, methodTagKey, uriTagKey }); ViewManager.RegisterView(view); }
public async Task NavigationWithoutNavigationBar(ViewName viewName) { var page = _pageFactory.GetPage(viewName); await Application.Current.MainPage.Navigation.PushAsync(page); NavigationPage.SetHasNavigationBar(page, false); }
public HttpClientDesktopObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <HttpClientDesktopObserver> logger) : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger) { PathMatcher = new Regex(options.EgressIgnorePattern); clientTimeMeasure = MeasureDouble.Create("client.desk.totalTime", "Total request time", MeasureUnit.MilliSeconds); clientCountMeasure = MeasureLong.Create("client.core.totalRequests", "Total request count", "count"); var view = View.Create( ViewName.Create("http.desktop.client.request.time"), "Total request time", clientTimeMeasure, Distribution.Create(BucketBoundaries.Create(new List <double>() { 0.0, 1.0, 5.0, 10.0, 100.0 })), new List <ITagKey>() { statusTagKey, uriTagKey, methodTagKey, clientTagKey }); ViewManager.RegisterView(view); view = View.Create( ViewName.Create("http.desktop.client.request.count"), "Total request counts", clientCountMeasure, Sum.Create(), new List <ITagKey>() { statusTagKey, uriTagKey, methodTagKey, clientTagKey }); ViewManager.RegisterView(view); }
public void HandleStopEvent_RecordsStats() { var options = new MetricsEndpointOptions(); var stats = new OpenCensusStats(); var tags = new OpenCensusTags(); var observer = new AspNetCoreHostingObserver(options, stats, tags, null); var context = GetHttpRequestMessage(); var exceptionHandlerFeature = new ExceptionHandlerFeature() { Error = new ArgumentNullException() }; context.Features.Set <IExceptionHandlerFeature>(exceptionHandlerFeature); context.Response.StatusCode = 500; Activity act = new Activity("Test"); act.Start(); Thread.Sleep(1000); act.SetEndTime(DateTime.UtcNow); observer.HandleStopEvent(act, context); observer.HandleStopEvent(act, context); var reqData = stats.ViewManager.GetView(ViewName.Create("http.server.request.time")); var aggData1 = reqData.SumWithTags() as IDistributionData; Assert.Equal(2, aggData1.Count); Assert.True(aggData1.Mean > 1000.00); Assert.True(aggData1.Max > 1000.00); act.Stop(); }
public void GetAllExportedViewsResultIsUnmodifiable() { IView view1 = View.Create( ViewName.Create("View 1"), VIEW_DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, new List <ITagKey>() { KEY }); viewManager.RegisterView(view1); ISet <IView> exported = viewManager.AllExportedViews; IView view2 = View.Create( ViewName.Create("View 2"), VIEW_DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, new List <ITagKey>() { KEY }); Assert.Throws <NotSupportedException>(() => exported.Add(view2)); }
public AuditLogForm(SkylineViewContext viewContext) : base(viewContext, AuditLogStrings.AuditLogForm_AuditLogForm_Audit_Log) { InitializeComponent(); _skylineWindow = viewContext.SkylineDataSchema.SkylineWindow; _clearLogButton = new ToolStripButton(AuditLogStrings.AuditLogForm_AuditLogForm_Clear_log); _enableAuditLogging = new CheckBox { Text = AuditLogStrings.AuditLogForm_AuditLogForm_Enable_audit_logging, Checked = Settings.Default.AuditLogging, BackColor = Color.Transparent }; var checkBoxHost = new ToolStripControlHost(_enableAuditLogging) { Alignment = ToolStripItemAlignment.Right }; NavBar.BindingNavigator.Items.Add(_clearLogButton); NavBar.BindingNavigator.Items.Add(checkBoxHost); if (!string.IsNullOrEmpty(Settings.Default.AuditLogView)) { var viewName = ViewName.Parse(Settings.Default.AuditLogView); if (viewName.HasValue) { DataboundGridControl.ChooseView(viewName.Value); } } }
/// <summary> /// Спавним ботов /// </summary> private void SpawBots() { int numberBot = 0; while (IsCanSpawnBot(numberBot)) { if (pathsContainer.Paths.Count == 0) { return; } Transform startPoint = CheckPosition(); Transform transformBot = Instantiate(prefabBot, startPoint.position, startPoint.rotation, parentCar); string nameDriver = NameBot(); transformBot.name = "Enemy_" + nameDriver; transformBot.GetComponent <DriverName>().Driver_Name = nameDriver; SpawnWaypointCircuit(nameDriver); WaypointProgressTracker newWaypointProgressTracker = transformBot.GetComponent <WaypointProgressTracker>(); newWaypointProgressTracker.circuit = newWaypointCircuit; newWaypointProgressTracker.Reset(); Color newBotColor = CheckColor(); AddColorBot(newBotColor, transformBot); ViewName viewName = Instantiate(prefabUi, Vector3.one * 1000, Quaternion.identity, parentUi); viewName.name = "ViewName_" + nameDriver; viewName.Init(transformBot, newBotColor, nameDriver); numberBot++; } }
public void TestGetAllExportedViews() { Assert.Empty(viewManager.AllExportedViews); IView cumulativeView1 = CreateCumulativeView( ViewName.Create("View 1"), MEASURE_DOUBLE, DISTRIBUTION, new List <ITagKey>() { KEY }); IView cumulativeView2 = CreateCumulativeView( ViewName.Create("View 2"), MEASURE_DOUBLE, DISTRIBUTION, new List <ITagKey>() { KEY }); // View intervalView = // View.Create( // View.Name.Create("View 3"), // VIEW_DESCRIPTION, // MEASURE_DOUBLE, // DISTRIBUTION, // Arrays.asList(KEY), // INTERVAL); viewManager.RegisterView(cumulativeView1); viewManager.RegisterView(cumulativeView2); // Only cumulative views should be exported. Assert.Contains(cumulativeView1, viewManager.AllExportedViews); Assert.Contains(cumulativeView2, viewManager.AllExportedViews); Assert.Equal(2, viewManager.AllExportedViews.Count); }
public ToReactivePropertyAsSynchronizedViewModel(ToReactivePropertyAsSynchronizedModel _model) { Model = _model.AddTo(DisposeCollection); IgnoreValidationErrorValueTrueInput = Model.IgnoreValidationErrorValueTrue.ToReactivePropertyAsSynchronized( x => x.Value, x => x.Name, x => String.IsNullOrEmpty(x) ? ViewName.NullObject : ViewName.Create(x), Reactive.Bindings.ReactivePropertyMode.Default | Reactive.Bindings.ReactivePropertyMode.IgnoreInitialValidationError, true ).SetValidateNotifyError(x => String.IsNullOrEmpty(x) ? "何か入力してください。" : null) .AddTo(DisposeCollection); ShowCommand.Subscribe(() => System.Windows.MessageBox.Show(Model.IgnoreValidationErrorValueTrue.Value.Name)).AddTo(DisposeCollection); IgnoreValidationErrorValueFalseInput = Model.IgnoreValidationErrorValueFalse.ToReactivePropertyAsSynchronized( x => x.Value, x => x.Name, x => String.IsNullOrEmpty(x) ? ViewName.NullObject : ViewName.Create(x), Reactive.Bindings.ReactivePropertyMode.Default | Reactive.Bindings.ReactivePropertyMode.IgnoreInitialValidationError, false ).SetValidateNotifyError(x => String.IsNullOrEmpty(x) ? "何か入力してください。" : null) .AddTo(DisposeCollection); Show2Command.Subscribe(() => System.Windows.MessageBox.Show(Model.IgnoreValidationErrorValueFalse.Value.Name)).AddTo(DisposeCollection); }
public static void Run(string projectId) { // 5. Start Stackdriver Exporter for metrics collection var exporter = new StackdriverExporter( projectId, exportComponent: null, viewManager: Stats.ViewManager); exporter.Start(); // 6. Define what will be exported (schema): a measure, how it's aggregated and how it will be tagged (metadata) var executionCountView = View.Create( ViewName.Create("sample_execution_count"), "Counts the number of method invocations over time", numberOfInvocations, Count.Create(), new List <ITagKey>() { tagEnv, tagMachine }); // 7. Register the view to export Stats.ViewManager.RegisterView(executionCountView); // Run instrumented fragment on a separate thread Task.Run((Action)InstrumentedFragment); }
/// <summary> /// Returns True if the table refers that view /// </summary> /// <param name="viewName"></param> /// <returns></returns> internal protected bool IsViewReferenced(string viewName) { if (string.IsNullOrEmpty(viewName)) { return(false); } if (!string.IsNullOrEmpty(ViewName) && ViewName.Equals(viewName, StringComparison.OrdinalIgnoreCase)) { return(true); } // Check partition map if (string.IsNullOrEmpty(PartitionOnProperty) || PartitionsToViewMap == null) { return(false); } KeyValuePair <string, string> entry = PartitionsToViewMap.FirstOrDefault(x => x.Value.Equals(viewName, StringComparison.OrdinalIgnoreCase)); if (entry.Equals(default(KeyValuePair <string, string>))) { return(false); } return(!string.IsNullOrEmpty(entry.Key)); }
public async Task NavigationWithoutBackButton(ViewName viewName, object o = null) { var page = _pageFactory.GetPage(viewName, o); await Application.Current.MainPage.Navigation.PushAsync(page); NavigationPage.SetHasBackButton(page, false); }
protected override string?PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(ViewNameProps)) { if (ViewNameProps.Count > 0 && !ViewName.HasText()) { return(ValidationMessage._0ShouldBeNull.NiceToString(pi.NiceName())); } if (ViewName.HasText() && Workflow != null) { var dv = DynamicViewEntity.TryGetDynamicView(Workflow.MainEntityType.ToType(), ViewName); if (dv != null) { return(ViewNamePropEmbedded.ValidateViewNameProps(dv, ViewNameProps)); } } } if (pi.Name == nameof(DecisionOptions)) { return((pi, DecisionOptions).IsSetOnlyWhen(Type == WorkflowActivityType.Decision)); } if (pi.Name == nameof(CustomNextButton) && CustomNextButton != null && Type != WorkflowActivityType.Task) { return(ValidationMessage._0IsSet.NiceToString(pi.NiceName())); } return(base.PropertyValidation(pi)); }
protected override string?PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(SubWorkflow)) { var requiresSubWorkflow = this.Type == WorkflowActivityType.CallWorkflow || this.Type == WorkflowActivityType.DecompositionWorkflow; if (SubWorkflow != null && !requiresSubWorkflow) { return(ValidationMessage._0ShouldBeNull.NiceToString(pi.NiceName())); } if (SubWorkflow == null && requiresSubWorkflow) { return(ValidationMessage._0IsNotSet.NiceToString(pi.NiceName())); } } if (pi.Name == nameof(Script)) { var requiresScript = this.Type == WorkflowActivityType.Script; if (Script != null && !requiresScript) { return(ValidationMessage._0ShouldBeNull.NiceToString(pi.NiceName())); } if (Script == null && requiresScript) { return(ValidationMessage._0IsNotSet.NiceToString(pi.NiceName())); } } if (pi.Name == nameof(ViewNameProps)) { if (ViewNameProps.Count > 0 && !ViewName.HasText()) { return(ValidationMessage._0ShouldBeNull.NiceToString(pi.NiceName())); } if (ViewName.HasText()) { var dv = DynamicViewEntity.TryGetDynamicView(Lane.Pool.Workflow.MainEntityType.ToType(), ViewName); if (dv != null) { return(ViewNamePropEmbedded.ValidateViewNameProps(dv, ViewNameProps)); } } } if (pi.Name == nameof(DecisionOptions)) { return((pi, DecisionOptions).IsSetOnlyWhen(Type == WorkflowActivityType.Decision)); } if (pi.Name == nameof(CustomNextButton) && CustomNextButton != null && Type != WorkflowActivityType.Task) { return(ValidationMessage._0IsSet.NiceToString(pi.NiceName())); } return(base.PropertyValidation(pi)); }
private void loadyttables(HttpContext context) { int ProjectID = WebUtil.GetIntValue(context, "ProjectID"); int PropertyID = WebUtil.GetIntValue(context, "PropertyID"); var project = Project.GetProject(ProjectID); string strjson = string.Empty; List <ViewYT> ytlist = new List <ViewYT>(); List <ProjectPropertyDetail> list = new List <ProjectPropertyDetail>(); if (project.ParentID > 1) { var property = ProjectPropertyDetail.GetProjectPropertyDetailByID(project.PropertyID); property.Title = project.Name; list.Add(property); } else { list = ProjectPropertyDetail.GetProjectPropertyDetailListByProjectID(project.ID, PropertyID).ToList(); } int startlevel = (project.IconID - 1) < 0 ? 0 : (project.IconID - 1); foreach (var item in list) { int SortOrder = 0; if (item.SortOrder > 0) { SortOrder = item.SortOrder; } else if (item.MainSortOrder > 0) { SortOrder = item.MainSortOrder; } ViewYT view = new ViewYT(); view.ID = item.ID; view.title = item.Title; view.order = SortOrder; var listView = new List <ViewName>(); PropertyInfo[] projectProperty = item.GetType().GetProperties(); for (int i = startlevel; i <= projectProperty.Length; i++) { PropertyInfo info = projectProperty.FirstOrDefault(p => p.Name.Equals("Level" + i)); if (info != null) { object value = info.GetValue(item, null); if (value != null && !string.IsNullOrEmpty(value.ToString())) { string name = info.Name; ViewName viewName = new ViewName(); viewName.Name = value.ToString(); listView.Add(viewName); } } } view.list = listView; ytlist.Add(view); } WebUtil.WriteJson(context, new { status = true, values = ytlist }); }
public void CreateMetrics_CountAgg_ReturnsExpected() { var opts = new CloudFoundryForwarderOptions(); var stats = new OpenCensusStats(); var tagsComponent = new TagsComponent(); var tagger = tagsComponent.Tagger; var ep = new MicrometerMetricWriter(opts, stats); IMeasureDouble testMeasure = MeasureDouble.Create("test.total", "test", MeasureUnit.Bytes); SetupTestView(stats, Count.Create(), testMeasure, "test.test1"); ITagContext context1 = tagger .EmptyBuilder .Put(TagKey.Create("a"), TagValue.Create("v1")) .Put(TagKey.Create("b"), TagValue.Create("v1")) .Put(TagKey.Create("c"), TagValue.Create("v1")) .Build(); long allKeyssum = 0; for (int i = 0; i < 10; i++) { allKeyssum = allKeyssum + i; stats.StatsRecorder.NewMeasureMap().Put(testMeasure, i).Record(context1); } var viewData = stats.ViewManager.GetView(ViewName.Create("test.test1")); Assert.NotNull(viewData); var aggMap = viewData.AggregationMap; Assert.Single(aggMap); var tagValues = aggMap.Keys.Single(); var data = aggMap.Values.Single(); Assert.NotNull(tagValues); Assert.NotNull(data); var result = ep.CreateMetrics(viewData, data, tagValues, 1L); Assert.NotNull(result); Assert.Single(result); var metric = result[0]; Assert.Equal("test.test1", metric.Name); Assert.Equal(1L, metric.Timestamp); Assert.Equal("gauge", metric.Type); Assert.Equal("bytes", metric.Unit); Assert.Equal(10, metric.Value); var tags = metric.Tags; Assert.Equal("count", tags["statistic"]); Assert.Equal("v1", tags["a"]); Assert.Equal("v1", tags["b"]); Assert.Equal("v1", tags["c"]); }
private void ChangeView(ViewName viewName) { RootNavigationView.SelectedIndex = (int)viewName; Analytics.TrackEvent("View Changed", new Dictionary <string, string> { { "ViewName", $"{viewName}" } }); }
public void Constructor_RegistersExpectedViews() { var options = new MetricsOptions(); var stats = new OpenCensusStats(); var tags = new OpenCensusTags(); var observer = new AspNetCoreHostingObserver(options, stats, tags, null); Assert.NotNull(stats.ViewManager.GetView(ViewName.Create("http.server.requests"))); }
public void HandleThreadsEvent_RecordsValues() { var options = new MetricsEndpointOptions(); var stats = new OpenCensusStats(); var tags = new OpenCensusTags(); var observer = new CLRRuntimeObserver(options, stats, tags, null); CLRRuntimeSource.ThreadMetrics metrics = new CLRRuntimeSource.ThreadMetrics(100, 100, 200, 200); observer.HandleThreadsEvent(metrics); var live = stats.ViewManager.GetView(ViewName.Create("clr.threadpool.active")); var aggData = MetricsHelpers.SumWithTags(live) as IMeanData; Assert.Equal(100, aggData.Mean); Assert.Equal(100, aggData.Min); Assert.Equal(100, aggData.Max); aggData = MetricsHelpers.SumWithTags(live, new List <ITagValue>() { TagValue.Create("worker") }) as IMeanData; Assert.Equal(100, aggData.Mean); Assert.Equal(100, aggData.Min); Assert.Equal(100, aggData.Max); aggData = MetricsHelpers.SumWithTags(live, new List <ITagValue>() { TagValue.Create("completionPort") }) as IMeanData; Assert.Equal(100, aggData.Mean); Assert.Equal(100, aggData.Min); Assert.Equal(100, aggData.Max); var avail = stats.ViewManager.GetView(ViewName.Create("clr.threadpool.avail")); aggData = MetricsHelpers.SumWithTags(avail) as IMeanData; Assert.Equal(100, aggData.Mean); Assert.Equal(100, aggData.Min); Assert.Equal(100, aggData.Max); aggData = MetricsHelpers.SumWithTags(avail, new List <ITagValue>() { TagValue.Create("worker") }) as IMeanData; Assert.Equal(100, aggData.Mean); Assert.Equal(100, aggData.Min); Assert.Equal(100, aggData.Max); aggData = MetricsHelpers.SumWithTags(avail, new List <ITagValue>() { TagValue.Create("completionPort") }) as IMeanData; Assert.Equal(100, aggData.Mean); Assert.Equal(100, aggData.Min); Assert.Equal(100, aggData.Max); }
public override int GetHashCode() { unchecked { var hashCode = (ViewName != null ? ViewName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DefaultLayoutName != null ? DefaultLayoutName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Layouts != null ? Layouts.GetHashCode() : 0); return(hashCode); } }
private static void RegisterViewName() { string[] names = Enum.GetNames(typeof(ViewName)); foreach (var name in names) { ViewName temp = (ViewName)Enum.Parse(typeof(ViewName), name); _viewNameDic.Add(temp, name); } Debug.Log("Name dic have count:" + _viewNameDic.Count); }
public void Constructor_RegistersExpectedViews() { var options = new MetricsEndpointOptions(); var stats = new OpenCensusStats(); var tags = new OpenCensusTags(); var observer = new HttpClientDesktopObserver(options, stats, tags, null); Assert.NotNull(stats.ViewManager.GetView(ViewName.Create("http.desktop.client.request.time"))); Assert.NotNull(stats.ViewManager.GetView(ViewName.Create("http.desktop.client.request.count"))); }
public void PreventTooLongViewName() { char[] chars = new char[ViewName.NAME_MAX_LENGTH + 1]; for (int i = 0; i < chars.Length; i++) { chars[i] = 'a'; } String longName = new String(chars); Assert.Throws <ArgumentOutOfRangeException>(() => ViewName.Create(longName)); }
// Because of how jqxDataTable works: // In a data table with a DropDownList, the selected *display name* associated with the *lookup field name* is returned. // We need to convert this to the non-aliased master table FK ID and lookup the value from the FK table given the name. // ANNOYINGLY, THIS MEANS THAT THE NAME MUST ALSO BE UNIQUE! This should be acceptable, if not even good practice, but it's still an annoying constraint. public void FixupLookups(ViewName viewName, Dictionary <string, object> kvParams) { ViewInfo view = (ViewInfo)db.GetView(viewName.Value); // Find all lookup fields: view.AllFields.Where(f => f.IsFK).ForEach(f => { object val; TableForeignKey tfk = f.References[0]; // assume only one FK involvement for this field. // assume a non-clustered fk. string fkFieldName = tfk.FkPkMap.First().Key; // fk field name string pkFieldName = tfk.FkPkMap.First().Value; // pk field name of referenced table. Assert.That(tfk.ValueFields.Count > 0, "View: " + view.Name + " -> To resolve foreign keys, at least one display field must be defined in the foreign key relationship for " + f.TableFieldInfo.TableInfo.Name + "." + fkFieldName + " -> " + tfk.PkTable + "." + pkFieldName); string aliasedPkValueFieldName = tfk.ValueFields[0]; // Not all FK's in the view may be defined, especially when there are sub-classes of the GenericTableController that // populate the FK values based on session parameters, for example. if (view.Exists(aliasedPkValueFieldName)) { string dealiasedPkValueFieldName = view.GetField(aliasedPkValueFieldName).TableFieldInfo.FieldName; // Aliases can be null for table joins where we're just getting an ID or other fields that don't map to a lookup that needs to be resolved. // TODO: What was this issue really? if (kvParams.TryGetValue(aliasedPkValueFieldName, out val)) { // Remove the *value field* name kvParams.Remove(aliasedPkValueFieldName); // "Please Choose" is text that the jqx dropdown might return, but it seems to return an empty field. if ((val != null) && (!String.IsNullOrEmpty(val.ToString())) && (!val.ToString().ToLower().BeginsWith("please choose"))) { // Replace with the non-aliased *FK field* name. // TODO: This doesn't handle multiple columns referencing the same FK table. // Now, lookup the value in the FK table. Sigh, this requires a database query. If the jqxDataTable / jqxDropDownList worked correctly with ID's, this wouldn't be necessary! // Assume one value field. object id = db.QueryScalar("select ID from " + tfk.PkTable + " where " + dealiasedPkValueFieldName + " = @val", new Dictionary <string, object>() { { "val", val } }); Assert.That(id != null, "Expected to resolve the foreign key ID for primary key table " + tfk.PkTable + " with display value of " + val.ToString().SingleQuote()); // The update will throw an exception if a null FK is not permitted but the lookup returned a null for id. kvParams[fkFieldName] = id; } else { Assert.That(f.TableFieldInfo.IsNullable, "The FK " + fkFieldName + " in the view " + view.Name + " is not marked as nullable. A value is required."); kvParams[fkFieldName] = null; } } } }); }
private void RegisterView(ViewName name, IView view) { if (_viewObjDic.ContainsKey(name)) { Debug.LogError(name + " already exist in dic."); } else { _viewObjDic.Add(name, view); } }
private void Repopulate() { if (_inRepopulate) { return; } try { _inRepopulate = true; if (!Equals(SelectedGroup, toolStripComboGroup.SelectedItem)) { listView1.Items.Clear(); } toolStripComboGroup.Items.Clear(); imageList1.Images.Clear(); var newItems = new List<ListViewItem>(); var newGroups = new List<ListViewGroup>(); if (null != ViewContext) { imageList1.Images.AddRange(ViewContext.GetImageList()); toolStripComboGroup.Items.AddRange(ViewContext.ViewGroups.ToArray()); IEnumerable<ViewGroup> groups; if (null != SelectedGroup) { groups = new[] {SelectedGroup}; listView1.View = View.List; } else { groups = ViewContext.ViewGroups; listView1.View = View.SmallIcon; } foreach (var group in groups) { var listViewGroup = new ListViewGroup(group.Id.Name, group.Label) {Tag = group}; newGroups.Add(listViewGroup); foreach (var viewSpec in ViewContext.GetViewSpecList(group.Id).ViewSpecs) { bool validRowSource = null != ViewContext.GetViewInfo(new ViewName(group.Id, viewSpec.Name)); if (FilterRowSources && !validRowSource) { continue; } var viewName = new ViewName(group.Id, viewSpec.Name); var item = new ListViewItem(viewSpec.Name, ViewContext.GetImageIndex(viewSpec)) { Name = viewName.ToString(), Group= listViewGroup, Tag = viewName, Checked = _checkedItems.Contains(viewName), }; if (!validRowSource && GrayDisabledRowSources) { item.ForeColor = SystemColors.GrayText; } newItems.Add(item); } } toolStripComboGroup.SelectedItem = SelectedGroup; } ReplaceItems(listView1, newGroups, newItems); } finally { _inRepopulate = false; } }
public ViewInfo(ViewName viewName = ViewName.Unknown, ViewType viewType = ViewType.View, object parameter = null) { ViewName = viewName; ViewType = viewType; Parameter = parameter; }