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;
            }
        }
Exemplo n.º 4
0
        internal void Add(string name, object property, bool skipValidations, bool onlyVisibleToPublicChildren)
        {
            if (!skipValidations)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw Microsoft.CoreWf.Internals.FxTrace.Exception.ArgumentNullOrEmpty("name");
                }

                if (property == null)
                {
                    throw Microsoft.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);
        }
Exemplo n.º 5
0
 internal RegistrationContext(ExecutionPropertyManager properties, IdSpace currentIdSpace)
 {
     _properties     = properties;
     _currentIdSpace = currentIdSpace;
 }
Exemplo n.º 6
0
 public IdSpace(IdSpace parent, int parentId)
 {
     this.Parent   = parent;
     this.ParentId = parentId;
 }