protected override bool OnAttach(IRenderHost host) { if (!base.OnAttach(host)) { return(false); } AttachMaterial(); var geometry = Geometry as MeshGeometry3D; if (geometry == null) { throw new Exception("Geometry must not be null"); } OnCreateGeometryBuffers(); hasInstances = (Instances != null) && (Instances.Any()); bHasInstances = effect.GetVariableByName("bHasInstances").AsScalar(); OnRasterStateChanged(); if (hasInstances) { isInstanceChanged = true; } // Device.ImmediateContext.Flush(); return(true); }
public IEnumerable <Issue> GetIssues() { if (MonitorStatus != MonitorStatus.Good && Instances.Any(i => i.LastPoll.HasValue)) { yield return(new Issue <HAProxyGroup>(this, "HAProxy", Name)); } }
public void SaveGesture() { if (_newGesture) { Id = _provider.SaveNewDynamicGestureClass(Name, null); // Need to get id } var editedGesture = new DGClass(Instances); var sampleInstance = (Instances.Any()) ? Instances.FirstOrDefault().Instance : null; var gestureWrapper = new DGClassWrapper() { Id = this.Id, Name = this.Name, Gesture = editedGesture, SampleInstance = sampleInstance }; _provider.SaveDynamicGestureClass(gestureWrapper); if (Changeset.ChangesExist()) { // Update the StaticGestureInstances table foreach (int instanceId in Changeset.DeletedGestureInstances) { _provider.DeleteDynamicGestureInstance(instanceId); } foreach (var instance in Changeset.NewGestureInstances) { _provider.SaveNewDynamicGestureInstance(Id, instance.Instance); } } _mvm.UpdateDynamicGestureLibrary(); }
private static async void FinishCreatingAsync(BackButton backButton, Frame frame, NavigationService service) { await Task.CompletedTask; // TODO: add this feature back in if you can figure out the reason for an err // await ClearExpiredCacheAsync(service); service.BackButtonHandling = backButton; frame.RequestedTheme = Settings.DefaultTheme; if (backButton == BackButton.Attach) { // frame.RegisterPropertyChangedCallback(Frame.BackStackDepthProperty, (s, args) => BackButtonService.GetInstance().UpdateBackButton(service.CanGoBack)); frame.Navigated += (s, args) => BackButtonService.UpdateBackButton(service.CanGoBack); BackButtonService.BackRequested += async(s, e) => e.Handled = await service.GoBackAsync(); } if (!Instances.Any()) { Default = service; } Instances.Add(service); Central.MessengerService.Send(new Messages.NavigationServiceCreatedMessage { NavigationService = service, BackButtonHandling = backButton, IsDefault = Default == service, Dispatcher = service.GetDispatcher() }); }
private static async void FinishCreatingAsyncVoid(BackButton backButton, Frame frame, NavigationService service) { await Task.CompletedTask; // TODO: add this feature back in if you can figure out the reason for an err // await ClearExpiredCacheAsync(service); service.BackButtonHandling = backButton; if (backButton == BackButton.Attach) { frame.RegisterPropertyChangedCallback(Frame.CanGoBackProperty, (s, args) => GestureService.UpdateBackButton(service.CanGoBack)); Central.Messenger.Subscribe <Messages.BackRequestedMessage>(frame, async m => { await service.GoBackAsync(); }); } if (!Instances.Any()) { Default = service; } Instances.Register(service); Central.Messenger.Send(new Messages.NavigationServiceCreatedMessage { NavigationService = service, BackButtonHandling = backButton, IsDefault = Default == service, Dispatcher = service.GetDispatcher() }); }
public static void Initialize(string language) { Logger.Debug("Initializing Data..."); var json = WebInteractions.DownloadString($"https://raw.githubusercontent.com/easly1989/ffxiv_act_dfassist/master/data/{language}.json"); Fill(json, language); Logger.Debug(Initialized && Instances.Any() && Roulettes.Any() ? $"Data {Version} Initialized!" : "Unable to initialize Data!"); }
protected override void OnRender(RenderContext renderContext) { /// --- set constant paramerers var worldMatrix = modelMatrix * renderContext.WorldMatrix; effectTransforms.mWorld.SetMatrix(ref worldMatrix); /// --- check shadowmaps hasShadowMap = renderHost.IsShadowMapEnabled; effectMaterial.bHasShadowMapVariable.Set(hasShadowMap); effectMaterial.AttachMaterial(); /// --- check instancing hasInstances = (Instances != null) && (Instances.Any()); if (bHasInstances != null) { bHasInstances.Set(hasInstances); } /// --- set context Device.ImmediateContext.InputAssembler.InputLayout = vertexLayout; Device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; Device.ImmediateContext.InputAssembler.SetIndexBuffer(indexBuffer, Format.R32_UInt, 0); /// --- set rasterstate Device.ImmediateContext.Rasterizer.State = rasterState; if (hasInstances) { /// --- update instance buffer if (isInstanceChanged) { instanceBuffer = Buffer.Create(Device, Instances.ToArray(), new BufferDescription(Matrix.SizeInBytes * Instances.Count, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)); isInstanceChanged = false; } /// --- INSTANCING: need to set 2 buffers Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new[] { new VertexBufferBinding(vertexBuffer, VertexSizeInBytes, 0), new VertexBufferBinding(instanceBuffer, Matrix.SizeInBytes, 0), }); /// --- render the geometry effectTechnique.GetPassByIndex(0).Apply(Device.ImmediateContext); /// --- draw Device.ImmediateContext.DrawIndexedInstanced(Geometry.Indices.Count, Instances.Count, 0, 0, 0); } else { /// --- bind buffer Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, VertexSizeInBytes, 0)); /// --- render the geometry effectTechnique.GetPassByIndex(0).Apply(Device.ImmediateContext); /// --- draw Device.ImmediateContext.DrawIndexed(Geometry.Indices.Count, 0, 0); } }
protected override void OnRender(RenderContext renderContext) { /// --- set constant paramerers var worldMatrix = modelMatrix * renderContext.WorldMatrix; EffectTransforms.mWorld.SetMatrix(ref worldMatrix); /// --- check shadowmaps hasShadowMap = renderHost.IsShadowMapEnabled; effectMaterial.bHasShadowMapVariable.Set(hasShadowMap); effectMaterial.AttachMaterial(geometryInternal as MeshGeometry3D); /// --- check instancing hasInstances = (Instances != null) && (Instances.Any()); if (bHasInstances != null) { bHasInstances.Set(hasInstances); } /// --- set context Device.ImmediateContext.InputAssembler.InputLayout = vertexLayout; Device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; Device.ImmediateContext.InputAssembler.SetIndexBuffer(IndexBuffer.Buffer, Format.R32_UInt, 0); /// --- set rasterstate Device.ImmediateContext.Rasterizer.State = RasterState; if (hasInstances) { /// --- update instance buffer if (isInstanceChanged) { InstanceBuffer.UploadDataToBuffer(renderContext.DeviceContext, Instances.ToArray()); isInstanceChanged = false; } /// --- INSTANCING: need to set 2 buffers Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new[] { new VertexBufferBinding(VertexBuffer.Buffer, VertexBuffer.StructureSize, 0), new VertexBufferBinding(InstanceBuffer.Buffer, InstanceBuffer.StructureSize, 0), }); /// --- render the geometry effectTechnique.GetPassByIndex(0).Apply(Device.ImmediateContext); /// --- draw Device.ImmediateContext.DrawIndexedInstanced(Geometry.Indices.Count, Instances.Count, 0, 0, 0); } else { /// --- bind buffer Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(VertexBuffer.Buffer, VertexBuffer.StructureSize, 0)); /// --- render the geometry effectTechnique.GetPassByIndex(0).Apply(Device.ImmediateContext); /// --- draw Device.ImmediateContext.DrawIndexed(Geometry.Indices.Count, 0, 0); } }
/// <summary> /// See <see cref="object.ToString"/>. /// </summary> /// <returns></returns> public override string ToString() { const string NAME_PART = " - {0}: {1}"; return(new StringBuilder(this.FriendlyName()) .AppendFormat(Resources.Culture, NAME_PART, nameof(Lifetime), Lifetime?.ToString() ?? "NULL") .AppendFormat(Resources.Culture, NAME_PART, nameof(Implementation), Implementation?.GetFriendlyName() ?? "NULL") .AppendFormat(Resources.Culture, NAME_PART, nameof(Instances), Instances.Any() ? string.Join(", ", Instances.Select(GetInstance)) : "EMPTY") .ToString()); }
public List <string> CheckForErrorsOnName(T InstanceInfo) { var errorList = new List <string>(); if (Instances.Any(x => x.Name.ToUpper() == InstanceInfo.Name.ToUpper())) { errorList.Add("Instance name is already in use. Please use a different name"); } return(errorList); }
/// <summary> /// Adds the instance from the strongly typed class interface. /// </summary> /// <param name="instanceToAdd">The item.</param> public void AddInstance(INSTANCETYPE instanceToAdd) { // If instanceToAdd already exists, or is null, don't try to add it. if (instanceToAdd == null || Instances.Any(x => PersistableTypeInfo.IdentityComparator.Invoke(x, instanceToAdd))) { return; } // Add this instance to the queue. Instances.Add(instanceToAdd); // Add all this instance's associated objects. AddAssociatedInstances(instanceToAdd); }
private bool ValidateForm() { if (string.IsNullOrEmpty(AlgoName)) { MessageBox.Show("Необходимо указать название алгоритма"); return(false); } if (Instances.Any(p => p.MaxAmount == 0)) { MessageBox.Show("Максимальная сумма должна быть больше 0"); return(false); } return(true); }
/// <summary> /// Override LineGeometryModel3D's Attach method to /// provide a buffer of DynamoLineVertices /// </summary> /// <param name="host"></param> public override void Attach(IRenderHost host) { renderTechnique = host.RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Lines]; base.Attach(host); if (Geometry == null) { return; } if (renderHost.RenderTechnique == host.RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.Deferred) || renderHost.RenderTechnique == host.RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.Deferred)) { return; } vertexLayout = renderHost.EffectsManager.GetLayout(renderTechnique); effectTechnique = effect.GetTechniqueByName(renderTechnique.Name); effectTransforms = new EffectTransformVariables(effect); var geometry = Geometry as LineGeometry3D; if (geometry != null) { vertexBuffer = Device.CreateBuffer(BindFlags.VertexBuffer, VertexSizeInBytes, CreateVertexArray()); indexBuffer = Device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), geometry.Indices.ToArray()); } hasInstances = (Instances != null) && (Instances.Any()); bHasInstances = effect.GetVariableByName("bHasInstances").AsScalar(); if (hasInstances) { instanceBuffer = Buffer.Create(Device, instanceArray, new BufferDescription(Matrix.SizeInBytes * instanceArray.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)); } vViewport = effect.GetVariableByName("vViewport").AsVector(); vLineParams = effect.GetVariableByName("vLineParams").AsVector(); var lineParams = new Vector4((float)Thickness, (float)Smoothness, 0, 0); vLineParams.Set(lineParams); OnRasterStateChanged(DepthBias); Device.ImmediateContext.Flush(); }
public void SaveGesture() { Dictionary <string, int> featureWeightsDict = null; if (_newGesture) { Id = _provider.SaveNewStaticGestureClass(Name, null); // Need to get id } else { // Fill featureWeightsDict featureWeightsDict = new Dictionary <string, int>(); foreach (var fw in FeatureWeights) { featureWeightsDict.Add(fw.Name, fw.Weight); } } var editedGesture = new SGClass(Instances, featureWeightsDict); var sampleInstance = (Instances.Any()) ? Instances.FirstOrDefault().Gesture : null; var gestureWrapper = new SGClassWrapper() { Id = this.Id, Name = this.Name, Gesture = editedGesture, SampleInstance = sampleInstance }; _provider.SaveStaticGestureClass(gestureWrapper); if (Changeset.ChangesExist()) { // Update the StaticGestureInstances table foreach (int instanceId in Changeset.DeletedGestureInstances) { _provider.DeleteStaticGestureInstance(instanceId); } foreach (var instance in Changeset.NewGestureInstances) { _provider.SaveNewStaticGestureInstance(Id, instance.Gesture); } } _mvm.UpdateStaticGestureLibrary(); }
public override void Attach(IRenderHost host) { base.Attach(host); renderTechnique = host.RenderTechniquesManager.RenderTechniques["RenderCustom"]; if (Geometry == null) { return; } vertexLayout = renderHost.EffectsManager.GetLayout(renderTechnique); effectTechnique = effect.GetTechniqueByName(renderTechnique.Name); effectTransforms = new EffectTransformVariables(effect); AttachMaterial(); var geometry = Geometry as MeshGeometry3D; if (geometry == null) { throw new Exception("Geometry must not be null"); } vertexBuffer = Device.CreateBuffer(BindFlags.VertexBuffer, VertexSizeInBytes, CreateCustomVertexArray()); indexBuffer = Device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), Geometry.Indices.ToArray()); hasInstances = (Instances != null) && (Instances.Any()); bHasInstances = effect.GetVariableByName("bHasInstances").AsScalar(); if (hasInstances) { instanceBuffer = Buffer.Create(Device, instanceArray, new BufferDescription(Matrix.SizeInBytes * instanceArray.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)); } OnRasterStateChanged(DepthBias); Device.ImmediateContext.Flush(); }
public override void Render(RenderContext renderContext) { if (!IsRendering) { return; } if (Geometry == null) { return; } if (Visibility != Visibility.Visible) { return; } if (renderContext.IsShadowPass) { if (!IsThrowingShadow) { return; } } /// --- set constant paramerers var worldMatrix = modelMatrix * renderContext.WorldMatrix; effectTransforms.mWorld.SetMatrix(ref worldMatrix); /// --- check shadowmaps hasShadowMap = renderHost.IsShadowMapEnabled; effectMaterial.bHasShadowMapVariable.Set(hasShadowMap); /// --- set material params if (phongMaterial != null) { effectMaterial.vMaterialDiffuseVariable.Set(phongMaterial.DiffuseColor); effectMaterial.vMaterialAmbientVariable.Set(phongMaterial.AmbientColor); effectMaterial.vMaterialEmissiveVariable.Set(phongMaterial.EmissiveColor); effectMaterial.vMaterialSpecularVariable.Set(phongMaterial.SpecularColor); effectMaterial.vMaterialReflectVariable.Set(phongMaterial.ReflectiveColor); effectMaterial.sMaterialShininessVariable.Set(phongMaterial.SpecularShininess); /// --- has samples effectMaterial.bHasDiffuseMapVariable.Set(phongMaterial.DiffuseMap != null); effectMaterial.bHasNormalMapVariable.Set(phongMaterial.NormalMap != null); /// --- set samplers if (phongMaterial.DiffuseMap != null) { effectMaterial.texDiffuseMapVariable.SetResource(texDiffuseMapView); } if (phongMaterial.NormalMap != null) { effectMaterial.texNormalMapVariable.SetResource(texNormalMapView); } } /// --- check instancing hasInstances = (Instances != null) && (Instances.Any()); if (bHasInstances != null) { bHasInstances.Set(hasInstances); } /// --- set context Device.ImmediateContext.InputAssembler.InputLayout = vertexLayout; Device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; Device.ImmediateContext.InputAssembler.SetIndexBuffer(indexBuffer, Format.R32_UInt, 0); /// --- set rasterstate Device.ImmediateContext.Rasterizer.State = rasterState; if (hasInstances) { /// --- update instance buffer if (isChanged) { instanceBuffer = Buffer.Create(Device, instanceArray, new BufferDescription(Matrix.SizeInBytes * instanceArray.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)); DataStream stream; Device.ImmediateContext.MapSubresource(instanceBuffer, MapMode.WriteDiscard, MapFlags.None, out stream); stream.Position = 0; stream.WriteRange(instanceArray, 0, instanceArray.Length); Device.ImmediateContext.UnmapSubresource(instanceBuffer, 0); stream.Dispose(); isChanged = false; } /// --- INSTANCING: need to set 2 buffers Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new[] { new VertexBufferBinding(vertexBuffer, DynamoMeshVertex.SizeInBytes, 0), new VertexBufferBinding(instanceBuffer, Matrix.SizeInBytes, 0), }); /// --- render the geometry effectTechnique.GetPassByIndex(0).Apply(Device.ImmediateContext); /// --- draw Device.ImmediateContext.DrawIndexedInstanced(Geometry.Indices.Count, instanceArray.Length, 0, 0, 0); } else { /// --- bind buffer Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, DynamoMeshVertex.SizeInBytes, 0)); /// --- render the geometry effectTechnique.GetPassByIndex(0).Apply(Device.ImmediateContext); /// --- draw Device.ImmediateContext.DrawIndexed(Geometry.Indices.Count, 0, 0); } }
/// <summary> /// Determines whether an instance is in the project. /// </summary> public bool ContainsInstance(string name) { return(Instances.Any(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase))); }
/// <summary> /// /// </summary> /// <param name="host"></param> public override void Attach(IRenderHost host) { /// --- attach renderTechnique = host.RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Lines]; base.Attach(host); if (Geometry == null) { return; } if (renderHost.RenderTechnique == renderHost.RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.Deferred) || renderHost.RenderTechnique == renderHost.RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.GBuffer)) { return; } // --- get device vertexLayout = renderHost.EffectsManager.GetLayout(renderTechnique); effectTechnique = effect.GetTechniqueByName(renderTechnique.Name); effectTransforms = new EffectTransformVariables(effect); // --- get geometry var geometry = Geometry as LineGeometry3D; // -- set geometry if given if (geometry != null) { /// --- set up buffers vertexBuffer = Device.CreateBuffer(BindFlags.VertexBuffer, VertexSizeInBytes, CreateLinesVertexArray()); /// --- set up indexbuffer indexBuffer = Device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), geometry.Indices.Array); } /// --- init instances buffer hasInstances = (Instances != null) && (Instances.Any()); bHasInstances = effect.GetVariableByName("bHasInstances").AsScalar(); if (hasInstances) { instanceBuffer = Buffer.Create(Device, instanceArray, new BufferDescription(Matrix.SizeInBytes * instanceArray.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)); } /// --- set up const variables vViewport = effect.GetVariableByName("vViewport").AsVector(); //this.vFrustum = effect.GetVariableByName("vFrustum").AsVector(); vLineParams = effect.GetVariableByName("vLineParams").AsVector(); /// --- set effect per object const vars var lineParams = new Vector4((float)Thickness, (float)Smoothness, 0, 0); vLineParams.Set(lineParams); /// === debug hack //{ // var texDiffuseMapView = ShaderResourceView.FromFile(device, @"G:\Projects\Deformation Project\FrameworkWPF2012\Externals\HelixToolkit-SharpDX\Source\Examples\SharpDX.Wpf\LightingDemo\TextureCheckerboard2.jpg"); // var texDiffuseMap = effect.GetVariableByName("texDiffuseMap").AsShaderResource(); // texDiffuseMap.SetResource(texDiffuseMapView); //} /// --- create raster state OnRasterStateChanged(DepthBias); //this.rasterState = new RasterizerState(this.device, rasterStateDesc); /// --- set up depth stencil state //var depthStencilDesc = new DepthStencilStateDescription() //{ // DepthComparison = Comparison.Less, // DepthWriteMask = global::SharpDX.Direct3D11.DepthWriteMask.All, // IsDepthEnabled = true, //}; //this.depthStencilState = new DepthStencilState(this.device, depthStencilDesc); /// --- flush Device.ImmediateContext.Flush(); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private async void Execute(object sender, EventArgs e) { await package.JoinableTaskFactory.SwitchToMainThreadAsync(); var dte2 = await package.GetDTE2Async(); var projects = Utilities.GetCodeProjectsInSolution(dte2); var outputPane = Utilities.GetDebugOutputPane(dte2); outputPane.Clear(); outputPane.OutputString("Checking projects in solution for dapr configuration.\n"); foreach (var project in projects) { outputPane.OutputString($"Checking for dapr in project {project.Name}\n"); var properties = project.Properties.Cast <Property>() .ToList(); var projectOutputFileName = properties .FirstOrDefault(item => item.Name == "OutputFileName") ?.Value ?.ToString() .Replace(".dll", ".exe"); var projectFileName = properties .FirstOrDefault(item => item.Name == "FullProjectFileName") ?.Value ?.ToString(); var projectFullPath = properties .FirstOrDefault(item => item.Name == "FullPath") ?.Value ?.ToString(); if (string.IsNullOrEmpty(projectFileName) || string.IsNullOrEmpty(projectOutputFileName) || string.IsNullOrEmpty(projectFullPath)) { outputPane.OutputString($"Project not compatible: {project.Name}\n"); continue; } var projectFile = new XmlDocument(); projectFile.Load(projectFileName); var appId = projectFile.SelectSingleNode("//Project/PropertyGroup/DaprAppId")?.InnerText; var appPort = projectFile.SelectSingleNode("//Project/PropertyGroup/DaprAppPort")?.InnerText; if (string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appPort)) { continue; } outputPane.OutputString($"Registering dapr instance for project {project.Name}\n"); var arguments = new List <string> { $"--app-id {appId}", $"--app-port {appPort}" }; AddOptionalArgument(projectFile, arguments, "--app-ssl", "DaprAppSSL"); AddOptionalArgument(projectFile, arguments, "--app-protocol", "DaprAppProtocol"); AddOptionalArgument(projectFile, arguments, "--app-max-concurrency", "DaprAppMaxConcurrency"); AddOptionalArgument(projectFile, arguments, "--dapr-grpc-port", "DaprGrpcPort"); AddOptionalArgument(projectFile, arguments, "--dapr-http-port", "DaprHttpPort"); AddOptionalArgument(projectFile, arguments, "--image", "DaprImage"); AddOptionalArgument(projectFile, arguments, "--config", "DaprConfig"); AddOptionalArgument(projectFile, arguments, "--log-level", "DaprLogLevel"); AddOptionalArgument(projectFile, arguments, "--profile-port", "DaprProfilePort"); AddOptionalArgument(projectFile, arguments, "--components-path", "DaprComponentsPath"); AddOptionalArgument(projectFile, arguments, "--enable-profiling", "DaprEnableProfiling"); AddOptionalArgument(projectFile, arguments, "--placement-host-address", "DaprPlacementHostAddress"); var process = new Process { EnableRaisingEvents = true, StartInfo = new ProcessStartInfo { FileName = "dapr", ErrorDialog = false, CreateNoWindow = false, UseShellExecute = true, WorkingDirectory = projectFullPath, Arguments = $"run {string.Join(" ", arguments)} -- dotnet run" } }; process.Exited += (_, _2) => { outputPane.OutputString($"Dapr process ({project.Name}) exited with code {process.ExitCode}\n"); KillProcesses(); }; process.Start(); Instances.Add(new DebuggableInstance { AppId = appId, IsAttached = false, DotNetProcessId = -1, ProjectName = project.Name, DaprProcessId = process.Id, IsRunning = !process.HasExited, OutputFileName = projectOutputFileName }); } outputPane.OutputString("Project scan completed.\n"); if (Instances.Any(item => !item.IsRunning)) { outputPane.OutputString("Not all processes could be started, stopping debugging session.\n"); KillProcesses(); // TODO: Alert? return; } var notAttached = Instances.Where(item => !item.IsAttached) .ToList(); outputPane.OutputString($"Waiting for {notAttached.Count} dotnet processes start.\n"); while (notAttached.Any()) { foreach (var instance in notAttached) { var process = dte2.Debugger.LocalProcesses.Cast <EnvDTE.Process>() .FirstOrDefault(item => item.Name.Contains(instance.OutputFileName)); outputPane.OutputString($"Searching for {instance.AppId} dotnet process.\n"); if (process != null) { process.Attach(); instance.IsAttached = true; instance.DotNetProcessId = process.ProcessID; outputPane.OutputString($"Attached to dotnet process for {instance.AppId}.\n"); } else { outputPane.OutputString($"No dotnet process found for {instance.AppId}.\n"); } } notAttached = Instances.Where(item => !item.IsAttached) .ToList(); if (notAttached.Any()) { await Task.Delay(250); } } outputPane.OutputString("Debugging started.\n"); }
public Dataset(Header header, Instance[] instances) : this() { Header = header ?? throw new ArgumentNullException(nameof(header)); Instances = instances ?? throw new ArgumentNullException(nameof(instances)); Name = (Header != null) ? Header.RelationName : "Unknown"; var iterableFeatures = Header.Features.Yaap(settings: new YaapSettings() { Description = $"Processing features of {Name}", ColorScheme = YaapColorScheme.Bright, UnitName = "feature" }); foreach (var feature in iterableFeatures) { if (feature.Type is IntegerFeature) { var nonMissingValues = Instances.Where(x => !feature.Type.IsMissing(x[feature])).Select(x => (int)x[feature]).ToArray(); var valuesmissing = Instances.Length - nonMissingValues.Length; int max, min; if (nonMissingValues.Length > 0) { max = nonMissingValues.Max(); min = nonMissingValues.Min(); } else { max = 0; min = 0; } feature.FeatureInformation = new IntegerFeatureInformation() { MissingValueCount = valuesmissing, MaxValue = max, MinValue = min, Feature = feature, }; } else if (feature.Type is NumericFeature) { var nonMissingValues = Instances.Where(x => !feature.Type.IsMissing(x[feature])).Select(x => (double)x[feature]).ToArray(); var valuesmissing = Instances.Length - nonMissingValues.Length; double max, min; if (nonMissingValues.Length > 0) { max = nonMissingValues.Max(); min = nonMissingValues.Min(); } else { max = 0; min = 0; } feature.FeatureInformation = new NumericFeatureInformation() { MissingValueCount = valuesmissing, MaxValue = max, MinValue = min, Feature = feature, }; } else if (feature.Type is NominalFeature) { var len = ((NominalFeature)feature.Type).Values.Count; double[] valuesCount = new double[len]; bool missingFeatures = Instances.Any(x => !feature.Type.IsMissing(x[feature])); var iterableValues = Range(0, len).Yaap(settings: new YaapSettings() { Description = $"Counting each value of {feature.Name}'s appearances", ColorScheme = YaapColorScheme.NoColor }); foreach (var i in iterableValues) { valuesCount[i] = Instances.Where(x => !feature.Type.IsMissing(x[feature])).Count(x => (int)x[feature] == i); } //for (int i = 0; i < len; i++) // valuesCount[i] = Instances.Where(x => !feature.Type.IsMissing(x[feature])).Count(x => (int)x[feature] == i); var valuesmissing = Instances.Select(x => x[feature]).Count(feature.Type.IsMissing); var valueProbability = valuesCount.Select(x => x / (valuesCount.Sum() * 1.0)).ToArray(); var ratio = valuesCount.Select(x => x / (valuesCount.Min() * 1F)).ToArray(); feature.FeatureInformation = new NominalFeatureInformation() { Distribution = valuesCount, MissingValueCount = valuesmissing, ValueProbability = valueProbability, Ratio = ratio, Feature = feature, }; } } int objWithIncompleteData = 0; var iterableInstances = Instances.Yaap(settings: new YaapSettings() { Description = "Processing instances...", ColorScheme = YaapColorScheme.Bright, UnitName = "feature" }); foreach (var instance in iterableInstances) { if (Header.Features.Any(feature => feature.Type.IsMissing(instance[feature]))) { objWithIncompleteData++; } } DatasetInformation = new DatasetInformation() { ObjectsWithIncompleteData = objWithIncompleteData, GlobalAbscenseInformation = Header.Features.Sum(feature => feature.FeatureInformation.MissingValueCount) }; }
/// <summary> /// Verifica se possui resposta disponível. /// </summary> public bool HasRead() { return(Instances.Any(a => a.HasRead())); }
void IJsonSerializable.Serialize(JsonWriter writer) { // Types if (Types != null && Types.Any()) { writer.WritePropertyName("types"); writer.WriteStartObject(); foreach (var type in Types) { writer.WritePropertyName(type); writer.WriteRawValue(GetTypeJson(type)); } writer.WriteEndObject(); } if (Instances != null && Instances.Any()) { writer.WritePropertyName("instances"); writer.WriteStartObject(); foreach (var typeItem in Instances) { writer.WritePropertyName(typeItem.Key); writer.WriteStartObject(); // Serialize static property values if (typeItem.Value.StaticProperties.Count > 0) { writer.WritePropertyName("static"); writer.Serialize( typeItem.Value.StaticProperties.ToDictionary( property => property.Name, property => JsonConverter.GetPropertyValue(property, property.DeclaringType))); } // Serialize instances foreach (var instanceItem in typeItem.Value.Instances) { writer.WritePropertyName(instanceItem.Key); writer.Serialize(instanceItem.Value); } writer.WriteEndObject(); } writer.WriteEndObject(); } if (Conditions != null && Conditions.Any()) { writer.WritePropertyName("conditions"); writer.Serialize(Conditions); } if (Events != null && Events.Any()) { writer.WritePropertyName("events"); writer.Serialize(Events); } if (Model != null && Model.Any()) { writer.WritePropertyName("model"); writer.Serialize(Model); } if (ServerInfo != null) { writer.WritePropertyName("serverInfo"); writer.Serialize(ServerInfo); } if (Changes != null && Changes.Any()) { writer.WritePropertyName("changes"); writer.Serialize(Changes.Where(modelEvent => !(modelEvent is ModelValueChangeEvent) || ExoWeb.IncludeInClientModel(((ModelValueChangeEvent)modelEvent).Property))); } }
public new int NextInstanceID() { var childContainers = Instances.SelectMany(it => it.ChildContainers); return(Math.Min(Instances.Any() ? Instances.Min(it => it.InstanceID.GetValueOrDefault()) : 0, childContainers.Any() ? childContainers.Min(it => it.NextInstanceID()) : 0) - 1); }