Example #1
0
        public static bool TryGetElementFromRoot(Activity root, byte[] idBytes, out Activity targetElement)
        {
            Fx.Assert(root.MemberOf != null, "We need to have our IdSpaces set up for this to work.");

            Activity currentActivity = root;
            IdSpace  currentIdSpace  = root.MemberOf;

            int offset = 0;

            while (offset < idBytes.Length)
            {
                offset += Decode(idBytes, offset, out int value);

                if (currentIdSpace == null)
                {
                    targetElement = null;
                    return(false);
                }

                currentActivity = currentIdSpace[value];

                if (currentActivity == null)
                {
                    targetElement = null;
                    return(false);
                }

                currentIdSpace = currentActivity.ParentOf;
            }

            targetElement = currentActivity;
            return(true);
        }
Example #2
0
        public static bool TryGetElementFromRoot(Activity root, byte[] idBytes, out Activity targetElement)
        {
            Activity activity = root;
            IdSpace  memberOf = root.MemberOf;
            int      offset   = 0;

            while (offset < idBytes.Length)
            {
                int num2;
                offset += Decode(idBytes, offset, out num2);
                if (memberOf == null)
                {
                    targetElement = null;
                    return(false);
                }
                activity = memberOf[num2];
                if (activity == null)
                {
                    targetElement = null;
                    return(false);
                }
                memberOf = activity.ParentOf;
            }
            targetElement = activity;
            return(true);
        }
Example #3
0
        public QualifiedId(Activity element)
        {
            int bufferSize = 0;

            Stack <int> ids = new Stack <int>();

            int id = element.InternalId;

            bufferSize += GetEncodedSize(id);
            ids.Push(id);

            IdSpace space = element.MemberOf;

            while (space != null && space.ParentId != 0)
            {
                bufferSize += GetEncodedSize(space.ParentId);
                ids.Push(space.ParentId);

                space = space.Parent;
            }

            this.compressedId = new byte[bufferSize];

            int offset = 0;

            while (ids.Count > 0)
            {
                offset += Encode(ids.Pop(), this.compressedId, offset);
            }
        }
Example #4
0
 internal ExecutionProperties(ActivityContext currentContext, System.Activities.ActivityInstance scope, ExecutionPropertyManager properties)
 {
     this.context    = currentContext;
     this.scope      = scope;
     this.properties = properties;
     if (this.context != null)
     {
         this.currentIdSpace = this.context.Activity.MemberOf;
     }
 }
        internal void Add(string name, object property, bool skipValidations, bool onlyVisibleToPublicChildren)
        {
            if (!skipValidations)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw FxTrace.Exception.ArgumentNullOrEmpty("name");
                }

                if (property == null)
                {
                    throw FxTrace.Exception.ArgumentNull("property");
                }

                ThrowIfActivityExecutionContextDisposed();
                ThrowIfChildrenAreExecuting();
            }

            if (this.properties != null)
            {
                this.properties.ThrowIfAlreadyDefined(name, this.scope);
            }

            IPropertyRegistrationCallback registrationCallback = property as IPropertyRegistrationCallback;

            if (registrationCallback != null)
            {
                registrationCallback.Register(new RegistrationContext(this.properties, this.currentIdSpace));
            }

            if (this.properties == null)
            {
                this.properties = new ExecutionPropertyManager(this.scope);
            }
            else if (!this.properties.IsOwner(this.scope))
            {
                //
                this.properties = new ExecutionPropertyManager(this.scope, this.properties);
            }

            IdSpace visibility = null;

            if (onlyVisibleToPublicChildren)
            {
                Fx.Assert(this.currentIdSpace != null, "We should never call OnlyVisibleToPublicChildren when we don't have a currentIdSpace");
                visibility = this.currentIdSpace;
            }

            this.properties.Add(name, property, visibility);
        }
Example #6
0
        internal void Add(string name, object property, bool skipValidations, bool onlyVisibleToPublicChildren)
        {
            if (!skipValidations)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw FxTrace.Exception.ArgumentNullOrEmpty(nameof(name));
                }

                if (property == null)
                {
                    throw FxTrace.Exception.ArgumentNull(nameof(property));
                }

                ThrowIfActivityExecutionContextDisposed();
                ThrowIfChildrenAreExecuting();
            }

            if (this.properties != null)
            {
                this.properties.ThrowIfAlreadyDefined(name, this.scope);
            }


            if (property is IPropertyRegistrationCallback registrationCallback)
            {
                registrationCallback.Register(new RegistrationContext(this.properties, this.currentIdSpace));
            }

            if (this.properties == null)
            {
                this.properties = new ExecutionPropertyManager(this.scope);
            }
            else if (!this.properties.IsOwner(this.scope))
            {
                // TODO, 51474, Thread properties are broken when the this.scope is not the current activity.  This will only happen for NoPersistProperty right now so it doesn't matter.
                this.properties = new ExecutionPropertyManager(this.scope, this.properties);
            }

            IdSpace visibility = null;

            if (onlyVisibleToPublicChildren)
            {
                Fx.Assert(this.currentIdSpace != null, "We should never call OnlyVisibleToPublicChildren when we don't have a currentIdSpace");
                visibility = this.currentIdSpace;
            }

            this.properties.Add(name, property, visibility);
        }
Example #7
0
        public QualifiedId(Activity element)
        {
            int         num        = 0;
            Stack <int> stack      = new Stack <int>();
            int         internalId = element.InternalId;

            num += GetEncodedSize(internalId);
            stack.Push(internalId);
            for (IdSpace space = element.MemberOf; (space != null) && (space.ParentId != 0); space = space.Parent)
            {
                num += GetEncodedSize(space.ParentId);
                stack.Push(space.ParentId);
            }
            this.compressedId = new byte[num];
            for (int i = 0; stack.Count > 0; i += Encode(stack.Pop(), this.compressedId, i))
            {
            }
        }
 public IdSpace(IdSpace parent, int parentId)
 {
     this.Parent   = parent;
     this.ParentId = parentId;
 }
 internal RegistrationContext(ExecutionPropertyManager properties, IdSpace currentIdSpace)
 {
     this.properties     = properties;
     this.currentIdSpace = currentIdSpace;
 }
 public IdSpace(IdSpace parent, int parentId)
 {
     this.Parent = parent;
     this.ParentId = parentId;
 }
 internal RegistrationContext(ExecutionPropertyManager properties, IdSpace currentIdSpace)
 {
     this.properties = properties;
     this.currentIdSpace = currentIdSpace;
 }