Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What is "public object" in C#?

Here's my code from Visual Studio that I'm trying to deconstruct:

public class DrawingTypeController : Controller
    {
        private readonly IDrawingService _drawingService; //you're bringing all of the functionality represented by the IDrawingSErvice in your Planroom.Services directory and naming it _drawingService
        private readonly AttachmentOptions _attachmentOptions;
        public DrawingTypeController(IDrawingService drawingService)
        {
            _drawingService = drawingService;
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            return View();//going to return Index.cshtml in your Views/DrawingType directory
        }
        [HttpGet] //attribute that decorates a method or class, will only work with a GET verb. Won't work with a POST
        public object GetDrawingTypes(DataSourceLoadOptions loadOptions) //this is what's grabbing your content. GetDrawingTypes is coming from your DrawingService in Services directory
            //
        {
            var data = _drawingService.GetDrawingTypes();//you're digging into your IDrawingService interface and accessing the GetDrawingTypes method
            return DataSourceLoader.Load(data, loadOptions);//you're returninging the results you've stored in your data var
        }

    }

Open in new window


This is what I understand thus far:

Just like you declare a variable by first defining its datatype, you follow the same process by in the first construct by defining a variable called "_drawingservice" which, based on the qualifiers, "private" and "readonly," this is exclusive to the DrawingType controller class and it will not change. It has a "datatype" of IDrawingService.

public DrawingTypeController(IDrawingService drawingService) is a construct that  is creating an instance of IDrawingService and calling it "drawingService." I then save the parameter "drawingService" into the field that I created a moment ago called "_drawingService."

<b>Real quick: The constructor "DrawingTypeController" is a naming convention that invokes that construct when this page is accessed, correct? That's why it's name "DrawingTypeController." Yes?</b>

The next part of the page is where I have my question: What is public object GetDrawingTypes? I'm thinking that it's a construct just like it's predecessors, but what's the significance of it being an "object?" Why could it not have been called "public GetDrawingTypes?"
SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Thank you!