Using a returned instance?

Issue I have a hierarchy of classes that perform API requests. In the base class, I build the request object, and in some subclasses, this method is overridden. Base class: protected virtual HttpRequestMessage BuildRequest(HttpMethod method, Uri uri, HttpContent content =

Continue reading

XamlParseException: Could not load file or assembly 'ResourceLibrary, …' or one of its dependencies. The system cannot find the file specified

Issue System.Windows.Markup.XamlParseExceptionoccurred A first chance exception of type ‘System.Windows.Markup.XamlParseException’ occurred in PresentationFramework.dll Additional information: ‘Set property ‘System.Windows.ResourceDictionary.Source’ threw an exception.’ Line number ’21’ and line position ‘6’. “Could not load file or assembly ‘ResourceLibrary, Culture=neutral’ or one of its dependencies.

Continue reading

C# 8 understanding await using syntax

Issue I have next method: public async Task<IEnumerable<Quote>> GetQuotesAsync() { using var connection = new SqlConnection(_connectionString); var allQuotes = await connection.QueryAsync<Quote>(@”SELECT [Symbol], [Bid], [Ask], [Digits] FROM [QuoteEngine].[RealtimeData]”); return allQuotes; } Everything fine and clear, connection will be disposed at the

Continue reading

'ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.' – C#

Issue The code: private void btnSave_Click(object sender, EventArgs e) { using (con = new SqlConnection(connectionString)) { SqlCommand cmd; switch (action) { case ‘a’: cmd = new SqlCommand("INSERT INTO tbl_User (userName, userPass) Values (@username, @userpass)", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@username", txtUN.Text.Trim());

Continue reading

Best way to alias expression

Issue I’m writing a program in C++, and at one part I want the program to sleep for 1 second. I’m using the following expression to be platform independent: std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(1000)); This line is way too long, so I want

Continue reading

How to naming namespaces for product that have sub-products/modules?

Issue I read that carefully. And yes very helpful! https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-namespaces Assuming you have following products and namespaces Microsoft.Dynamics.Inventory is a DLL Microsoft.Dynamics.Bank is a DLL Each of above have (Views, Reports, Utils, etc) Microsoft.Dynamics.Inventory.DLL Should I go for that? Microsoft.Dynamics.Inventory.Sales.Reports

Continue reading

Does a C# using statement perform try/finally?

Issue Suppose that I have the following code: private void UpdateDB(QuoteDataSet dataSet, Strint tableName) { using(SQLiteConnection conn = new SQLiteConnection(_connectionString)) { conn.Open(); using (SQLiteTransaction transaction = conn.BeginTransaction()) { using (SQLiteCommand cmd = new SQLiteCommand(“SELECT * FROM ” + tableName, conn))

Continue reading

C# – getting out of using with return doesnt work

Issue This method works: HttpResponseMessage responseMessage = await GetResponseMessage(pathWithParams: $"https://api.webasd.com/crm/v3565/objects/contacts?&limit=100&after={afterValue}&archived=false"); private Task<HttpResponseMessage> GetResponseMessage(string pathWithParams = null, HttpRequestMessage requestMessage = null) { var httpClient = new HttpClient(); var bearerToken = _configuration["BEARER_TOKEN"]; httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken); if (pathWithParams != null) {

Continue reading

Combining foreach and using

Issue I’m iterating over a ManageObjectCollection.( which is part of WMI interface). However the important thing is, the following line of code. : foreach (ManagementObject result in results) { //code here } The point is that ManageObject also implements IDisposable,

Continue reading

angular: ng-class in ng-repeater , duplicate call

Issue first of all sorry for my English. my problem is: i’ve this simple code: <li ng:repeat=”item in menu.items” ng:class=”getMenuItemClass(item)”> <a ng:href=”#{{item.url}}”>{{item.label}}</a> </li> and this my getMenuItemClass: scope.getMenuItemClass = function(item) { console.log(item) var hashPath = $location.hashPath || ‘/’; if (hashPath

Continue reading

ng-class messing with the order of classes

Issue I have some very simple Angular code which looks like this… <div ng-repeat=”message in data.messages” ng-class=”‘conversationCard-‘ + message.type”></div> It works, but the resulting output looks like this…. <div ng-repeat=”message in data.messages” ng-class=”‘conversationCard-‘ + message.type” class=”ng-scope conversationCard-phone”></div> The problem is

Continue reading

is it possible to combine multiple ng-class

Issue is it possible to avoid repeating the code here by replacing the ng-switch by ng-class. <li ng-repeat=”el in elm.required”> <span ng-switch on=”el.type” > <i class=”icon-file” ng-switch-when=”upload” tooltip=”{{el.name}}” ng-class=”{‘muted’:!el.completed}”></i> <i class=”icon-check” ng-switch-when=”checkbox” tooltip=”{{el.name}}” ng-class=”{‘muted’:!el.completed}”></i> <i class=”icon-calendar” ng-switch-when=”date” tooltip=”{{el.name}}” ng-class=”{‘muted’:!el.completed}”></i> <i

Continue reading

How to change the color of the div based on a value

Issue Here are the scripts and style that I used: <script src=”angular.min.js”></script> <style> .greater { color:#D7E3BF; background-color:#D7E3BF; } .less { color:#E5B9B5; background-color:#E5B9B5; } </style> <script> var app = angular.module(‘MyTutorialApp’, []); app.controller(“controller”, function ($scope) { $scope.chargeability = [{ date: ’15-Sep-13′, max:

Continue reading

ng-class is not applied

Issue I am trying to validate a form using AngularJS. This is my form: <form ng-controller=”LoginCtrl” role=”form” class=”form-horizontal”> <div class=”form-group”> <label for=”email” class=”col-sm-2 control-label”>Email</label> <div class=”col-sm-10″> <input required type=”email” name=”email” ng-model=”email” class=”form-control” ng-class=”{ error: email.$invalid }” id=”email”> </div> </div> </form>

Continue reading

Angular apply class in directive

Issue I have a angular directive which will produce bootstrap form-group, looks for $scope.errors for value of ng-model of the directive to show errors.. Example below: My html code: <input type=”text” b-input ng-model=”data.company.name” label=”Company Name” class=”form-control”/> and my directive code:

Continue reading

Inject scope in ng-class

Issue my problem is simple: i’m doing this: <div class=”text-center tag row class_{{infoticket.tags[0]}}”>{{infoticket.tags[0]}}</div> <div ng-repeat=”item in ticketcontent track by $index”> <div style=”display: block” class=”container row col-md-offset-1 col-md-8″ ng-class=”{true: ‘agent’, false: ‘collab_infoticket.tags[0]’} [item.author_id == 591119252 || item.author_id == 619780882 || item.author_id

Continue reading

Angular dirrectives and ng-class

Issue Suppose a directive with html e.g. in component.html like <div class=”text-field” ng-class=”{‘classA’: varA}”> …. </div> then I’m trying to do… <component ng-class=”{‘classB’: varB}”></component> After that in ng-class I’m having something like {‘classB’: varB} {‘classA’: varA} that is obviously not

Continue reading