public void VInterop_TestAutoregisterPolicy() { var oldPolicy = UserData.RegistrationPolicy; try { string script = @"return myobj:Test1()"; UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; Script S = new Script(); SomeOtherClass obj = new SomeOtherClass(); S.Globals.Set("myobj", UserData.Create(obj)); DynValue res = S.DoString(script); Assert.AreEqual(DataType.String, res.Type); Assert.AreEqual("Test1", res.String); } finally { UserData.RegistrationPolicy = oldPolicy; } }
public void SomeFunction(int someValue) { // Replace with whatever your actual code is... ToDate toDate = new SomeOtherClass().SomeOtherFunction(someValue); CheckToDate(toDate); }
public static void Main() { SomeOtherClass thingy = new SomeOtherClass(); thingy.SomeMethod(); print(); }
public WhatClass() { int theCount = Count; // This will set theCount to 0 because int is a value type AProperty = new SomeOtherClass; // This is fine because the setter is totally usable SomeOtherClass thisProperty = AProperty; // This is completely acceptable because you just gave AProperty a value; thisProperty = AnotherProperty; // Throws NullReferenceException because you didn't first set the "AnotherProperty" to have a value }
public string MethodWithReturn() { var returnValue = SomeOtherClass.SomeMethod(); if (returnValue == null) { throw new InvalidOperationException("Return value of method 'MethodWithReturn' is null."); } return(returnValue); }
static void Main(string[] args) { var wrappedData = new Wrapper <int> { Data = 3 }; var someObject = new SomeOtherClass { WrappedData = wrappedData }; dynamic d = someObject.WrappedData; Console.WriteLine(d.Data); }
public void EqualityCheck() { var firstZeroPositiveInt = new ZeroPositiveInt(1); var secondZeroPositiveInt = new ZeroPositiveInt(1); Assert.AreEqual(firstZeroPositiveInt, secondZeroPositiveInt); var thirdZeroPositiveInt = new ZeroPositiveInt(2); Assert.AreNotEqual(firstZeroPositiveInt, thirdZeroPositiveInt); Assert.AreNotEqual(secondZeroPositiveInt, thirdZeroPositiveInt); var somethingElse = new SomeOtherClass(); Assert.AreNotEqual(secondZeroPositiveInt, somethingElse); }
public void Session_14_Virtual_Method_In_C_Sharp() { //An abstract class has a default implementation for a method. //The methods default implementation is needed in some class but not in some other class.How can you achieve it? SomeClass sc = new SomeClass(); sc.AbstractMethod();//See that base abstract class method is called SomeOtherClass soc = new SomeOtherClass(); soc.AbstractMethod();//Overridden method is called. //In below example method defined in child class will be called since it is present in child class OneMoreclass omc = new OneMoreclass(); omc.AbstractMethod(); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request THAT I MADE IN VS 2017."); // parse query parameter string name = req.GetQueryNameValuePairs() .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0) .Value; // Get request body dynamic data = await req.Content.ReadAsAsync <object>(); // Set name to query string or body data name = name ?? data?.name; var c1 = new SomeOtherClass { Id = 4, Name = "Four Guy" }; return(name == null ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body") : req.CreateResponse(HttpStatusCode.OK, "Hey there " + name)); }
public MyClass(ref int setting) { SomeOtherClass instance = new SomeOtherClass(s => setting = s); }
public IClass ProvideClass(SomeOtherClass impl) { return impl; }
public SomeClass() { var item = new SomeOtherClass(); }
public IClass ProvideClass(SomeOtherClass impl) { return(impl); }
public SomeClassBase() { SomeOtherClass.Test(this); }
// This class and this constructor are externally visible // The parameter of type SomeOtherClass must also be public in order // for external assemblies to be able to construct this type public SomeClass(SomeOtherClass someOtherClass) { }
public SomethingClass() { this._someOtherClass = new SomeOtherClass(); }
public void SomeMethod(SomeOtherClass thingy) { }
public MyConcreteThisIsNotCircularDependency(SomeOtherClass dep, SomeOtherClass dep2) { }
static void Main(string[] args) { SomeClass <int> someClass = new SomeClass <int>(); // działa dobrze (brak błędu) SomeClass <string> someClass = new SomeClass <string>(); // zgodnie z potrzebą T musi być numeryczne (zamierzony błąd) SomeOtherClass <int> someOtherClass = new SomeOtherClass <int>(); // ale użycie skrótu nie działa (błąd) }
public string MethodWithReturn() { return(SomeOtherClass.SomeMethod()); }
private void OnNewMessage(SomeOtherClass sender, InspectionSchemeChecks schemeChecks) { // Do what you want }
public SomeClass() { SomeOtherClass.MyFunction(out myObject); }
public void Interop_TestAutoregisterPolicy() { try { string script = @"return myobj:Test1()"; UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; Script S = new Script(); SomeOtherClass obj = new SomeOtherClass(); S.Globals.Set("myobj", UserData.Create(obj)); DynValue res = S.DoString(script); Assert.AreEqual(DataType.String, res.Type); Assert.AreEqual("Test1", res.String); } finally { UserData.RegistrationPolicy = InteropRegistrationPolicy.Explicit; } }
public Foo(SomeClassType xSct, SomeOtherClass xSoc) { // Note: No initializer list, we have to do those assignments manually sct = xSct; soc = xSoc; }
public SomeClass() { SomeOtherClass.MyFunction(this); }
public void Foo(SomeClass paramA, SomeOtherClass paramB) { }
public static void Print(this SomeOtherClass c) { // TODO: print SomeOtherClass }
static void aReference() { var foo = new SomeOtherClass(); }