Tuesday, February 27, 2018

Polaris

1. Define each term in SOLID and explain where you have used it in your project?
2. Component Life Cycle and what happen in each stage?
3. Define all the method in angular life cycle?
4. Difference between component life cycle and directive life cycle.
5. What is Map in observables?

HCL

1.What is Singleton?
2.Difference between Singleton and Static
3.How Sring.Format work?
Ans use params string[] array.

4. Can we call WebAPI controller from MVC controller?
Ans: using HttpClient we can.
5. If we have a constant in one library and we have changed its value than should we rebuild the project which has included this library.
Ans Yes, In case of constant you need to rebuild the both project while in case of readonly, static and instance variable no need to rebuild the project.

Consider a class defined in AssemblyA.

public class Const_V_Readonly
{
  public const int I_CONST_VALUE = 2;
  public readonly int I_RO_VALUE;
  public Const_V_Readonly()
  {
     I_RO_VALUE = 3;
  }
}

in the case of the const value, it is like a find-replace, the value 2 is 'baked into' the AssemblyB's IL. This means that if tomorrow I'll update I_CONST_VALUE to 20 in the future. AssemblyB would still have 2 till I recompile it.

in the case of the readonly value, it is like a ref to a memory location. The value is not baked into AssemblyB's IL. This means that if the memory location is updated, AssemblyB gets the new value without recompilation. So if I_RO_VALUE is updated to 30, you only need to build  AssemblyA. All clients do not need to be recompiled.

Source : https://stackoverflow.com/questions/55984/what-is-the-difference-between-const-and-readonly/56024#56024

6. How String.Format design for multiple arguments.
Ans using params object[]

7. Security in Web API.

Saturday, February 24, 2018

Difference Between Temp table and Table Variable

1. Temp table easy to create and backup data. Table variable involves the effort when we usually create the normal table.

2.Result of temp table can be used by multiple user. Table variable can be used by current user only.

3. Both are stored in tempdb.

4. Temp table supports all the DDL operations. We can alter table , drop table. Table Variable won't allow DDL operations.

5. Temp table can be used for current session or global so that multiple user session can utilize the results in table. Table variable can be used up to current program(stored procedure)

6.Table variable does not affected by transaction means we can not roll back table variable. While temp table operation can be rollback using transaction.

7. Function cannot use the temp table. But the function allows us to use the table variable. More over we cannot do the DML operation in the functions but using the table variable we can do that.

8. The stored procedure will do the recompilation (can't use same execution plan) when we use the temp variable for every sub sequent calls. Where the table variable won't do like that.

9. As far as performance is concerned table variables are useful with small amounts of data (like only a few rows). Temporary table is useful when sifting through large amounts of data.

10. Table variables can not have Non-Clustered Indexes
11. You can not create constraints in table variables
12. You can not create default values on table variable columns
13. Statistics can not be created against table variables.
14. Temp table support explicit index, we can create index on temp table. Table variable does not support index, we can not create index on table variable.

Friday, February 23, 2018

Merge Command

Merge command used to Combine Insert,Update and Delete into single statement.

MERGE INTO dbo.energydata WITH (HOLDLOCK) AS target
USING dbo.temp_energydata AS source
    ON target.webmeterID = source.webmeterID
    AND target.DateTime = source.DateTime
WHEN MATCHED THEN
    UPDATE SET target.kWh = source.kWh
WHEN NOT MATCHED BY TARGET THEN
    INSERT (webmeterID, DateTime, kWh)
    VALUES (source.webmeterID, source.DateTime, source.kWh)
WHEN NOT MATCHED BY SOURCE THEN
    DELETE;
    

Thursday, February 22, 2018

Genpact

1. How to post a method in Web API?
Ans using HttpPost.
2. Routing in Web API?
3. Life Cycle of Web API?
4. Difference between get and post.
5. Post is cacheble or not?
Ans No
6. Exception Handling in WCF?
7. Merge command in SQL.
8. Difference between temp table and table variable.
9. In which we can use transaction (temp table, table variable)
Ans : temp table.
10. Difference between value type and reference type.
11. Difference between Pass by value and Pass by reference.
12. What is garbage collector?
13. What is Dipose method?
14. If a class contain both destructor and Dispose which will be called first.
15. How will you define explicit interfac?
16. When the static constructor of a class called.
classA.PropertyName
classA obj = new classA()
17. What is boxing and unbosing?
18. Difference between equalto and ==
19. Difference between sub query and co related query.
20. How to validate field in MVC?
Ans:
21. How can we make the object in java-script
22. Prototype function in java-script
Ans :

Window -- Document(Html Element) -- (Head and Body)


23. What is the hierarchy in DOM
24. How many ways we get the element in java-script
Ans 

GetElementsByName
GetElementsById
GetElementsByTagName
GetElementByClass

querySelectorAll (It is called CSS Selector also)
var x = document.querySelectorAll("p.intro");

finds the form element with id="frm1"
var x = document.forms["frm1"];

Difference Between Subject and Observable

Subject is a special kid of observable.

All subscribers to a subject share the same execution of the subject. i.e. when a subject produces data, all of its subscribers will receive the same data. This behavior is different from observables, where each subscription causes an independent execution of the observable.

Ex.

var subject = new Rx.Subject();

// Here the subject is acting like a data producer
// because it is being subscribed to
subject.subscribe(v => console.log('consumer A: ' + v));
subject.subscribe(v => console.log('consumer B: ' + v));

// Create a source of the data, which in our case is an observable
var observable = Rx.Observable.from([0, 1]);

// Here the same subject as a data consumer because it
// can subscribe to another observable

observable.subscribe(subject);

/* Prints */
// Consumer A: 0
// Consumer B: 0
// Consumer A: 1
// Consumer B: 1

Here are some point to motice

1. I had to setup my subscriptions before my subject subscribed to the source.
2. Both the consumers logged the same value for v.

The fact that our consumers log the same data implies that the broadcasted data is shared with all the consumers/subscribers. This is unlike observables, where each consumer/subscriber causes the observable function to be re-executed.

Ex of observable

var observable = Rx.Observable.create(function(source) {
  source.next(Math.random());
});

observable.subscribe(v => console.log('consumer A: ' + v));
observable.subscribe(v => console.log('consumer B: ' + v));

/* Prints DIFFERENT values for both consumers */
// consumer A: 0.25707833297857885
// consumer B: 0.8304769607422662

If we want our observable broadcast same value than we have to wrap it in subject as below

var observable = Rx.Observable.create(function(source) {
  source.next(Math.random());
});

var subject = new Rx.Subject();

subject.subscribe(v => console.log('consumer A: ' + v));
subject.subscribe(v => console.log('consumer B: ' + v));

observable.subscribe(subject);

/* Prints SAME values for both consumers */
// consumer A: 0.8495447073368834
// consumer B: 0.8495447073368834


Observable are unicast and Subject are multicast.

Unicast means each subscriber have a independent execution of observable.
Multicast  : All subscriber  will share the same execution plan. 

Wednesday, February 21, 2018

Icreaon

1. What is Agile?
2. What is scrum?
3. What are other framework in Agile?
4. What is story, epic and themes?
Ans: https://www.atlassian.com/agile/project-management/epics-stories-themes
5. What story point?
Ans : It is the priority of story in terms of weightage ( It is in fabnicaony series)?
6. Why we give weightage in fibnocay series?
7. What is sprint and what is your sprint duration?
8. What is different between sprint and release?
9. Why did you use singleton in your project?
10. What is TDD?
11. What approach did you use Test first or code first?
12. There is biggest disadvantage of using TDD, what is it?
13. Have you worked on unit testing and integration testing?
14. What is D in SOLID principle?
15-- Why do we use dependency injection
16. What dependency injection have you used?
17. When do we use property dependency injection?
18. Dependency Injection, Inversion of Control
19. What IOC container you haev used?
20. What is the best conventional approach for dependency injection?
Ans using Reflection (most probably)
21. Difference IEnumerable and IQueryable 22. What will be sql query for IEnumberable and IQueryable using in Select statement?
22. What will you use array or arraylist in terms of performance?
23. Difference between char and varchar, varchar and nvarchar.
24. If there is a private constructor in singleton than how we are able to create object?
25. What challenges you have faced in your tenure?
27. What is .map of Rx?


28. What is subject.next()?

Tuesday, February 20, 2018

Difference between component and directives

Component have their own view using html and class, while directives are behavior added to existing element or component.

Component extends directive.

A directive may or may not have view but a component always have view.

Difference Between Promise and Observable

Observable is more powerful way of handling http asynchronous requests.

A Promise handles a single event when an async operation completes or fails.

Note: There are Promise libraries out there that support cancellation, but ES6 Promise doesn’t so far.


An Observable is like a Stream (in many languages) and allows to pass zero or more events where the callback is called for each event.

Promises:
returns a single value
not cancellable
Promises are eager while obeservable are lazy
Observables:
works with multiple values over time
cancellable
supports map, filter, reduce and similar operators
proposed feature for ES 2016
use Reactive Extensions (RxJS)
an array whose items arrive asynchronously over tim
There are also powerful operators like retry(), or replay().


Single value vs multiple values

Promises are most commonly used to handle HTTP requests. In this model, you make a request and then wait for a single response. You can be sure that there won’t be multiple responses to the same request.

const numberPromise = new Promise((resolve) => {
    resolve(5);
});

numberPromise.then(value => console.log(value));
It will print 5.

Promise is always resolved with the first value passed to the resolve function and ignores further calls to it:

const numberPromise = new Promise((resolve) => {
    resolve(5);
    resolve(10);
});

numberPromise.then(value => console.log(value));
// still prints only 5

On the contrary, Observables allow you to resolve (or, as we say, “emit”) multiple values. Here is how it would look:

const numberObservable = new Observable((observer) => {
    observer.next(5);
    observer.next(10);
});

numberObservable.subscribe(value => console.log(value));
// prints 5 and 10

Let’s for example see how wrapping setInterval in Observable would look like.

const secondsObservable = new Observable((observer) => {     
    let i = 0;
    setInterval(() => {
        observer.next(i++);
    }, 1000);
});

secondsObservable.subscribe(value => console.log(value));
// logs:
// 0
// 1
// 2
// and so on, every second

Eager vs lazy

Let’s rewrite setInterval example

const secondsPromise = new Promise((resolve) => {     
    let i = 0;
    setInterval(() => {
        resolve(i++);
    }, 1000);
});

We have a problem here. Even though no one is listening for these numbers (we are not even logging them here),
setInterval is still called immediately at the moment of Promise creation. We are wasting resources, emitting values that no one will listen to. This happens because Promise constructor immediately calls function passed to it.

On the contrary test following, Observable based, code:

const observable = new Observable(() => {
    console.log('I was called!');
});

This time nothing happens. This is because while Promises are eager, Observables are lazy. Function passed to Observable constructor gets called only when someone actually subscribes to an Observable:

Not cancellable vs cancellable
Here is the code of observable for cancellation

const subscription =
    secondsObservable.subscribe(value => console.log(value));

subscription.unsubscribe();


Monday, February 19, 2018

Genpact

1. What is state management in angular2
2. What is route gaurd?
3. What is ngConent?

  • 4. What is @Inject As?

5. What is Magic table?
6. What are tables in Magic tables?
7. If we have not used @Injectable  than what will happen?
8. Difference between Singleton and Static?
9. What are the ways to pass data from component to component?
10. What is data binding in angular 2?
Ans : https://www.c-sharpcorner.com/article/data-binding-in-angular-2/
11. If a method defined as HtttpGet and at client side you are posting data using post method than what will happen?
12. What are directives and type of directives?



Sunday, February 18, 2018

Passing data from component to component using services

When passing data between components that lack a direct connection, such as siblings, grandchildren, etc, than use shared service.

When you have data that should aways been in sync, I prefer a BehaviorSubject.

It will always return the current value on subscription - there is no need to call onnext
It has a getValue() function to extract the last value as raw data.
It ensures that the component always receives the most recent data.

In the service, we create a private BehaviorSubject that will hold the current value of the message. We define a currentMessage variable handle this data stream as an observable that will be used by the components. Lastly, we create function that calls next on the BehaviorSubject to change its value.

The parent, child, and sibling components all receive the same treatment. We inject the DataService in the constructor, then subscribe to the currentMessage observable and set its value equal to the message variable.

Now if we create a function in any one of these components that changes the value of the message. when this function is executed the new data it’s automatically broadcast to all other components.

data.service.ts

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';

@Injectable()
export class DataService {

  private messageSource = new BehaviorSubject("default message");
  currentMessage = this.messageSource.asObservable();

  constructor() { }

  changeMessage(message: string) {
    this.messageSource.next(message)
  }

}

parent.component.ts

import { Component, OnInit } from '@angular/core';
import { DataService } from "../data.service";

@Component({
  selector: 'app-parent',
  template: `
    {{message}}
  `,
  styleUrls: ['./sibling.component.css']
})
export class ParentComponent implements OnInit {

  message:string;

  constructor(private data: DataService) { }

  ngOnInit() {
    this.data.currentMessage.subscribe(message => this.message = message)
  }

}

sibling.component.ts

import { Component, OnInit } from '@angular/core';
import { DataService } from "../data.service";

@Component({
  selector: 'app-sibling',
  template: `
    {{message}}
    <button (click)="newMessage()">New Message</button>
  `,
  styleUrls: ['./sibling.component.css']
})
export class SiblingComponent implements OnInit {

  message:string;

  constructor(private data: DataService) { }

  ngOnInit() {
    this.data.currentMessage.subscribe(message => this.message = message)
  }

  newMessage() {
    this.data.changeMessage("Hello from Sibling")
  }

Lifecycle hook of Component



ngOnChanges()

Respond when Angular (re)sets data-bound input properties. The method receives a SimpleChanges object of current and previous property values.

Called before ngOnInit() and whenever one or more data-bound input properties change.

ngOnInit()
Initialize the directive/component after Angular first displays the data-bound properties and sets the directive/component's input properties.

Called once, after the first ngOnChanges().

ngDoCheck()
Detect and act upon changes that Angular can't or won't detect on its own.

Called during every change detection run, immediately after ngOnChanges() and ngOnInit().

ngAfterContentInit()
Respond after Angular projects external content into the component's view.

Called once after the first ngDoCheck().

A component-only hook.

ngAfterContentChecked()
Respond after Angular checks the content projected into the component.

Called after the ngAfterContentInit() and every subsequent ngDoCheck().

A component-only hook.

ngAfterViewInit()
Respond after Angular initializes the component's views and child views.

Called once after the first ngAfterContentChecked().

A component-only hook.

ngAfterViewChecked()
Respond after Angular checks the component's views and child views.

Called after the ngAfterViewInit and every subsequent ngAfterContentChecked().

A component-only hook.

ngOnDestroy()
Cleanup just before Angular destroys the directive/component. Unsubscribe Observables and detach event handlers to avoid memory leaks.

Called just before Angular destroys the directive/component.

Source : https://angular.io/guide/lifecycle-hooks

Passing data from Parent to Child using Local variable

Parent Template can access the child component properties and methods by creating the template reference variable.

No change in child component.
parent.component.ts is

import { Component} from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
        <h1>{{title}}!</h1>
        <p> current count is {{child.count}} </p>
        <button (click)="child.increment()"<Increment</button>
        <button (click)="child.decrement()"<decrement</button>
        <child-component #child></child-component>` ,
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'Parent interacts with child via local variable';
}

Passing data from child to parent using ViewChild

ViewChild allows a one component to be injected into another, giving the parent access to its attributes and functions. One caveat, however, is that child won’t be available until after the view has been initialized. This means we need to implement the AfterViewInit lifecycle hook to receive the data from the child.

Child Component
There is no change in the child component


Parent Component
In parent component, we need to import the viewChild annotation. We also need to import the child component

import { Component, ViewChild } from '@angular/core';
import { ChildComponent } from './child.component';

@Component({
  selector: 'app-root',
  template: `
        <h1>{{title}}</h1>
        <p> current count is {{child.count}} </p>
        <button (click)="increment()">Increment</button>
        <button (click)="decrement()">decrement</button>
        <child-component></child-component>` ,
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'Parent calls an @ViewChild()';

  @ViewChild(ChildComponent) child: ChildComponent;

  increment() {
    this.child.increment();
  }

  decrement() {
    this.child.decrement();
  }
}

Two way data binding

Two-way data binding combines the input and output binding into a single notation using the ngModeldirective.
<input [(ngModel)]="name" >
What this is doing behind the scenes is equivalent to:
<input [ngModel]="name" (ngModelChange)="name=$event">
To create your own component that supports two-way binding, you must define an @Output property to match an @Input, but suffix it with the Change. The code example below, inside class CounterComponent shows how to make property count support two-way binding.
app/counter.component.ts
import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'rio-counter',
  templateUrl: 'app/counter.component.html'
})
export class CounterComponent {
  @Input() count = 0;
  @Output() countChange = EventEmitter<number>();

  increment() {
    this.count++;
    this.countChange.emit(this.count);
  }
}
app/counter.component.html
<div>
  <p>
    <ng-content></ng-content>    Count: {{ count }} -
    <button (click)="increment()">Increment</button>
  </p></div>
Source https://angular-2-training-book.rangle.io/handout/components/app_structure/two_way_data_binding.html
https://blog.thoughtram.io/angular/2016/10/13/two-way-data-binding-in-angular-2.html

Saturday, February 17, 2018

Difference Between Put and Post

Idempotency is the main difference between PUT and POST. Similar to the GET request, PUT request is also idempotent in HTTP, which means it will produce the same results if executed once more multiple times. 

PUT is idempotent, so you can cache the response. Response of Post method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.

Use PUT when you want to modify a singular resource which is already a part of resources collection. PUT replaces the resource in its entirety. Use PATCH if request updates part of the resource.

In case of Put,  If the Request-URI refers to an already existing resource – an update operation will happen, otherwise create operation should happen if Request-URI is a valid resource URI

Another practical difference PUT and POST method in the context of REST WebService are that POST is often used to create a new entity, and PUT is often used to update an existing entity. If you replace an existing entity using PUT than you should be aware that if only a subset of data elements is passed then the rest will be replaced by empty or null.


Difference Between IEnumerable,ICollection and IList

IEnumerable 


IEnumerable interface contains only a single method definition i.e., GetEnumerator() and the GetEnumerator method must return an instance of an object of a class which implements the IEnumerator interface

Hide   Copy Code
public interface IEnumerable
{
IEnumerator GetEnumerator();
}
The IEnumerator interface implements two methods, MoveNext() and Reset() and it also has one property called Current that returns the current element in the list.

ICollection

ICollection inherits IEnumerable apart from it contains some more method and count property

public interface ICollection : IEnumerable
{
int count { get; }
bool IsSynchronized { get; }
Object SyncRoot { get; }
void CopyTo(Array array,int index);
}

The IsSynchronized and SyncRoot properties help to make the collection thread-safe.

ICollection<T>

This is the generic version of ICollection Interface.

Defines methods to manipulate generic collections.

Hide   Copy Code
public interface ICollection : IEnumerable, IEnumerable
{
int count { get; }
bool IsReadOnly { get; }
void Add(T item);
void Clear();
bool Contains(T item);
void CopyTo(T[] array, it arrayIndex);
bool Remove(T item);
}

IList

1. IList exist in System.Collections
2. IList Interface implements both IEnumerable and ICollection Interface.
3. IList is used to access an element in a specific position/index in a list.
4. Like IEnumerable, IList is also best to query data from in-memory collections like List, Array, etc.
5. IList is useful when you want to add or remove items from the list.
6. IList can find out the number of elements in the collection without iterating the collection.
7. IList supports deferred execution.
8. IList doesn’t support further filtering.

public interface IList : ICollection,IEnumerable
{
bool IsFixedSize { get; }
bool IsReadOnly { get; }
Object this[int index] { get;set; }
int Add(Object value);
int IndexOf(Object value);
void Insert(intindex,object value);
void Remove(Object value);
void RemoveAt(int index);
}

Difference between IEnumerable,IQueryable

IEnumerable is the base interface of IQueryable, ICollection and IList.

IEnumerable

1. IEnumerable exists in System.Collections Namespace.

2. IEnumerable can move forward only over a collection, it can’t move backward and between the items.

3. IEnumerable is best to query data from in-memory collections like List, Array etc.

4. While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data.

5. IEnumerable is suitable for LINQ to Object and LINQ to XML queries.

6. IEnumerable supports deferred execution.

7. IEnumerable doesn’t supports custom query.

8. IEnumerable doesn’t support lazy loading. Hence not suitable for paging like scenarios.

9. Extension methods supports by IEnumerable takes functional objects.

IEnumerable Example
 MyDataContext dc = new MyDataContext ();
IEnumerable<Employee> list = dc.Employees.Where(p => p.Name.StartsWith("S"));
list = list.Take<Employee>(10);

Generated SQL statements of above query will be :
 SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
WHERE [t0].[EmpName] LIKE @p0

Notice that in this query "top 10" is missing since IEnumerable filters records on client side

IQueryable 

1. IQueryable exists in System.Linq Namespace.

2. IQueryable can move forward only over a collection, it can’t move backward and between the items.

3, IQueryable is best to query data from out-memory (like remote database, service) collections.

4. While query data from database, IQueryable execute select query on server side with all filters.

5. IQueryable is suitable for LINQ to SQL queries.

6. IQueryable supports deferred execution.

7. IQueryable supports custom query using CreateQuery and Execute methods.

8. IQueryable support lazy loading. Hence it is suitable for paging like scenarios.

9. Extension methods supports by IQueryable takes expression objects means expression tree.

IQueryable Example
 
MyDataContext dc = new MyDataContext ();
IQueryable<Employee> list = dc.Employees.Where(p => p.Name.StartsWith("S"));
list = list.Take<Employee>(10); 

Generated SQL statements of above query will be :
 SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
WHERE [t0].[EmpName] LIKE @p0

Notice that in this query "top 10" is exist since IQueryable executes query in SQL server with all filters.


Friday, February 16, 2018

Value Type and Reference Type

Value type defined in a function goes in stack while value type associated with a class object i.e declared as a member variable goes in heap.

Reference type variable declared as member goes in heap as well their reference, if reference type variable are declared in a function than those variable will goes in heap but their reference will goes in stack.


https://photos.google.com/share/AF1QipO_WWADgrm06nlnC5cUohzW3J2l3KlLCrOiz5QvaVlfCVlHi-O2_Lsh_2Hw1EyI-g?key=WHdmSmpNRk8ybVNHcmNsb0JNZ2lEdGhIR1FKUU5R

Tuesday, February 13, 2018

R1 RCM

1. Is it correct?

Select * from (
Select 1 union select 2 ) t

Ans : No

This query will not run.
Error:  'no column was specified for column 1 of t'
Correct query is

Select * from (
Select 1 as m1 union select 2 as m2) t

2. Get 7th highest salary.
3. What is normalization?
4. Difference between char,varchar and nvarchar
5. Why we create minified version of js file?
Ans : Reason is
1.  Reducing the page load time of application.
2.  Many are use for security purpose they don't want to share code with others.

6. How we create a minified version of  js file?
Ans :
If we are using Wepack it will do minified and also bundle all dependecies into single budle.js.
Other tool used to minify are UglifyJS

7. Difference between IEnumerable, IQuerable and IList.
Ans : https://interview-preparation-for-you.blogspot.in/2018/02/difference-between-ienumerableiqueryable.html

8. What is anonymous type?
Ans : Anonymous type(class) used when we fetch data using LINQ and put them in a newly created anonymous class.

9. What is the difference between put and post?

Tuesday, February 6, 2018

Add Extension method for .Net 2.0

To add extension method in a library that is build on framework 2.0 you need to add following class in your project


using System;

#pragma warning disable 1685
namespace System.Runtime.CompilerServices
{
    [AttributeUsage (AttributeTargets.Method | 
    AttributeTargets.Class | AttributeTargets.Assembly)]
    public sealed class ExtensionAttribute : Attribute
    {
    }
}

With this mimic System.Runtime.CompilerServices.ExtensionAttribute class in your project, its compilation will succeed even when targeting .NET 2.0.


Note: Since our mimic ExtensionAttribute collides with the one in the global assembly cache, the compiler will generate a warning CS1685. We are of course deliberately doing this. Thus, we add the line of #pragma to suppress that warning.

Source : https://www.codeproject.com/Tips/512823/Using-Extension-Methods-in-NET-SP

Friday, February 2, 2018

DLR

DLR (Dynamic language runtime) is set of services which add dynamic programming capability to CLR. DLR makes dynamic languages like LISP, Javascript, PHP,Ruby to run on .NET framework.

Source : http://www.c-sharpcorner.com/uploadfile/shivprasadk/net-4-0-faq-part-i-the-dlr/

Bootstrap

Some Key points about bootstrap.

1. Bootstrap is CSS, HTML, Javascript framwork.
2. It is used to develop responsive website.
3. Meta data is used to ensure proper rendering and touch zooming on mobile devices.
4.Bootstrap grid system help to create page payout with rows and columns.
5. There are four type of devices

1. Extra Small  xs
2. Small  dm
3. Medium  md
4. Large   lg

6. In Bootstrap grid system all row should be within container.
7. Sum of each column should be 12.
8. If sum of column is greater than 12 than specific column where sum is exceeding 12 all column from there will be shift in next row.
9. In Bootstrap grid system col-lg-*, col-md-*  etc gives same look on each device whether it is large medium or small( in small they are stacked each other. If you want different look on each screen than you can override the behavior by specifying their class.

Thursday, February 1, 2018

Event Aggregator

Problem in traditional approach of event Handling

1. Tight coupling will not allow publisher and subscriber to change independently of each other.
2. The subscriber of the event needs to know the publisher of an event and refer it directly by event names causing a tight coupling between them.
3. If there are multiple subscriber and publisher then code becode hard to read and debug.
4. Its Subscriber responsibility to register and unregister from an event, And if subscriber forgets to unregister
than it will be memory leak because both subscriber and publisher will remain in memory.


Benefit of Event Aggregator

1. Simply subscribing and unsubscribing  to events.
2. Decouple publisher from subscribers allowing both to change without effecting the other.
3. Make it easy to add events.
4. Centralized handling of events.
5. Reduce wastage of system resources. ( not clear how)


Publish event using Prism (It is simulate to fire event)

PersonViewModel
public Person SelectedPerson 

get

return this.selectedPerson; 
}
set

if(this.selectedPerson!=value)

this.selectedPerson = value;
this.NotifyPropertyChanged("SelectedPerson");

// Publish event.
this
.iEventAggregator
.GetEvent<PubSubEvent<Person>>()
.Publish(this.SelectedPerson);
}
}
}

Subscribe event using Prism

class name is PersonViewModel

private IEventAggregator iEventAggregator;
public PersonDetails1ViewModel(IEventAggregator iEventAggregator)

this.iEventAggregator = iEventAggregator;
SubscriptionToken subscriptionToken =
this
.iEventAggregator
.GetEvent<PubSubEvent<Person>>()
.Subscribe((details) =>
{
this.Person = details;
});

this.Subscribe = new DelegateCommand(
() =>
{
subscriptionToken =
this
.iEventAggregator
.GetEvent<PubSubEvent<Person>>()
.Subscribe((details) =>
{
this.Person = details;
});
});

this.Unsubscribe = new DelegateCommand(
() => {

this
.iEventAggregator
.GetEvent<PubSubEvent<Person>>()
.Unsubscribe(subscriptionToken);
});
}

Another way to subscribe
private IEventAggregator iEventAggregator;
public PersonDetails2ViewModel(IEventAggregator iEventAggregator)
{
this.iEventAggregator = iEventAggregator;
this
.iEventAggregator
.GetEvent<PubSubEvent<Person>>()
.Subscribe((details) =>
{
this.Person = details;
});
}

In view we have to pass

this.DataContext = new PersonViewModel(Event.EventInstance.EventAggregator);

Evon

1.   What is the first step to create WCF service?
Ans: 1. Select the project type class library.
2. Add a class named Calc.
3. Add a namespace System.Runtime.Serialization.
4. Decorate the class with DataContratc.
5. Decorate the member with DataMember
6. Decorate the methods with OpertaionContract.
7. Add an interface named ICalcService.
8. Add a namespace System.ServiceModel
9. Decorate the interface with ServiceContract.
10. Decorate the method declaration with OperationContract.
11. Implement the class with interface ICalsService
12. Add ServiceBehavior attribute on class
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
13. Add the App.config and Edit it.

2.   What are Instance Mode?
3.   What are Concurrency Mode?
4.   Which is better WCF or Web APi?
5.   If we have two client desktop and Mobile what will you create?
6.   Where will be the entityframe work used in WPF or in WCF?
7.   How model will update while updating database in entity-framework?
Ans : Right clicking on your EDMX file and selecting Open With -> ADO.NET Entity Data Model Designer
Right click on the designer surface of the EDMX designer and click Update Model From Database...
All entities are refreshed by default, new entities are only added if you select them.

8.   What is renterent mode?
9.   What are the resources in WPF?
10. If you have user control consisting text block where will you create resources?
11. Can we mix Data Contract and Message Contract both in a single class?
Ans : No
 Mixing message and data contracts will cause a run time error when you generate WSDL from the service.
12. What is binding?
13. How will you fast a WPF application?
14. What are the ways of DataContext?
Ans. Xaml and in Code behind
Xaml is better.

Difference Between Angular 1 and Angular 2

Why Angular 2
Angular 2 is five times faster than angular 1.In Angular 2 Bootstrap is platform specific. For Mobile it call different bootstrap and for desktop different.

For Browser it used dart.
package:angular2/platform/browser.dart

For mobile it used (It reduce loading time)
Apache Cordova 

In Angular there was no mobile suppport it is made for responsive and two way binding app. Although there are some other libraries that can be used to run angular 1 on Mobile. Angular is madekeeping in mind mobile oriend architechture.

Angular2 used typescript to write code it is easy to code for java/.net developer.

No $scope in Angular 1, used this operator to access member variable.

Same code render different view for mobile and desktop.

Angular 2 is component based.

Injectors changed significantly. Child injectors is new thing in Angular 2.
There were bunch of directives in Angular 1. Angular 2 has only Component, Decorator and Template directive.
JSON based Route config is more easy to edit.

Followers

Link