I have implemented subscription to my mobile application that was developed using Xamarin.iOS.
But if the user cancels their subscription, how can I get that event?
internal class BillingService : SKProductsRequestDelegate
{
private BillingService() {...}
public void CompleteTransaction(SKPaymentTransaction t) {...}
public void FailedTransaction(SKPaymentTransaction t) {...}
public void RestoreTransaction(SKPaymentTransaction t) {...}
internal class CustomPaymentObserver : SKPaymentTransactionObserver
{
public override voide RestoreCompletedTransactionsFailedWithError(...) {}
public override voide RestoreCompletedTransactionsFinished(...){}
public override void UpdatedTransactions(...){}
}
}
This is simple work flow of BillingService code.
Thanks.
Related
I'm attempting to create a graph extension to modify the behavior of one of the mobile scan screens, and I found in developer release notes for 2020 R1 the ability to use the [PXProtectedAccess] attribute to utilize protected members of a Graph from the extension, even though it does not directly inherit from it.
However, in order to utilize this, the Graph Extension class needs to be abstract and Acumatica no longer seems to recognize it when I do so. I'm sure that I am missing a crucial piece here but I can't figure out what it is based on documentation. EDIT: I was missing the [PXProtectedAccess] attribute on the class itself.
Now I am seeing something else when I try to actually call the abstract method. It throws Unable to cast object of type 'Wrapper.PX.Objects.IN.Cst_INScanIssueHost' to type 'INScanIssueHostDynamicInterface'. when I attempt to call any one of these protected members. I'm not sure what INScanIssueHostDynamicInterface refers to or how to resolve the type conflicts here.
Here is an excerpt of the code I'm using:
[PXProtectedAccess]
public abstract class INScanIssue_Extension : PXGraphExtension<INScanIssue, INScanIssueHost>
{
[PXProtectedAccess]
protected abstract void ReportError(string errorMsg, params object[] args);
public delegate void ProcessConfirmDelegate();
[PXOverride]
public virtual void ProcessConfirm(ProcessConfirmDelegate baseMethod)
{
ReportError("TEST");
}
}
I think you are on the right path. Your graphExtension should be abstract. Also please note that on your extension you use protected member of the graph extension by specifying the parameter of the attribute, as shown below:
public class MyGraph : PXGraph<MyGraph>
{
protected void Bar() { }
}
public class MyExt : PXGraphExtension<MyGraph>
{
protected void Foo() { }
}
[PXProtectedAccess]
public abstract class MySecondLevelExt : PXGraphExtension<MyExt, MyGraph>
{
[PXProtectedAccess]
protected abstract void Bar();
[PXProtectedAccess(typeof(MyExt))]
protected abstract void Foo();
}
So in your case, I think you can try to add that parameter to the ProctectedAccess attribute for those members that from INScanIssue(or overriden there ):
namespace PX.Objects.IN
{
[PXProtectedAccess]
public abstract class INScanIssue_Extension : PXGraphExtension<INScanIssue,
INScanIssueHost>
{
public static bool IsActive()
{
return true;
}
# region Protected Access
*[PXProtectedAccess(typeof(INScanIssue))]*
protected abstract void ClearHeaderInfo(bool redirect = false);
[PXProtectedAccess]
protected abstract void SetScanState(string state, string message = null, params object[] args);
[PXProtectedAccess(typeof(INScanIssue))]
protected abstract bool PromptLocationForEveryLine { get; }
........................................
Use the abstract extension only to access the protected members, then add a second level extension, that calls the exposed members from your first level extension. And I don't think you need to apply the attribute on the extension.
public abstract class INScanIssueProtectedAccessExt : PXGraphExtension<INScanIssue, INScanIssueHost>
{
[PXProtectedAccess]
public abstract void ReportError(string errorMsg, params object[] args);
}
public class INScanIssue_Extension : PXGraphExtension<INScanIssueProtectedAccessExt, INScanIssue, INScanIssueHost>
{
public delegate void ProcessConfirmDelegate();
[PXOverride]
public virtual void ProcessConfirm(ProcessConfirmDelegate baseMethod)
{
this.Base2.ReportError("TEST");
}
}
In guice, Is there a way to select particular implementation for binding based on some external parameter
Eg:
public interface Service {
void sendMessage()
}
class EmailService implements Service {
public EmailService() { }
#Override
void sendMessage() {
println "Sending email..."
}
}
class SMSService implements Service {
public EmailService() { }
#Override
void sendMessage() {
println "Sending sms..."
}
}
class Client {
private Service service
#Inject
Client(Service service) {
this.service = service
}
public void send() {
service.sendMessage()
}
}
public class ServiceProvider implements Provider<Service> {
Service get() {
return new SMSService() //Select implementation here?
}
}
public class MyModule extends AbstractModule {
#Override
protected void configure() {
bind(Service.class).toProvider(ServiceProvider.class).in(Scopes.SINGLETON)
}
}
public static void main(String...args) {
Injector injector = Guice.createInjector(new MyModule())
Client c = injector.getInstance(Client.class)
c.send()
}
In the above example, I'm forced to select which provider to use in Provider get() method. If I want to make this more dynamic, say for example, based on user preference, is there a way to wait select the provider at runtime and have guice inject it?
For these kind of problems, guice offers the MapBinder:
public class SnacksModule extends AbstractModule {
protected void configure() {
MapBinder<String, Snack> mapbinder
= MapBinder.newMapBinder(binder(), String.class, Snack.class);
mapbinder.addBinding("twix").toInstance(new Twix());
mapbinder.addBinding("snickers").toProvider(SnickersProvider.class);
mapbinder.addBinding("skittles").to(Skittles.class);
}
}
With this binding, a Map can now be injected:
class SnackMachine {
#Inject
public SnackMachine(Map<String, Snack> snacks) { ... }
}
You can define all your services in advance, and than pick the concrete instance (or provider) from the map byconfigured value.
I have a public method in project and here is that method.
public bool SaveDocument(string customer)
{
//some codes
}
I have another project in same solution with this method
private void buttonSaveReport_Click(object sender, EventArgs e)
{
}
button click event I need to pass 3 parameters (name,title,isbn) to SaveDocument() method and override it.I am having a difficulty with implementing this.Trying with this and can anyone help me out to complete it.
public class Ext : DocumentManager.DocumentManager
{
public override void SaveDocument()
{
base.SaveDocumentCustomer(customer);
}
}
Thanks
I am trying to re-use the service registrations in an assembly that I use through a few services in my solution. I follow the example listed from the NServiceBus website to implement the solution. When following that, unless I add the IWantCustomInitialization interface, my Init method (and IoC container implementation) appears not to function. When I have that interface implemented, I get exceptions (listed in SO questions here and here). I can't seem to get it to work that there are no exceptions AND the dependencies in my MessageHandler are being populated properly. Here is my current EndpointConfig implementation.
[EndpointSLA("00:00:30")]
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, UsingTransport<Msmq>, INeedInitialization {
public void Init() {
Configure.With().ObjectBuilderAdapter();
}
}
public class ObjectBuilderAdapter : IContainer {
readonly IDependencyInjector injector;
public ObjectBuilderAdapter(IDependencyInjectionBuilder dependencyInjectionBuilder) {
injector = dependencyInjectionBuilder.Create(); //This method does all the common service registrations that I am trying to re-use
//injector.RegisterType<ExtractIncomingPrincipal, PrincipalExtractor>();
}
public void Dispose() {
injector.Dispose();
}
public object Build(Type typeToBuild) {
return injector.Resolve(typeToBuild);
}
public IContainer BuildChildContainer() {
return new ObjectBuilderAdapter(new DependencyInjectorBuilder());
}
public IEnumerable<object> BuildAll(Type typeToBuild) {
return injector.ResolveAll(typeToBuild);
}
public void Configure(Type component, DependencyLifecycle dependencyLifecycle) {
injector.RegisterType(component);
}
public void Configure<T>(Func<T> component, DependencyLifecycle dependencyLifecycle) {
injector.RegisterType(component);
}
public void ConfigureProperty(Type component, string property, object value) {
if (injector is AutofacDependencyInjector) {
((AutofacDependencyInjector)injector).ConfigureProperty(component, property, value);
} else {
Debug.WriteLine("Configuring {0} for property {1} but we don't handle this scenario.", component.Name, property);
}
}
public void RegisterSingleton(Type lookupType, object instance) {
injector.RegisterInstance(lookupType, instance);
}
public bool HasComponent(Type componentType) {
return injector.IsRegistered(componentType);
}
public void Release(object instance) { }
}
public static class Extensions {
public static Configure ObjectBuilderAdapter(this Configure config) {
ConfigureCommon.With(config, new ObjectBuilderAdapter(new DependencyInjectorBuilder()));
return config;
}
}
Note: When I use the INeedInitialization interface, I get the ComponentNotRegisteredException when it's looking for IStartableBus.
When you are trying to swap the built in container, then you need to implement IWantCustomInitialization in the same class that implements IConfigureThisEndpoint.
You can use your own container and register all your types in there and tell NSB to use that container.
For example:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
public void Init()
{
var container = new ContainerBuilder().Build();
Configure.With()
.AutofacBuilder(container);
}
}
I'm trying to implement an OnMethodBoundary aspect on an abstract method in an abstract class so that all types that inherit from this class will automatically have the aspect applied. There are no compilation errors or warnings, but the OnEntry method doesn't fire. Note: If I apply the aspect to a non-abstract method, everything works fine
here's the aspect example:
[Serializable]
[MulticastAttributeUsage(MulticastTargets.Method, Inheritance = MulticastInheritance.Multicast)]
public sealed class DoSomethingAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionArgs args)
{
//Do work
}
}
// here's the abstract class
public abstract class Job
{
//...
[DoSomething]
public abstract void Run();
}
Updated answer: it doesn't matter where anything is, as long as both projects have Postsharp referenced then you're good to go.
It works just fine. Which version of PostSharp are you using?
class Program
{
static void Main(string[] args)
{
Job1 j = new Job1();
j.Run();
Console.ReadKey();
}
}
[Serializable]
[MulticastAttributeUsage(MulticastTargets.Method, Inheritance = MulticastInheritance.Multicast)]
public sealed class DoSomethingAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionArgs args)
{
Console.WriteLine("OnEntry");
}
}
public abstract class Job
{
//...
[DoSomething]
public abstract void Run();
}
public class Job1 : Job
{
public override void Run()
{
Console.WriteLine("Run method");
}
}
Results:
OnEntry
Run method