Exemplo n.º 1
0
 public ChangeTracker <T> CheckChanges(
     Func <T, object> selector,
     ChangeTypeEnum code)
 {
     CheckChangesWithPlanned(selector, null, code);
     return(this);
 }
Exemplo n.º 2
0
 public static void SetEulerAngles(this Transform @this, Vector3 newValue, ChangeTypeEnum changeTypeTransform, AxisCombined axisCombined = AxisCombined.XYZ)
 {
     if (@this)
     {
         Vector3 eulerAngles = @this.eulerAngles;
         @this.eulerAngles = Vector3Extend.ChangeVector(eulerAngles, newValue, changeTypeTransform, axisCombined);
     }
 }
Exemplo n.º 3
0
 public static void SetVelocity(this Rigidbody2D @this, Vector2 newValue, ChangeTypeEnum changeTypeTransform, Axis2DCombined axisCombined = Axis2DCombined.XY)
 {
     if (@this)
     {
         Vector3 velocity = @this.velocity;
         @this.velocity = Vector2Extend.ChangeVector(velocity, newValue, changeTypeTransform, axisCombined);
     }
 }
 /// <summary>Init and get event instance</summary>
 public static BGCurveChangedArgs GetInstance(BGCurve curve, ChangeTypeEnum type, string message)
 {
     Instance.curve           = curve;
     Instance.changeType      = type;
     Instance.message         = message;
     Instance.multipleChanges = null;
     Instance.point           = null;
     return(Instance);
 }
Exemplo n.º 5
0
 public static void SetZEulerAngles(this Transform @this, float zValue, ChangeTypeEnum changeTypeTransform, Vector2 range = default)
 {
     if (@this)
     {
         Vector3 eulerAngles = @this.eulerAngles;
         eulerAngles       = Vector3Extend.ChangeVector(eulerAngles, AxisCombined.Z, zValue, changeTypeTransform, range);
         @this.eulerAngles = eulerAngles;
     }
 }
Exemplo n.º 6
0
 public static void SetYVelocity(this Rigidbody2D @this, float yValue, ChangeTypeEnum changeTypeTransform, Vector2 range = default)
 {
     if (@this)
     {
         Vector3 velocity = @this.velocity;
         velocity       = Vector2Extend.ChangeVector(velocity, Axis2DEnum.Y, yValue, changeTypeTransform, range);
         @this.velocity = velocity;
     }
 }
Exemplo n.º 7
0
 private void LogsForNewItem <TS>(
     ChangeTypeEnum added,
     Func <TS, IEnumerable <AuditLogEntry> > processorOfNew,
     TS entity)
     where TS : Identity
 {
     Logs = Logs.Append(LogAction(added, null, entity, false));
     if (processorOfNew != null)
     {
         Logs = Logs.Concat(processorOfNew(entity));
     }
 }
        /// <summary>
        /// This method Item Changed
        /// </summary>
        public async void ItemChanged(object itemChanged, ChangeTypeEnum listChangeType)
        {
            // cast the item as a ToDo object
            Image image = itemChanged as Image;

            // If the image object exists
            if (NullHelper.Exists(image))
            {
                // perform the saved
                bool saved = await ImageService.SaveImage(ref image);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// This method Item Changed
        /// </summary>
        public async void ItemChanged(object itemChanged, ChangeTypeEnum listChangeType)
        {
            // cast the item as a ToDo object
            ToDo toDo = itemChanged as ToDo;

            // If the toDo object exists
            if (NullHelper.Exists(toDo))
            {
                // perform the saved
                bool saved = await ToDoService.SaveToDo(ref toDo);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// This method Item Changed
        /// </summary>
        public async void ItemChanged(object itemChanged, ChangeTypeEnum listChangeType)
        {
            // cast the item as a ToDo object
            Artist artist = itemChanged as Artist;

            // If the artist object exists
            if (NullHelper.Exists(artist))
            {
                // perform the saved
                bool saved = await ArtistService.SaveArtist(ref artist);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// This method Item Changed
        /// </summary>
        public async void ItemChanged(object itemChanged, ChangeTypeEnum listChangeType)
        {
            // cast the item as a ToDo object
            User user = itemChanged as User;

            // If the user object exists
            if (NullHelper.Exists(user))
            {
                // perform the saved
                bool saved = await UserService.SaveUser(ref user);
            }
        }
Exemplo n.º 12
0
 private static AuditLogEntry LogAction(ChangeTypeEnum code, object origin, object updated, bool planned)
 {
     if (!ChangeTypeCodes.ContainsKey(code))
     {
         throw new ArgumentException($"Change type {code} is not exist.");
     }
     return(new AuditLogEntry
     {
         Original = origin,
         NewValue = updated,
         ChangeType = $"{(int)code + 1} {ChangeTypeCodes[code]}",
         IsPlanned = planned
     });
 }
Exemplo n.º 13
0
        /// <summary>
        /// Watches for changes of the given type to the Element with the given ID. When changed, executes
        /// the given Delegate.
        /// </summary>
        /// <param name="e">ID of the Element being watched.</param>
        /// <param name="type">Type of change to watch for.</param>
        /// <param name="d">Delegate to be called when changed.</param>
        public void RegisterChangeHook(ElementId e, ChangeTypeEnum type, DynElementUpdateDelegate d)
        {
            Dictionary <ElementId, DynElementUpdateDelegate> dict;

            if (!_updateDict.ContainsKey(type))
            {
                dict = new Dictionary <ElementId, DynElementUpdateDelegate>();
                _updateDict[type] = dict;
            }
            else
            {
                dict = _updateDict[type];
            }

            dict[e] = d;
        }
Exemplo n.º 14
0
 private void SaveChange(ChangeTypeEnum pIntChangeType, T pObjEntity)
 {
     mObjContext.Change.Add(new Change()
     {
         Id               = 0,
         ChangeType       = pIntChangeType,
         ObjectType       = typeof(T).Name,
         Object           = GetSerializedObject(pObjEntity),
         Date             = DateTime.Now,
         Protected        = true,
         Removed          = false,
         UserId           = GetCurrentUserId(),
         CreationDate     = DateTime.Now,
         ModificationDate = DateTime.Now
     });
 }
Exemplo n.º 15
0
        public ChangeTracker <T> CheckChangesWithPlanned(
            Func <T, object> selector,
            Func <T, object> plannedSelector,
            ChangeTypeEnum code)
        {
            if (_original == null)
            {
                throw new InvalidOperationException("You can't use this method without origin.");
            }
            if (selector(_original).IsDeepEqual(selector(_updated)))
            {
                return(this);
            }
            bool planned = plannedSelector != null && !plannedSelector(_original).IsDeepEqual(plannedSelector(_updated));

            Logs = Logs.Append(LogAction(code, selector(_original), selector(_updated), planned));

            return(this);
        }
Exemplo n.º 16
0
            public static dynamic GetTSObject(ChangeTypeEnum dynEnum)
            {
                var tsType = TSActivator.CreateInstance("Tekla.Structures.Model.ChangeData.ChangeTypeEnum").GetType();

                switch (dynEnum)
                {
                case ChangeTypeEnum.OBJECT_INSERT:
                    return(System.Enum.Parse(tsType, "OBJECT_INSERT"));

                case ChangeTypeEnum.OBJECT_MODIFY:
                    return(System.Enum.Parse(tsType, "OBJECT_MODIFY"));

                case ChangeTypeEnum.OBJECT_DELETE:
                    return(System.Enum.Parse(tsType, "OBJECT_DELETE"));

                case ChangeTypeEnum.USERPROPERTY_CHANGED:
                    return(System.Enum.Parse(tsType, "USERPROPERTY_CHANGED"));

                default:
                    throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented");
                }
            }
Exemplo n.º 17
0
 private void SaveChange(ChangeTypeEnum pIntChangeType, IList <T> pLstObjEntity)
 {
     if (pLstObjEntity != null && pLstObjEntity.Count > 0)
     {
         foreach (var lObjEntity in pLstObjEntity)
         {
             mObjContext.Change.Add(new Change()
             {
                 Id               = 0,
                 ChangeType       = pIntChangeType,
                 ObjectType       = lObjEntity.GetType().Name,
                 Object           = lObjEntity.CopyWithoutVirtualProperties().JsonSerialize(),
                 Date             = DateTime.Now,
                 Protected        = true,
                 Removed          = false,
                 UserId           = GetCurrentUserId(),
                 CreationDate     = DateTime.Now,
                 ModificationDate = DateTime.Now
             });
         }
     }
 }
Exemplo n.º 18
0
        private void SaveChange(ChangeTypeEnum pIntChangeType, T pObjEntity)
        {
#if DEBUG
            var a = typeof(T).Name;
            var b = pObjEntity.CopyWithoutVirtualProperties().JsonSerialize();
            var c = GetCurrentUserId();
#endif

            mObjContext.Change.Add(new Change()
            {
                Id               = 0,
                ChangeType       = pIntChangeType,
                ObjectType       = typeof(T).Name,
                Object           = pObjEntity.CopyWithoutVirtualProperties().JsonSerialize(),
                Date             = DateTime.Now,
                Protected        = true,
                Removed          = false,
                UserId           = GetCurrentUserId(),
                CreationDate     = DateTime.Now,
                ModificationDate = DateTime.Now
            });
        }
Exemplo n.º 19
0
        public ChangeTracker <T> CheckChangesInIdentityList <TS>(
            Func <T, List <TS> > selector,
            Func <TS, TS, IEnumerable <AuditLogEntry> > processor,
            ChangeTypeEnum added,
            Func <TS, IEnumerable <AuditLogEntry> > processorOfNew = null) where TS : Identity
        {
            var updated = selector(_updated)
                          .GroupBy(x => x.Id)
                          .ToDictionary(x => x.Key, x => x.FirstOrDefault());

            if (_original == null)
            {
                foreach (var entity in updated.Values)
                {
                    LogsForNewItem(added, processorOfNew, entity);
                }
                return(this);
            }

            var original = selector(_original)
                           .GroupBy(x => x.Id)
                           .ToDictionary(x => x.Key, x => x.FirstOrDefault());

            foreach (var updatedKey in updated.Keys)
            {
                if (original.ContainsKey(updatedKey))
                {
                    Logs = Logs.Concat(processor(original[updatedKey], updated[updatedKey]));
                }
                else
                {
                    var entity = updated[updatedKey];
                    LogsForNewItem(added, processorOfNew, entity);
                }
            }

            return(this);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Unregisters an element that has been registered via RegisterChangeHook()
 /// </summary>
 /// <param name="e">ID of the Element to unregister.</param>
 /// <param name="type">Type of change to unsubscribe from.</param>
 public void UnRegisterChangeHook(ElementId e, ChangeTypeEnum type)
 {
     _updateDict[type].Remove(e);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Unregisters an element that has been registered via RegisterChangeHook()
 /// </summary>
 /// <param name="e">ID of the Element to unregister.</param>
 /// <param name="type">Type of change to unsubscribe from.</param>
 public void UnRegisterChangeHook(ElementId e, ChangeTypeEnum type)
 {
     this.updateDict[type].Remove(e);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Watches for changes of the given type to the Element with the given ID. When changed, executes
        /// the given Delegate.
        /// </summary>
        /// <param name="e">ID of the Element being watched.</param>
        /// <param name="type">Type of change to watch for.</param>
        /// <param name="d">Delegate to be called when changed.</param>
        public void RegisterChangeHook(ElementId e, ChangeTypeEnum type, DynElementUpdateDelegate d)
        {
            Dictionary<ElementId, DynElementUpdateDelegate> dict;
            if (!this.updateDict.ContainsKey(type))
            {
                dict = new Dictionary<ElementId, DynElementUpdateDelegate>();
                this.updateDict[type] = dict;
            }
            else
                dict = this.updateDict[type];

            dict[e] = d;
        }
Exemplo n.º 23
0
 public BGCurveChangedArgs(BGCurve curve, BGCurveChangedArgs[] multipleChanges)
 {
     this.curve           = curve;
     changeType           = ChangeTypeEnum.Multiple;
     this.multipleChanges = multipleChanges;
 }
Exemplo n.º 24
0
 public BGCurveChangedArgs(BGCurve curve, BGCurvePoint point, ChangeTypeEnum changeType) : this(curve, changeType)
 {
     this.point = point;
 }
Exemplo n.º 25
0
 public BGCurveChangedArgs(BGCurve curve, ChangeTypeEnum changeType)
 {
     this.curve      = curve;
     this.changeType = changeType;
 }