public InvocationInfoImpl(MethodInfo compositeMethod, AbstractFragmentMethodModel fragmentMethodModel) { ArgumentValidator.ValidateNotNull("Composite method", compositeMethod); this._compositeMethod = compositeMethod; this._fragmentMethodModel = fragmentMethodModel; }
public void ActivateIfNeeded(Int32 compositeMethodIndex, MethodGenericArgumentsInfo gArgsInfo, AbstractFragmentMethodModel nextFragment) { if ((Int32)ActivatingAllowed.ALLOWED == this._activatingAllowed) { ApplicationSkeleton.PerformActivation(ref this._activationState, ref this._activationInProgress, this._passivationInProgress, ApplicationSkeleton.WAIT_TIME, false, () => { CompositePropertySPI idProp = (CompositePropertySPI)this.State.Properties[IDENTITY_QNAME]; if (Convert.ToBoolean(this._needToSetIdentity)) { idProp.PropertyValueAsObject = this._serviceID; Interlocked.Exchange(ref this._needToSetIdentity, Convert.ToInt32(false)); } // Disable prototype this.DisablePrototype(compositeMethodIndex, gArgsInfo, nextFragment); if (this._activationAction != null) { var compositeMethod = this.GetCompositeMethodInfo(compositeMethodIndex, gArgsInfo); if (compositeMethod != null) { this.InvocationInfo = new InvocationInfoImpl(compositeMethod, nextFragment); } try { this._activationAction(); } finally { if (compositeMethod != null) { this.InvocationInfo = null; } } } ((ServiceCompositeModelImmutable)this.ModelInfo.Model).InvokeAfterActivation(this); }); } }
protected virtual void ValidateFragmentMethod(CompositeValidationResult result, CompositeModel compositeModel, CompositeMethodModel compositeMethod, AbstractFragmentMethodModel methodModel) { if (compositeMethod == null) { result.InternalValidationErrors.Add(ValidationErrorFactory.NewInternalError("Composite method model may not be null.", compositeModel)); } if (methodModel != null) { var declType = methodModel.NativeInfo.DeclaringType; if (!declType #if WINDOWS_PHONE_APP .GetTypeInfo() #endif .IsClass) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The declaring type of fragment method " + methodModel.NativeInfo + " must be a class, however " + declType + " is not a class.", compositeModel, compositeMethod)); } if (!methodModel.IsGeneric && (!methodModel.NativeInfo.IsVirtual || methodModel.NativeInfo.IsFinal)) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The method " + methodModel.NativeInfo + " in " + declType + " is not virtual, however, all composite methods must be virtual.", compositeModel, methodModel)); } if (declType #if WINDOWS_PHONE_APP .GetTypeInfo() #endif .IsSealed) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The type " + declType + " is sealed, however, all fragment types must be non-sealed.", compositeModel, methodModel)); } //if ( !declType.IsPublic && !declType.IsNestedPublic ) //{ // String msg = null; // if ( methodModel.NativeInfo.IsAssembly || methodModel.NativeInfo.IsFamilyOrAssembly ) // { // if ( !declType.Assembly.GetCustomAttributes( true ).OfType<InternalsVisibleToAttribute>().Any( attr => Qi4CSGeneratedAssemblyAttribute.ASSEMBLY_NAME.Equals( attr.AssemblyName ) ) ) // { // msg = "The type " + declType + " is marked as internal, however, the " + typeof( InternalsVisibleToAttribute ) + " with argument " + typeof( Qi4CSGeneratedAssemblyAttribute ) + ".ASSEMBLY_NAME is not applied to the assembly"; // } // } // else // { // msg = "The type " + declType + " is not visible to the generated assembly."; // } // if ( msg != null ) // { // result.AddStructureError( new StructureValidationErrorImpl( compositeModel, methodModel, msg ) ); // } //} var genName = Qi4CSGeneratedAssemblyAttribute.GetGeneratedAssemblyName(declType.GetAssembly()); if (!IsTypeVisible(declType, genName)) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The type " + declType + " is not visible. Consider either making it public, or internal with combination of applying " + typeof(InternalsVisibleToAttribute) + " with argument " + typeof(Qi4CSGeneratedAssemblyAttribute) + ".ASSEMBLY_NAME to the assembly.", compositeModel, methodModel)); } } }
private void CheckCompositeState(Int32 compositeMethodIndex, MethodGenericArgumentsInfo gArgsInfo, AbstractFragmentMethodModel nextMethod) { if (this._checkStateFunc != null) { var violations = new Dictionary <QualifiedName, IList <ConstraintViolationInfo> >(); this._checkStateFunc(violations); if (violations.Any()) { throw new CompositeInstantiationException(violations); } } }
private void RunPrototypeAction(Int32 compositeMethodIndex, MethodGenericArgumentsInfo gArgsInfo, AbstractFragmentMethodModel nextMethod) { if (this._prototypeAction != null) { var compositeMethod = this.GetCompositeMethodInfo(compositeMethodIndex, gArgsInfo); if (compositeMethod != null) { this._invocationInfos.Value.Value.Push(new InvocationInfoImpl(compositeMethod, nextMethod)); } try { this._prototypeAction(); } finally { if (compositeMethod != null) { this._invocationInfos.Value.Value.Pop(); } } } }
public void DisablePrototype(Int32 compositeMethodIndex, MethodGenericArgumentsInfo gArgsInfo, AbstractFragmentMethodModel nextMethod) { ApplicationSkeleton.ThreadsafeStateTransition(ref this._isPrototype, (Int32)PrototypeState.PROTOTYPE, (Int32)PrototypeState.IN_TRANSITION_RUNNING_ACTION, (Int32)PrototypeState.NOT_PROTOTYPE, true, ref this._isPrototypeTransitionInProgress, ApplicationSkeleton.WAIT_TIME, () => { this.RunPrototypeAction(compositeMethodIndex, gArgsInfo, nextMethod); Interlocked.Exchange(ref this._isPrototype, (Int32)PrototypeState.IN_TRANSITION_CHECKING_STATE); this.CheckCompositeState(compositeMethodIndex, gArgsInfo, nextMethod); ((CompositeModelImmutable)this.ModelInfo.Model).InvokeCompositeInstantiated(this); }); }
public AbstractFragmentMethodModelMutable(AbstractFragmentMethodModelState state, AbstractFragmentMethodModel immutable) : base(state, immutable) { this._state = state; }