public override object Clone()
        {
            ActionBranchParameter dtp = (ActionBranchParameter)base.Clone();

            dtp._actionBranch = _actionBranch;
            return(dtp);
        }
 public ActionBranchParameterPointer(ActionBranchParameter p, ClassPointer root)
 {
     _parameter = p;
     if (p != null)
     {
         _parameterType = p.ObjectType;
     }
     _root         = root;
     ParameterName = p.Name;
     ParameterId   = p.ParameterID;
 }
        public override bool IsSameObjectRef(IObjectIdentity objectPointer)
        {
            ActionBranchParameter abp = objectPointer as ActionBranchParameter;

            if (abp != null)
            {
                if (abp.ParameterID == this.ParameterID)
                {
                    if (_actionBranch.BranchId == abp.ActionBranch.BranchId)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public void OnDeserialize(object context)
        {
            string err;

            _root = context as ClassPointer;
            if (_root == null)
            {
                if (context == null)
                {
                    err = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}.OnDeserialize(object context): context is null. MethodId:{1},BranchId:{2},ParameterId:{3},ParameterName:{4}", this.GetType().Name, MethodId, BranchId, ParameterId, ParameterName);
                }
                else
                {
                    err = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}.OnDeserialize(object context): context {1} is not a ClassPointer. MethodId:{2},BranchId:{3},ParameterId:{4},ParameterName:{5}", this.GetType().Name, context.GetType().Name, MethodId, BranchId, ParameterId, ParameterName);
                }
                MathNode.LogError(err);
            }
            else
            {
                MethodClass mc = _root.GetCustomMethodById(MethodId);
                if (mc == null)
                {
                    if (_root.ActionInstances != null)
                    {
                        IAction a;
                        if (_root.ActionInstances.TryGetValue(MethodId, out a))
                        {
                            MethodActionForeach ma = a as MethodActionForeach;
                            if (ma != null)
                            {
                                mc = ma;
                            }
                        }
                    }
                }
                if (mc == null)
                {
                    err = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}.OnDeserialize(object context): method [{1},{2}] is not found in ClassPointer.  MethodId:{2},BranchId:{3},ParameterId:{4},ParameterName:{5}", this.GetType().Name, _root.ClassId, MethodId, BranchId, ParameterId, ParameterName);
                    MathNode.LogError(err);
                }
                if (mc != null)
                {
                    ActionBranch ab = mc.SearchBranchById(BranchId);
                    if (ab == null)
                    {
                        //throw new DesignerException("{0}.OnDeserialize(object context): Action Branch [{1}] not found in method [{2},{3}][{4}]", this.GetType().Name, BranchId, _root.ClassId, MethodId, mc.Name);
                        mc.AddDeserializer(this);
                    }
                    else
                    {
                        AB_SubMethodAction sma = ab as AB_SubMethodAction;
                        if (sma != null)
                        {
                            _parameter = sma.GetParameterById(ParameterId);
                        }
                        if (_parameter == null)
                        {
                            _parameter = ab.GetActionBranchParameterByName(ParameterName);
                            if (_parameter != null)
                            {
                                _parameter.ParameterID = ParameterId;
                            }
                        }
                    }
                }
            }
        }