/// <summary>
        /// This will add a attachment point until the system flushes.
        /// This can be used by element provider implementors to attach trees to their exising trees.
        /// </summary>
        /// <param name="treeId"></param>
        /// <param name="entityToken"></param>
        /// <param name="position"></param>
        public bool AddCustomAttachmentPoint(string treeId, EntityToken entityToken, ElementAttachingProviderPosition position = ElementAttachingProviderPosition.Top)
        {
            Tree tree = GetTree(treeId);

            if (tree == null)
            {
                return(false);
            }

            var customAttachmentPoint = new CustomAttachmentPoint(entityToken, position);

            tree.AttachmentPoints.Add(customAttachmentPoint);

            List <IAttachmentPoint> attachmentPoints;

            using (_resourceLocker.Locker)
            {
                if (_resourceLocker.Resources.PersistentAttachmentPoints.TryGetValue(treeId, out attachmentPoints) == false)
                {
                    attachmentPoints = new List <IAttachmentPoint>();
                    _resourceLocker.Resources.PersistentAttachmentPoints.Add(treeId, attachmentPoints);
                }
            }

            attachmentPoints.Add(customAttachmentPoint);

            return(true);
        }
        private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;

            object keyValue = dataEntityToken.DataSourceId.GetKeyValue();

            string treeId             = this.GetBinding <string>("SelectedTreeId");
            string serializedPosition = this.GetBinding <string>("SelectedPosition");

            ElementAttachingProviderPosition position = (ElementAttachingProviderPosition)Enum.Parse(typeof(ElementAttachingProviderPosition), serializedPosition);

            TreeFacade.AddPersistedAttachmentPoint(treeId, dataEntityToken.InterfaceType, keyValue, position);

            this.RefreshCurrentEntityToken();
        }
Example #3
0
        /// <summary>
        /// This will add a attachment point until the system flushes.
        /// This can be used by element provider implementors to attach trees to their exising trees.
        /// </summary>
        /// <param name="treeId"></param>
        /// <param name="entityToken"></param>
        /// <param name="position"></param>
        public static bool AddCustomAttachmentPoint(string treeId, EntityToken entityToken, ElementAttachingProviderPosition position = ElementAttachingProviderPosition.Top)
        {
            EnsureInitialized();

            return _implementation.AddCustomAttachmentPoint(treeId, entityToken, position);
        }
Example #4
0
        /// <summary>
        /// Adds a attachment point that is persisted by the system and is loaded on every restart
        /// </summary>
        /// <param name="treeId"></param>
        /// <param name="interfaceType"></param>
        /// <param name="keyValue"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        public static bool AddPersistedAttachmentPoint(string treeId, Type interfaceType, object keyValue, ElementAttachingProviderPosition position = ElementAttachingProviderPosition.Top)
        {
            EnsureInitialized();

            return _implementation.AddPersistedAttachmentPoint(treeId, interfaceType, keyValue, position);
        }
        public bool AddPersistedAttachmentPoint(string treeId, Type interfaceType, object keyValue, ElementAttachingProviderPosition position = ElementAttachingProviderPosition.Top)
        {
            var attachmentPoint = DataFacade.BuildNew <IDataItemTreeAttachmentPoint>();

            attachmentPoint.Id            = Guid.NewGuid();
            attachmentPoint.TreeId        = treeId;
            attachmentPoint.Position      = position.ToString();
            attachmentPoint.InterfaceType = TypeManager.SerializeType(interfaceType);
            attachmentPoint.KeyValue      = ValueTypeConverter.Convert <string>(keyValue);

            bool added = false;

            using (var transactionScope = TransactionsFacade.CreateNewScope())
            {
                bool exist =
                    (from d in DataFacade.GetData <IDataItemTreeAttachmentPoint>()
                     where d.InterfaceType == attachmentPoint.InterfaceType && d.KeyValue == attachmentPoint.KeyValue && d.TreeId == treeId
                     select d).Any();

                if (!exist)
                {
                    DataFacade.AddNew <IDataItemTreeAttachmentPoint>(attachmentPoint);
                    added = true;
                }

                transactionScope.Complete();
            }

            return(added);
        }
 public CustomAttachmentPoint(EntityToken parentEntityToken, ElementAttachingProviderPosition position)
     :this(parentEntityToken)
 {
     this.Position = position;
 }
        /// <summary>
        /// This will add a attachment point until the system flushes.
        /// This can be used by element provider implementors to attach trees to their exising trees.
        /// </summary>
        /// <param name="treeId"></param>
        /// <param name="entityToken"></param>
        /// <param name="position"></param>
        public static bool AddCustomAttachmentPoint(string treeId, EntityToken entityToken, ElementAttachingProviderPosition position = ElementAttachingProviderPosition.Top)
        {
            EnsureInitialized();

            return(_implementation.AddCustomAttachmentPoint(treeId, entityToken, position));
        }
        /// <summary>
        /// Adds a attachment point that is persisted by the system and is loaded on every restart
        /// </summary>
        /// <param name="treeId"></param>
        /// <param name="interfaceType"></param>
        /// <param name="keyValue"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        public static bool AddPersistedAttachmentPoint(string treeId, Type interfaceType, object keyValue, ElementAttachingProviderPosition position = ElementAttachingProviderPosition.Top)
        {
            EnsureInitialized();

            return(_implementation.AddPersistedAttachmentPoint(treeId, interfaceType, keyValue, position));
        }
 public CustomAttachmentPoint(EntityToken parentEntityToken, ElementAttachingProviderPosition position)
     : this(parentEntityToken)
 {
     this.Position = position;
 }