Exemplo n.º 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)
            {
                int value;
                offset += Decode(idBytes, offset, out 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);
        }
Exemplo n.º 2
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;
            }

            _compressedId = new byte[bufferSize];

            int offset = 0;

            while (ids.Count > 0)
            {
                offset += Encode(ids.Pop(), _compressedId, offset);
            }
        }
Exemplo n.º 3
0
        internal ExecutionProperties(ActivityContext currentContext, ActivityInstance scope, ExecutionPropertyManager properties)
        {
            _context    = currentContext;
            _scope      = scope;
            _properties = properties;

            if (_context != null)
            {
                _currentIdSpace = _context.Activity.MemberOf;
            }
        }
        internal ExecutionProperties(ActivityContext currentContext, ActivityInstance scope, ExecutionPropertyManager properties)
        {
            this.context    = currentContext;
            this.scope      = scope;
            this.properties = properties;

            if (this.context != null)
            {
                this.currentIdSpace = this.context.Activity.MemberOf;
            }
        }
Exemplo n.º 5
0
        internal void Add(string name, object property, bool skipValidations, bool onlyVisibleToPublicChildren)
        {
            if (!skipValidations)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw CoreWf.Internals.FxTrace.Exception.ArgumentNullOrEmpty("name");
                }

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

                ThrowIfActivityExecutionContextDisposed();
                ThrowIfChildrenAreExecuting();
            }

            if (_properties != null)
            {
                _properties.ThrowIfAlreadyDefined(name, _scope);
            }

            IPropertyRegistrationCallback registrationCallback = property as IPropertyRegistrationCallback;

            if (registrationCallback != null)
            {
                registrationCallback.Register(new RegistrationContext(_properties, _currentIdSpace));
            }

            if (_properties == null)
            {
                _properties = new ExecutionPropertyManager(_scope);
            }
            else if (!_properties.IsOwner(_scope))
            {
                _properties = new ExecutionPropertyManager(_scope, _properties);
            }

            IdSpace visibility = null;

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

            _properties.Add(name, property, visibility);
        }
        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);
        }
Exemplo n.º 7
0
 internal RegistrationContext(ExecutionPropertyManager properties, IdSpace currentIdSpace)
 {
     this.properties     = properties;
     this.currentIdSpace = currentIdSpace;
 }
Exemplo n.º 8
0
 public IdSpace(IdSpace parent, int parentId)
 {
     this.Parent   = parent;
     this.ParentId = parentId;
 }