Click here to Skip to main content
15,919,749 members
Home / Discussions / C#
   

C#

 
AnswerRe: Centralized database for c# Windows Application (WinForms) Pin
Ravi Bhavnani27-Apr-24 10:01
professionalRavi Bhavnani27-Apr-24 10:01 
GeneralRe: Centralized database for c# Windows Application (WinForms) Pin
theo tuombe27-Apr-24 11:16
theo tuombe27-Apr-24 11:16 
QuestionSelf referencing loop detected for property with type ... Pin
AtaChris22-Apr-24 9:02
AtaChris22-Apr-24 9:02 
AnswerRe: Self referencing loop detected for property with type ... Pin
Richard Andrew x6422-Apr-24 12:37
professionalRichard Andrew x6422-Apr-24 12:37 
AnswerRe: Self referencing loop detected for property with type ... Pin
AtaChris22-Apr-24 21:30
AtaChris22-Apr-24 21:30 
AnswerRe: Self referencing loop detected for property with type ... Pin
Dave Kreskowiak22-Apr-24 13:43
mveDave Kreskowiak22-Apr-24 13:43 
GeneralRe: Self referencing loop detected for property with type ... Pin
AtaChris22-Apr-24 21:28
AtaChris22-Apr-24 21:28 
GeneralRe: Self referencing loop detected for property with type ... Pin
Dave Kreskowiak23-Apr-24 4:48
mveDave Kreskowiak23-Apr-24 4:48 
That's not how you do dependency injection.

Your Indicator class is useless as it has no way of setting its TradingManager property. Also, the JsonIgnoreAttribute is only useful if you're serializing the Indicator class to a file. I'm leaving the Indicator out of your code.
C#
class MyTradingManager : ITradingManager
{
   ... Code to implement the ITradingManager interface ...
}

C#
internal class SampleIndicator : ExtendedIndicator
{
      private ITradingManager _tradingManager;

      public SampleIndicator(ITradingManager tradingManager)
      {
           _tradingManager = tradingManager;
      }

      ... Code that uses the ITradingManager implementation ...
}

Note, for this to work, you cannot make SampleIndicator dependent on MyTradingManager. It should take an instance of some implementation of ITradingManager instead. MyTradingManager is that implementation. Whatever code is creating instances of this stuff has to create an instance of MyTradingManager and pass that to the constructor of SampleIndicator:
C#
{
    ...
    ITradingManager manager = new MyTradingManager();           // Create the dependency
    SampleIndicator indicator = new SampleIndicator(manager);   // Inject the dependency into SampleIndicator
    ...
}


QuestionHow to print the property values of an object to a file/console ? Pin
AtaChris22-Apr-24 8:51
AtaChris22-Apr-24 8:51 
AnswerRe: How to print the property values of an object to a file/console ? Pin
Dave Kreskowiak22-Apr-24 13:49
mveDave Kreskowiak22-Apr-24 13:49 
GeneralRe: How to print the property values of an object to a file/console ? Pin
AtaChris22-Apr-24 21:23
AtaChris22-Apr-24 21:23 
GeneralRe: How to print the property values of an object to a file/console ? Pin
Pete O'Hanlon22-Apr-24 22:44
mvePete O'Hanlon22-Apr-24 22:44 
GeneralRe: How to print the property values of an object to a file/console ? Pin
Dave Kreskowiak23-Apr-24 4:10
mveDave Kreskowiak23-Apr-24 4:10 
QuestionHow to identify Key Combinations ? Pin
AtaChris15-Apr-24 6:26
AtaChris15-Apr-24 6:26 
AnswerRe: How to identify Key Combinations ? Pin
Dave Kreskowiak15-Apr-24 6:35
mveDave Kreskowiak15-Apr-24 6:35 
QuestionHow to send property values via eventhandler ? Pin
AtaChris7-Apr-24 7:41
AtaChris7-Apr-24 7:41 
AnswerRe: How to send property values via eventhandler ? Pin
OriginalGriff7-Apr-24 20:23
mveOriginalGriff7-Apr-24 20:23 
GeneralRe: How to send property values via eventhandler ? Pin
AtaChris15-Apr-24 6:46
AtaChris15-Apr-24 6:46 
GeneralRe: How to send property values via eventhandler ? Pin
OriginalGriff15-Apr-24 19:09
mveOriginalGriff15-Apr-24 19:09 
QuestionRead information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 9:43
Victor Gonzalez 20245-Apr-24 9:43 
AnswerRe: Read information from serial port in Mathlab format Pin
Richard Andrew x645-Apr-24 11:01
professionalRichard Andrew x645-Apr-24 11:01 
GeneralRe: Read information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 12:26
Victor Gonzalez 20245-Apr-24 12:26 
AnswerRe: Read information from serial port in Mathlab format Pin
jschell5-Apr-24 12:20
jschell5-Apr-24 12:20 
GeneralRe: Read information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 12:28
Victor Gonzalez 20245-Apr-24 12:28 
GeneralRe: Read information from serial port in Mathlab format Pin
Richard MacCutchan5-Apr-24 22:44
mveRichard MacCutchan5-Apr-24 22:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.