logo
down
shadow

Getting reference to dependent in service with generic type


Getting reference to dependent in service with generic type

Content Index :

Getting reference to dependent in service with generic type
Tag : chash , By : Waynew
Date : November 23 2020, 03:01 PM

Hope that helps Autofac supports open generic registration and circular dependencies.
So it can be done like:
builder.RegisterGeneric(typeof (Service<>))
    .As(typeof (IService<>))
    .InstancePerLifetimeScope()
    .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies);
builder.RegisterType<SomeClass>()
    .InstancePerLifetimeScope();
public class HandlerRegistrationSource : IRegistrationSource
{
  public IEnumerable<IComponentRegistration> RegistrationsFor(
    Service service,
    Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor)
  {
    var swt = service as IServiceWithType;
    if(swt == null || !typeof(BaseClass).IsAssignableFrom(swt.ServiceType))
    {
      // It's not a request for the BaseClass type, so skip it.
      return Enumerable.Empty<IComponentRegistration>();
    }        
    var registration = new ComponentRegistration(
      Guid.NewGuid(),
      new DelegateActivator(swt.ServiceType, (c, p) =>
        {
          var myService = c.Resolve<IService>();
          ...
        }
        ...
  }
  ...
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Scala path-dependent types: type from reference to member val object seems to be different that type coming directly fro


Tag : scala , By : Joe
Date : March 29 2020, 07:55 AM
may help you . You would like the compiler to consider lexical.Scanner and mylexical.Scanner as equal, based on the fact that at runtime, the value of mylexical and lexical is always the same. This is a run-time property, and the type checker doesn't do any data-flow analysis (that would be way too slow to be practical).
So you need to help the type checker by telling it that the two values are always the same. You can do that by using a singleton type. A singleton type is a type that has exactly one value, and is written as (in this case) lexical.type.
val mylexical: lexical.type = lexical

Scala: Re-use generic resulting from path-dependent type in path-dependent context


Tag : scala , By : tangsty
Date : March 29 2020, 07:55 AM
I hope this helps . You can easily fix the issue by moving the abstract type member to a type parameter like this:
trait Simulator[CM[_]] {
  def useCM(v: CM[_])
}

case class CMH[CM[_]](cm: CM[_])

class SimIterator[S <: Simulator[CM], CM[_]](val sim: S, val cmhs: Seq[CMH[CM]]) {
  cmhs foreach { cmh => sim.useCM(cmh.cm) }
}
case class CMH[CM[_]](cm: CM[_])

trait Cake {
  type CM[_]

  trait Simulator {
    def useCM(v: CM[_])
  }

  class SimIterator[S <: Simulator](val sim: S, val cmhs: Seq[CMH[CM]]) {
    cmhs foreach { cmh => sim.useCM(cmh.cm) }
  }
}
trait Cake {
  type CM[_]

  trait Simulator {
    def useCM(v: CM[_])
  }
}

case class CMH[CM[_]](cm: CM[_])

class SimIteratorBuilder[C <: Cake](val cake: Cake) {
  class SimIterator(val sim: cake.Simulator, val cmhs: Seq[CMH[cake.CM]]) {
    cmhs foreach { cmh => sim.useCM(cmh.cm) }
  }
}

How can I require that a reference to a generic type can be compared for equality against the generic type?


Tag : rust , By : Pradeep Gowda
Date : January 12 2021, 08:33 AM
Any of those help You can either ignore the problem and compare a reference to a reference or non-reference to a non-reference:
if modulus == &T::one() {
// Or
if *modulus == T::one() {
impl<T> PowM for T
where
    T: Num + Two + ShrAssign<T> + Rem<T> + PartialOrd<T>,
    for <'a> &'a T: PartialEq<T>,
{
    // ...
}

Can C# (somehow) work out the type constraints itself when a generic type is passed as a generic type reference?


Tag : chash , By : jumpingmattflash
Date : March 29 2020, 07:55 AM
I hope this helps you . No this is not possible. Generic class level type parameters need to be defined if you wish to use them anywhere inside the class. You are trying to define T0 in terms of ClassA with type parameters that are not part of the ClassB definition so obviously it won't compile.
You could do something like:
ClassB<T0> where T0: ClassA<Int, Int, String> { }
ClassB<T0, T1, T2, T3> where T0: ClassA<T1, T2, T3> { }

Reference type dependency - declare Map.Entry to be dependent on generic types declared for TreeMap


Tag : java , By : Ryuken
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Generic event test method, preventing code duplication
  • How do I keep the ellipses in the center when the screen is resized
  • How to require a property using JsonSchema.NET?
  • C# XDocument Element/Elements returns null
  • Autofac keyed service with IEnumerable relationship type
  • Installing EntityFramework via NuGet manager
  • Always Check if there is Internet Connection Xamarin forms
  • WCF OneWay service slows down when aspNetCompatibilityEnabled is set to false
  • Can we use JsonRequestBehavior.AllowGet with [HttpPost] attribute?
  • How to customize the Setup wizard with custom forms in Visual Studio setup project
  • C# ASP.NET - Use method from another class to create labels
  • C# List IList or IEnumerable as argument
  • Parsing File with C# And Replace method
  • Losing special unicode characters in encryption (C#)
  • Getting stored procedure returned value instead of row affected
  • How can I construct HTML using NameValuePair in android?
  • Loading a pop up page in ASP.net through a js file
  • How to pass alert or notification message from controller to View?
  • C# to pause, turn on ssas server, backup cube.... how to?
  • How to execute DataTable.Select() for a column of custom class type for a particular element in that C#
  • how to connect mysql8.0 with C#
  • Passing incorrect values into MultiValueConverter by MultiBinding
  • Can i use IEnumerator as Update func?
  • How to convert API Json response to C# Array?
  • Blazor Textfield Oninput User Typing Delay
  • Performing both layout and render transform results in wrong output
  • uwp beforetextchanged cursor moving in front of text
  • How to keep duplicates from a string[] exclude words from a List and print them out
  • .Net Core Strings.Asc/Mid/Chr/Len missing even after importing Microsoft.VisualBasic
  • How to return to previous search page without being asked to Confirm Form Re-submission and keeping the results on ASP.N
  • How set a identity scaffolding item/page how initial page in asp.net MVC core?
  • LINQ isn't calling Dispose on my IEnumerator when using Union and Select, expected behavior or bug?
  • What is "ByteArray.uncompress()" in AS3 equivalent to in C#?
  • Getting a specific letter from a string variable for my simple guessing game for clues
  • Send an email with Outlook without a subject --- dialog box issue
  • passing List<MyModel> from my controller in the "WebInterfaceProject" to the processor method in "D
  • How to convert Word document created from template by OpenXML into MemoryStream?
  • How can I make a single slider that changes the color of an object?
  • Remap JSON parameter in c#
  • What is the difference between "this ref" and "ref this" when talking about C# 7.2 ref extension met
  • Convert OpenSSL encryption into native C#
  • Accessing Properties in Razor Pages
  • How to get SOAP element value
  • Projection after Group
  • C# error cannot convert sytem.text.regularexpressions.match to string
  • Issues with Save/Load System in a Text Based Adventure game made with ScriptableObjects in Unity
  • VS2019 MSBuild.exe - ASP .Net MVC project fails to publish when using PublishProfile, but works when using OutDir parame
  • Does <pages validateRequest="false" /> in Web.config still matter?
  • How to send new request to redirect URL with new access token
  • Attempt to invoke virtual method on a null object reference Xamarin LockScreen
  • "The attribute names could not be inferred from bind attribute 'bind-value'" exception in Blazor
  • How to fix ''System.ArgumentException" in c#?
  • C#. Ref returning delegate for ref extension method
  • Swashbuckle Swagger generate an actual guid
  • Trying to make thousands of database calls simultaneously - they stack instead of running concurently
  • run mstest from cmd using testcontainer
  • How to make M:N (many-to-many) relationship where both M and N are the same entities?
  • Consume COM DLL from multiple clients
  • Convert json string response representing UCHAR array to Byte array
  • Why does this LinqPad program produce different results on the second run?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com