コード例 #1
0
        /// <summary>
        /// Method executed after the code related to the attribute. The action is to check if the value is null
        /// </summary>
        public void Postprocess(MarshalByRefObject inst, IMessage msg, ref IMessage msgReturn)
        {
            // Extract Action
            ONAction lAction = inst as ONAction;

            // Shared Event Control
            if ((lAction != null) && (lAction.OnContext.InSharedContext == true))             // No-Principal Shared Event
            {
                return;
            }

            ReturnMessage lReturnMessage = msgReturn as ReturnMessage;
            IONType       lArgument      = lReturnMessage.Args[IndexArgument] as IONType;

            if (lArgument == null || lArgument.Value == null)
            {
                if (AllowsNull == false)
                {
                    throw new ONNotNullArgumentException(null, IdService, IdClass, IdArgument, ServiceName, ClassName, Name);
                }
            }
            else if ((Length > 0) && (lArgument.Value.ToString().Length > Length))
            {
                throw new ONMaxLenghtArgumentException(null, IdArgument, Name, Length.ToString());
            }
        }
コード例 #2
0
        public void Preprocess(MarshalByRefObject inst, IMessage msg)
        {
            if (mServiceCacheItem == null)
            {
                mServiceCacheItem = ONServiceCacheItem.Get("Action", ClassName, ServiceName);
            }

            IMethodCallMessage lMsg = msg as IMethodCallMessage;

            // Extract Action
            ONAction lAction = inst as ONAction;

            // Take the active Instance
            bool lFind = false;

            foreach (ONInstance lInstance in lAction.OnContext.TransactionStack)
            {
                if (((object)lInstance != null) && (lInstance == lAction.Instance))
                {
                    lAction.Instance = lInstance.GetFacet(lAction.Instance.ClassName);
                    lFind            = true;
                    break;
                }
            }
            if (!lFind)
            {
                foreach (ONInstance lInstance in lAction.OnContext.OperationStack)
                {
                    if (((object)lInstance != null) && (lInstance == lAction.Instance))
                    {
                        // Saving the old context of the This instance
                        lAction.Instance           = lInstance.GetFacet(lAction.Instance.ClassName);
                        mThisOnContext             = lAction.Instance.OnContext;
                        lAction.Instance.OnContext = lAction.OnContext;

                        break;
                    }
                }
            }

            // Push OID to Class Stack
            lAction.OnContext.TransactionStack.Push(lAction.Instance);
            mInStack = true;

            // Check State Changes
            if (lAction.OnContext.NeedsVerification)
            {
                mServiceCacheItem.InvoqueCheckState(lAction, lMsg.Args);
                lAction.OnContext.NeedsVerification = false;
            }

            // Check STD
            if (((object)lAction.Instance != null) && (!lFind))
            {
                mServiceCacheItem.InvoqueSTD(lAction, lMsg.Args);
            }

            // Check Precondition
            mServiceCacheItem.InvoquePrecondition(lAction, lMsg.Args);
        }
コード例 #3
0
 /// <summary>
 /// Marks the action class as modified to control what classes has been changed since the point of entry.
 /// The instance is putted if it's marked as modified
 /// </summary>
 /// <param name="filter">Action component that represents the class that is modified</param>
 public void AddModifiedClass(ONAction action)
 {
     if (action.Instance.Modified)
     {
         ModifiedClass.Remove(action.Instance.Oid);
         ModifiedClass.Add(action.Instance.Oid, action);
     }
 }
コード例 #4
0
        /// <summary>
        /// Puts the Oid in the modified class list to check integrity constraints and trigger conditions
        /// The Oid is added thought it's not marked as modified
        /// </summary>
        /// <param name="oid">Oid that represents the instance to be added</param>
        public void AddUnmodifiedClass(ONOid oid)
        {
            ModifiedClass.Remove(oid);
            ONAction lAction = GetComponent_Action(oid.ClassName, this);

            lAction.Instance = GetComponent_Instance(oid.ClassName, this);
            ModifiedClass.Add(oid, lAction);
        }
コード例 #5
0
        /// <summary>
        /// Represent the handdle for the exceptions
        /// </summary>
        /// <param name="inst">Instance</param>
        /// <param name="msg">Message</param>
        /// <param name="exception">Possible exception</param>
        public void Exceptionprocess(MarshalByRefObject inst, IMessage msg, Exception exception)
        {
            // Extract Action
            ONAction lAction = inst as ONAction;

            // Pop the OID from Class Stack
            if (mInStack)
            {
                lAction.OnContext.TransactionStack.Pop();
            }
        }
コード例 #6
0
        public void GetInitialValues(ONAction action, object[] arguments)
        {
            object[] lArgumentsActualValue = new object[arguments.Length];
            int      j = 0;

            while (j <= arguments.Length - 1)
            {
                if (arguments[j] is ONOid)
                {
                    lArgumentsActualValue[j] = (arguments[j] as ONOid).GetInstance(action.OnContext);
                }
                j++;
            }
            object lReturn = ONContext.InvoqueMethod(action, "CopyInstances", new object[] { lArgumentsActualValue });

            InstancesInitialValues = lReturn as Dictionary <ONOid, ONInstance>;
        }
コード例 #7
0
        /// <summary>
        /// Controls the triggers of the model object
        /// </summary>
        public void CheckTriggers()
        {
            foreach (KeyValuePair <ONOid, ONAction> lDictionaryEntry in ModifiedClass)
            {
                ONAction lAction = lDictionaryEntry.Value;

                ONActionCacheItem lActionCacheItem = ONActionCacheItem.Get("Action", lAction.ClassName);
                lActionCacheItem.InvoqueTriggers(lAction, new object[] { lDictionaryEntry.Key });

                ONInstance lInstance = (lDictionaryEntry.Key as ONOid).GetInstance(lAction.OnContext);
                foreach (ONInstance lNetInstance in lInstance.GetFacets())
                {
                    if (((object)lNetInstance != null) && (lNetInstance.ClassName != lAction.Instance.ClassName))
                    {
                        // Create action class
                        ONAction lNetAction = ONContext.GetComponent_Action(lNetInstance.ClassName, lNetInstance.OnContext);
                        lNetAction.Instance = lNetInstance;
                        ONActionCacheItem lNetActionCacheItem = ONActionCacheItem.Get("Action", lNetInstance.ClassName);
                        lNetActionCacheItem.InvoqueTriggers(lNetAction, new object[] { lNetInstance.Oid });
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// PostProcess method of the AOP
        /// </summary>
        /// <param name="inst">Instance</param>
        /// <param name="msg">Message</param>
        /// <param name="msgReturn">Return Message</param>
        public void Postprocess(MarshalByRefObject inst, IMessage msg, ref IMessage msgReturn)
        {
            IMethodCallMessage   lMsgIn  = msg as IMethodCallMessage;
            IMethodReturnMessage lMsgOut = msgReturn as IMethodReturnMessage;

            // Extract Action
            ONAction lAction = inst as ONAction;

            // Update Data
            if ((ServiceType == ServiceTypeEnumeration.New) || (ServiceType == ServiceTypeEnumeration.Destroy))
            {
                // Add ModifiedClass
                lAction.OnContext.AddModifiedClass(lAction);
            }
            else
            {
                if ((ServiceType == ServiceTypeEnumeration.Carrier) || (ServiceType == ServiceTypeEnumeration.Liberator))
                {
                    // Add ModifiedClass
                    lAction.OnContext.AddModifiedClass(lAction);
                }
                else if (lAction.Instance.Modified)
                {
                    // Update Instance
                    ONData lData = ONContext.GetComponent_Data(lAction.ClassName, lAction.OnContext);
                    lData.UpdateEdited(lAction.Instance);

                    // Add ModifiedClass
                    lAction.OnContext.AddModifiedClass(lAction);
                }
                lAction.Instance.ModifiedInTransaction = false;

                // Update Inheritance net data
                foreach (ONInstance lNetInstance in lAction.Instance.GetFacets())
                {
                    if (((object)lNetInstance != null) && (lNetInstance.ClassName != lAction.Instance.ClassName) && lNetInstance.Modified)
                    {
                        // Update inheritance net Instance
                        ONData lData = ONContext.GetComponent_Data(lNetInstance.ClassName, lNetInstance.OnContext);
                        lData.UpdateEdited(lNetInstance);

                        // Create action class
                        ONAction lNetAction = ONContext.GetComponent_Action(lNetInstance.ClassName, lNetInstance.OnContext);
                        lNetAction.Instance = lNetInstance;

                        // Add inheritance net ModifiedClass
                        lAction.OnContext.AddModifiedClass(lNetAction);
                    }

                    if ((object)lNetInstance != null)
                    {
                        lNetInstance.ModifiedInTransaction = false;
                    }
                }

                if (lAction.OnContext.ModifiedClass.ContainsKey(lAction.Instance.Oid))
                {
                    ONAction lNetAction = ONContext.GetComponent_Action(lAction.Instance.Root().ClassName, lAction.Instance.Root().OnContext);
                    lNetAction.Instance = lAction.Instance.Root();

                    lAction.OnContext.AddUnmodifiedClass(lNetAction);
                }
            }

            lAction.Instance.CleanDerivationCache();

            // Calculate OutboundArgumets
            object[] lArgs = lMsgOut.Args;
            mServiceCacheItem.InvoqueOutboundArguments(lAction, lArgs);

            // Pop the OID from Class Stack
            lAction.OnContext.TransactionStack.Pop();
            mInStack = false;

            // Restoing the old context of the This instance
            if (mThisOnContext != null)
            {
                lAction.Instance.OnContext = mThisOnContext;
            }

            msgReturn = new ReturnMessage(lMsgOut.ReturnValue, lArgs, lArgs.Length, lMsgOut.LogicalCallContext, lMsgIn);
            if (lAction.OnContext.TransactionStack.Count == 0)
            {
                // Check triggers
                lAction.OnContext.CheckTriggers();

                // Check integrity constraints
                lAction.OnContext.CheckIntegrityConstraints();
            }
        }
コード例 #9
0
        public void Preprocess(MarshalByRefObject inst, IMessage msg)
        {
            if (mServiceCacheItem == null)
            {
                mServiceCacheItem = ONServiceCacheItem.Get("Action", ClassName, ServiceName);
            }

            IMethodCallMessage lMsg = msg as IMethodCallMessage;
            int lIndex = 0;

            // Extract Action
            ONAction lAction = inst as ONAction;

            // Shared Event Control
            if (lAction.OnContext.InSharedContext == true) // No-Principal Shared Event
            {
                return;
            }
            lAction.OnContext.InSharedContext = true;
            mReflexivePrincipal = true;

            // Shared Event Arguments (in Shared Event order)
            HybridDictionary lReflexiveEventArguments     = new HybridDictionary(true);
            HybridDictionary lReflexiveEventArgumentsInfo = new HybridDictionary(true);
            int i = 0;

            foreach (ParameterInfo lArgument in lMsg.MethodBase.GetParameters())
            {
                ONSharedArgumentAttribute[] lReflexiveArgumentsInfo = lArgument.GetCustomAttributes(typeof(ONSharedArgumentAttribute), false) as ONSharedArgumentAttribute[];
                foreach (ONSharedArgumentAttribute lReflexiveArgumentInfo in lReflexiveArgumentsInfo)
                {
                    lReflexiveEventArgumentsInfo[lArgument.Name] = lReflexiveArgumentInfo;
                    break;
                }

                lReflexiveEventArguments[lArgument.Name] = lMsg.Args[i];
                i++;
            }

            // Shared Event Arguments for each Class (in Shared Event order)
            mServiceCacheItems = new List <ONServiceCacheItem>();
            foreach (DictionaryEntry lEntry in lReflexiveEventArgumentsInfo)
            {
                string lReflexiveArgumentName = lEntry.Key as String;
                ONSharedArgumentAttribute lReflexiveArgumentInfo = lEntry.Value as ONSharedArgumentAttribute;

                // Create Instance
                ONInstance lInstance = (lReflexiveEventArguments[lReflexiveArgumentName] as ONOid).GetInstance(lAction.OnContext);

                if (lInstance == null)
                {
                    throw new ONInstanceNotExistException(null, "", (lReflexiveEventArguments[lReflexiveArgumentName] as ONOid).ClassName);
                }

                // Create Action
                ONAction lReflexiveAction = ONContext.GetComponent_Action(lReflexiveArgumentInfo.ClassName, lAction.OnContext);
                //lSharedAction.Instance
                lReflexiveAction.Instance = lInstance;

                // Copy arguments
                MethodInfo lMethodInfo = ONContext.GetMethods(lReflexiveAction.GetType(), ToStringPartial());
                lIndex = 0;
                object[] lArguments = new object[lReflexiveEventArguments.Count];
                foreach (ParameterInfo lParameterInfo in lMethodInfo.GetParameters())
                {
                    // Normal Argument
                    lArguments[lIndex++] = lReflexiveEventArguments[lParameterInfo.Name];
                }
                mReflexiveClass = new KeyValuePair <ONAction, object[]>(lReflexiveAction, lArguments);
                mServiceCacheItems.Add(ONServiceCacheItem.Get("Action", lReflexiveArgumentInfo.ClassName, ServiceName + "_Partial"));
                object[] lObject = new object[mReflexiveClass.Value.Length];
                lObject[0] = mReflexiveClass.Value[1];
                lObject[1] = mReflexiveClass.Value[0];
                mReflexiveClass.Value[0] = lObject[0];
                mReflexiveClass.Value[1] = lObject[1];
            }

            // Take the active Instance
            lIndex = 0;
            bool lSharedFind = false;

            foreach (ONInstance lInstance in lAction.OnContext.TransactionStack)
            {
                if (lInstance == mReflexiveClass.Key.Instance)
                {
                    mReflexiveClass.Key.Instance = lInstance.GetFacet(mReflexiveClass.Key.Instance.ClassName);
                    lSharedFind = true;
                    break;
                }
            }
            if (!lSharedFind)
            {
                foreach (ONInstance lInstance in lAction.OnContext.OperationStack)
                {
                    if (lInstance == mReflexiveClass.Key.Instance)
                    {
                        mReflexiveClass.Key.Instance           = lInstance.GetFacet(mReflexiveClass.Key.Instance.ClassName);
                        mReflexiveClass.Key.Instance.OnContext = mReflexiveClass.Key.OnContext;

                        break;
                    }
                }
            }

            // Check State Changes
            if (lAction.OnContext.NeedsVerification)
            {
                mServiceCacheItem.InvoqueCheckState(lAction, lMsg.Args);
                lAction.OnContext.NeedsVerification = false;
            }


            // Push OID to Class Stack
            mReflexiveClass.Key.OnContext.TransactionStack.Push(mReflexiveClass.Key.Instance);

            // Check Shared STD
            if (!lSharedFind)
            {
                mServiceCacheItem.InvoqueSTD(mReflexiveClass.Key, mReflexiveClass.Value);
            }

            // Take the active Instance
            bool lFind = false;

            foreach (ONInstance lInstance in lAction.OnContext.TransactionStack)
            {
                if (lInstance == lAction.Instance)
                {
                    lAction.Instance = lInstance.GetFacet(lAction.Instance.ClassName);
                    lFind            = true;
                    break;
                }
            }
            if (!lFind)
            {
                foreach (ONInstance lInstance in lAction.OnContext.OperationStack)
                {
                    if (lInstance == lAction.Instance)
                    {
                        // Saving the old context of the This instance
                        lAction.Instance           = lInstance.GetFacet(lAction.Instance.ClassName);
                        mThisOnContext             = lAction.Instance.OnContext;
                        lAction.Instance.OnContext = lAction.OnContext;

                        break;
                    }
                }
            }

            // Push OID to Class Stack
            lAction.OnContext.TransactionStack.Push(lAction.Instance);
            mInStack = true;

            // Check STD
            if (!lFind)
            {
                mServiceCacheItem.InvoqueSTD(lAction, lMsg.Args);
            }

            // Check Shared Precondition
            lIndex = 0;
            mServiceCacheItem.InvoquePrecondition(mReflexiveClass.Key, mReflexiveClass.Value);

            // Check Precondition
            mServiceCacheItem.InvoquePrecondition(lAction, lMsg.Args);

            // Get Initial Values of the instances
            lAction.OnContext.GetInitialValues(lAction, lMsg.Args);

            // Throw Check Shared Partials
            lIndex = 0;
            if (mReflexiveClass.Key.Instance != lAction.Instance)
            {
                ONContext.InvoqueMethod(mReflexiveClass.Key, "_" + ServiceName + "_Partial", mReflexiveClass.Value);
            }
        }
コード例 #10
0
        public void Postprocess(MarshalByRefObject inst, IMessage msg, ref IMessage msgReturn)
        {
            IMethodCallMessage   lMsgIn  = msg as IMethodCallMessage;
            IMethodReturnMessage lMsgOut = msgReturn as IMethodReturnMessage;
            int lIndex = 0;

            // Extract Action
            ONAction lAction = inst as ONAction;

            // Shared Event Control
            if (mReflexivePrincipal == false) // No-Principal Shared Event
            {
                return;
            }
            lAction.OnContext.InSharedContext = false;

            if ((ServiceType != ServiceTypeEnumeration.Destroy) && (ServiceType != ServiceTypeEnumeration.New))
            {
                if (mReflexiveClass.Key.Instance.Modified)
                {
                    // Update Instance
                    ONData lData = ONContext.GetComponent_Data(mReflexiveClass.Key.ClassName, lAction.OnContext);
                    lData.UpdateEdited(mReflexiveClass.Key.Instance);

                    // Add ModifiedClass
                    lAction.OnContext.AddModifiedClass(mReflexiveClass.Key);
                }
                else if (ServiceType == ServiceTypeEnumeration.Insertion || ServiceType == ServiceTypeEnumeration.Deletion)
                {
                    // Add ModifiedClass
                    lAction.OnContext.AddUnmodifiedClass(mReflexiveClass.Key);
                }

                // Update Inheritance net data
                foreach (ONInstance lNetInstance in mReflexiveClass.Key.Instance.GetFacets())
                {
                    if (((object)lNetInstance != null) && (lNetInstance.ClassName != mReflexiveClass.Key.ClassName) && lNetInstance.Modified)
                    {
                        // Update inheritance net Instance
                        ONData lData = ONContext.GetComponent_Data(lNetInstance.ClassName, lNetInstance.OnContext);
                        lData.UpdateEdited(lNetInstance);

                        // Create action class
                        ONAction lNetAction = ONContext.GetComponent_Action(lNetInstance.ClassName, lNetInstance.OnContext);
                        lNetAction.Instance = lNetInstance;

                        // Add inheritance net ModifiedClass
                        lAction.OnContext.AddModifiedClass(mReflexiveClass.Key);
                    }
                }
            }

            if ((ServiceType != ServiceTypeEnumeration.Destroy) && (ServiceType != ServiceTypeEnumeration.New))
            {
                if (lAction.Instance.Modified)
                {
                    // Update Instance
                    ONData lData = ONContext.GetComponent_Data(lAction.ClassName, lAction.OnContext);
                    lData.UpdateEdited(lAction.Instance);

                    // Add ModifiedClass
                    lAction.OnContext.AddModifiedClass(lAction);
                }
                else
                {
                    // Add ModifiedClass
                    lAction.OnContext.AddUnmodifiedClass(lAction);
                }

                // Update Inheritance net data
                foreach (ONInstance lNetInstance in lAction.Instance.GetFacets())
                {
                    if (((object)lNetInstance != null) && (lNetInstance.ClassName != lAction.ClassName) && lNetInstance.Modified)
                    {
                        // Update inheritance net Instance
                        ONData lData = ONContext.GetComponent_Data(lNetInstance.ClassName, lNetInstance.OnContext);
                        lData.UpdateEdited(lNetInstance);

                        // Create action class
                        ONAction lNetAction = ONContext.GetComponent_Action(lNetInstance.ClassName, lNetInstance.OnContext);
                        lNetAction.Instance = lNetInstance;

                        // Add inheritance net ModifiedClass
                        lAction.OnContext.AddModifiedClass(lAction);
                    }
                }
            }

            // Calculate Shared OutboundArguments
            lIndex = 0;
            object[] lArgs = lMsgOut.Args;
            mServiceCacheItems[lIndex++].InvoqueOutboundArguments(mReflexiveClass.Key, mReflexiveClass.Value);

            // Copy outbound arguments (only not initialized)
            for (int i = lMsgOut.ArgCount - lMsgOut.OutArgCount; i < lMsgOut.ArgCount; i++)
            {
                if (new ONBool(mReflexiveClass.Value[i] as ONSimpleType != null) || mReflexiveClass.Value[i] as ONOid != null)
                {
                    lArgs[i] = mReflexiveClass.Value[i];
                }
            }

            // Pop the Shared OID from Class Stack
            lAction.OnContext.TransactionStack.Pop();

            // Calculate OutboundArgumets
            mServiceCacheItem.InvoqueOutboundArguments(lAction, lArgs);

            // Pop the OID from Class Stack
            lAction.OnContext.TransactionStack.Pop();
            mInStack = false;

            // Restoing the old context of the This instance
            if (mThisOnContext != null)
            {
                lAction.Instance.OnContext = mThisOnContext;
            }

            msgReturn = new ReturnMessage(lMsgOut.ReturnValue, lArgs, lArgs.Length, lMsgOut.LogicalCallContext, lMsgIn);
            if (lAction.OnContext.TransactionStack.Count == 0)
            {
                // Check triggers
                lAction.OnContext.CheckTriggers();

                // Check integrity constraints
                lAction.OnContext.CheckIntegrityConstraints();
            }

            lAction.OnContext.InstancesInitialValues.Clear();
        }
コード例 #11
0
        public void Preprocess(MarshalByRefObject inst, IMessage msg)
        {
            if (mServiceCacheItem == null)
            {
                mServiceCacheItem = ONServiceCacheItem.Get("Action", ClassName, ServiceName);
            }

            IMethodCallMessage lMsg = msg as IMethodCallMessage;
            int lIndex = 0;

            // Extract Action
            ONAction lAction = inst as ONAction;

            // Shared Event Control
            if (lAction.OnContext.InSharedContext == true)             // No-Principal Shared Event
            {
                return;
            }
            lAction.OnContext.InSharedContext = true;
            mSharedPrincipal = true;

            // Shared Event Arguments (in Shared Event order)
            HybridDictionary lSharedEventArguments     = new HybridDictionary(true);
            HybridDictionary lSharedEventArgumentsInfo = new HybridDictionary(true);
            int i = 0;

            foreach (ParameterInfo lArgument in lMsg.MethodBase.GetParameters())
            {
                ONSharedArgumentAttribute[] lSharedArgumentsInfo = lArgument.GetCustomAttributes(typeof(ONSharedArgumentAttribute), false) as ONSharedArgumentAttribute[];
                foreach (ONSharedArgumentAttribute lSharedArgumentInfo in lSharedArgumentsInfo)
                {
                    lSharedEventArgumentsInfo[lArgument.Name] = lSharedArgumentInfo;
                    break;
                }

                lSharedEventArguments[lArgument.Name] = lMsg.Args[i];
                i++;
            }

            // Shared Event Arguments for each Class (in Shared Event order)
            mServiceCacheItems = new List <ONServiceCacheItem>();
            foreach (DictionaryEntry lEntry in lSharedEventArgumentsInfo)
            {
                string lSharedArgumentName = lEntry.Key as String;
                ONSharedArgumentAttribute lSharedArgumentInfo = lEntry.Value as ONSharedArgumentAttribute;

                // Create Instance
                ONInstance lInstance = (lSharedEventArguments[lSharedArgumentName] as ONOid).GetInstance(lAction.OnContext);

                if (lInstance == null)
                {
                    throw new ONInstanceNotExistException(null, "", (lSharedEventArguments[lSharedArgumentName] as ONOid).ClassName);
                }

                // Create Action
                ONAction lSharedAction = ONContext.GetComponent_Action(lSharedArgumentInfo.ClassName, lAction.OnContext);
                lSharedAction.Instance = lInstance;

                // Reorder arguments
                lIndex = 0;
                object[] lArguments = new object[lSharedEventArguments.Count];
                foreach (MethodInfo lMethodInfo in ONContext.GetMethods(lSharedAction.GetType(), typeof(ONServiceAttribute), ToString(lSharedAction.ClassName)))
                {
                    foreach (ParameterInfo lParameterInfo in lMethodInfo.GetParameters())
                    {
                        if (lSharedEventArguments.Contains(lParameterInfo.Name))
                        {
                            // Normal Argument
                            lArguments[lIndex++] = lSharedEventArguments[lParameterInfo.Name];
                        }
                        else
                        {
                            ONSharedArgumentAttribute[] lSharedArgumentsInfo = lParameterInfo.GetCustomAttributes(typeof(ONSharedArgumentAttribute), false) as ONSharedArgumentAttribute[];
                            if (lSharedArgumentsInfo.Length == 0)
                            {
                                // Target Oid
                                lArguments[lIndex++] = lInstance.Oid;
                            }
                            else if (string.Compare(lSharedArgumentsInfo[0].ClassName, lAction.ClassName, true) == 0)
                            {
                                // Source Oid
                                lArguments[lIndex++] = lAction.Instance.Oid;
                            }
                            else
                            {
                                lArguments[lIndex++] = null;
                            }
                        }
                    }
                }

                mSharedClasses.Add(new KeyValuePair <ONAction, object[]>(lSharedAction, lArguments));
                mServiceCacheItems.Add(ONServiceCacheItem.Get("Action", lSharedArgumentInfo.ClassName, ServiceName));
            }

            // Check State Changes
            if (lAction.OnContext.NeedsVerification)
            {
                mServiceCacheItem.InvoqueCheckState(lAction, lMsg.Args);
                lAction.OnContext.NeedsVerification = false;
            }

            // Check Shared STD
            lIndex = 0;
            foreach (KeyValuePair <ONAction, object[]> lShared in mSharedClasses)
            {
                // Take the active Instance
                bool lSharedFind = false;
                foreach (ONInstance lInstance in lAction.OnContext.TransactionStack)
                {
                    if (lInstance == lShared.Key.Instance)
                    {
                        lShared.Key.Instance = lInstance.GetFacet(lShared.Key.Instance.ClassName);
                        lSharedFind          = true;
                        break;
                    }
                }
                if (!lSharedFind)
                {
                    foreach (ONInstance lInstance in lAction.OnContext.OperationStack)
                    {
                        if (lInstance == lShared.Key.Instance)
                        {
                            lShared.Key.Instance           = lInstance.GetFacet(lShared.Key.Instance.ClassName);
                            lShared.Key.Instance.OnContext = lShared.Key.OnContext;

                            break;
                        }
                    }
                }

                // Push OID to Class Stack
                lShared.Key.OnContext.TransactionStack.Push(lShared.Key.Instance);

                // Check STD
                if (!lSharedFind)
                {
                    mServiceCacheItems[lIndex++].InvoqueSTD(lShared.Key, lShared.Value);
                }
            }

            // Take the active Instance
            bool lFind = false;

            foreach (ONInstance lInstance in lAction.OnContext.TransactionStack)
            {
                if (lInstance == lAction.Instance)
                {
                    lAction.Instance = lInstance.GetFacet(lAction.Instance.ClassName);
                    lFind            = true;
                    break;
                }
            }
            if (!lFind)
            {
                foreach (ONInstance lInstance in lAction.OnContext.OperationStack)
                {
                    if (lInstance == lAction.Instance)
                    {
                        // Saving the old context of the This instance
                        lAction.Instance           = lInstance.GetFacet(lAction.Instance.ClassName);
                        mThisOnContext             = lAction.Instance.OnContext;
                        lAction.Instance.OnContext = lAction.OnContext;

                        break;
                    }
                }
            }


            // Push OID to Class Stack
            lAction.OnContext.TransactionStack.Push(lAction.Instance);
            mInStack = true;

            // Check STD
            if (!lFind)
            {
                mServiceCacheItem.InvoqueSTD(lAction, lMsg.Args);
            }

            // Check Shared Precondition
            lIndex = 0;
            foreach (KeyValuePair <ONAction, object[]> lShared in mSharedClasses)
            {
                mServiceCacheItems[lIndex++].InvoquePrecondition(lShared.Key, lShared.Value);
            }

            // Check Precondition
            mServiceCacheItem.InvoquePrecondition(lAction, lMsg.Args);

            // Get Initial Values of the instances
            lAction.OnContext.GetInitialValues(lAction, lMsg.Args);

            // Throw Check Shared Partials
            lIndex = 0;
            foreach (KeyValuePair <ONAction, object[]> lShared in mSharedClasses)
            {
                if ((string.Compare(lAction.ClassName, lShared.Key.ClassName, true) != 0) || (lAction.Instance != lShared.Key.Instance))
                {
                    mServiceCacheItems[lIndex++].InvoqueService(lShared.Key, lShared.Value);
                }
            }
        }
コード例 #12
0
        public void Postprocess(MarshalByRefObject inst, IMessage msg, ref IMessage msgReturn)
        {
            IMethodCallMessage   lMsgIn  = msg as IMethodCallMessage;
            IMethodReturnMessage lMsgOut = msgReturn as IMethodReturnMessage;

            // Extract Action
            ONAction lAction = inst as ONAction;

            if ((lAction.Instance != null) && (lAction.Instance.ModifiedInTransaction))
            {
                foreach (string lActiveFacet in lAction.Instance.LeafActiveFacets())
                {
                    ONInstance lInstanceToModify;
                    if (lActiveFacet == lAction.ClassName)
                    {
                        lInstanceToModify = lAction.Instance;
                    }
                    else
                    {
                        lInstanceToModify = lAction.Instance.GetFacet(lActiveFacet);
                    }
                    // Update Instance
                    if (lInstanceToModify.ModifiedInTransaction)
                    {
                        ONData lData = ONContext.GetComponent_Data(lInstanceToModify.ClassName, lInstanceToModify.OnContext);
                        lData.UpdateEdited(lInstanceToModify);
                    }
                }
                foreach (ONInstance lInstance in lAction.Instance.GetFacets())
                {
                    if (lInstance != null)
                    {
                        lInstance.ModifiedInTransaction = false;
                    }
                }

                lAction.Instance.ModifiedInTransaction = false;
            }

            // Calculate OutputArgumets
            object[] lArgs = lMsgOut.Args;
            mServiceCacheItem.InvoqueOutboundArguments(lAction, lArgs);

            // Pop the OID from Class Stack
            lAction.OnContext.TransactionStack.Pop();
            mInStack = false;

            // Restoing the old context of the This instance
            if (mThisOnContext != null)
            {
                lAction.Instance.OnContext = mThisOnContext;
            }

            msgReturn = new ReturnMessage(lMsgOut.ReturnValue, lArgs, lArgs.Length, lMsgOut.LogicalCallContext, lMsgIn);
            if (lAction.OnContext.TransactionStack.Count == 0)
            {
                // Check triggers
                lAction.OnContext.CheckTriggers();

                // Check integrity constraints
                lAction.OnContext.CheckIntegrityConstraints();
            }
        }