Example #1
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     this._modeController._changeMode.LogPayloadDecoration   = () => LogStepDetailsInfo();
     this._modeController._stepBackward.LogPayloadDecoration = () => LogStepDetailsInfo();
     this._modeController._stepForward.LogPayloadDecoration  = () => LogStepDetailsInfo();
     this._modeController._stepIn.LogPayloadDecoration       = () => LogStepDetailsInfo();
 }
Example #2
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     _createTask.InitializeExclusively(Create);
     _readTask.InitializeExclusively(Read);
     _updateTask.InitializeExclusively(Update);
     _deleteTask.InitializeExclusively(Delete);
 }
Example #3
0
        /// <summary>
        /// Get the Plain (POCO) object populated with current online data.
        /// </summary>
        /// <remarks>
        /// This method uses dynamic casting, which may impact the performance of the data exchange.
        /// </remarks>
        /// <param name="obj">Onliner from which the plain is created.</param>
        /// <returns>Plain (POCO) object populated with current online data.</returns>
        public static object CreatePlain(this IVortexObject obj)
        {
            dynamic o     = obj;
            var     plain = o.CreatePlainerType();

            o.FlushOnlineToPlain(plain);
            return(plain);
        }
Example #4
0
 public TreeViewWrapper(IVortexObject obj)
 {
     Wrapper = obj;
     if (Wrapper.GetType() == typeof(IVortexObject))
     {
         HasChildren = true;
         Children    = Wrapper.GetKids();
     }
 }
Example #5
0
        private string Translate(string text, IVortexObject sender)
        {
            if (sender != null && sender.GetValueTags().FirstOrDefault() != null)
            {
                return(sender.GetValueTags().FirstOrDefault().Translator.Translate(StringInterpolator.Interpolate(text, sender)));
            }

            return(text);
        }
Example #6
0
        /// <summary>
        /// Sets the logging for the 'Edit' -> 'Online' value change.
        /// </summary>
        /// <param name="obj">Root twin object</param>
        /// <returns>AppBuilder</returns>
        public TcoAppBuilder SetEditValueChangeLogging(IVortexObject obj)
        {
            foreach (var valtag in obj.GetValueTags())
            {
                valtag.EditValueChange = LoggingHelpers.EditValueChange;
            }

            return(this);
        }
Example #7
0
        public Recorder(IVortexObject vortexObject)
        {
            _recordedObject = vortexObject;
            Tasks           = _recordedObject.GetDescendants <IsTask>();

            foreach (var task in Tasks)
            {
                task.RecordTaskAction = this.Record;
            }
        }
Example #8
0
        public static IEnumerable <T> GetChildren <T>(this IVortexObject obj, IEnumerable <object> excluding) where T : IVortexObject
        {
            if (excluding == null)
            {
                excluding = new List <Type>();
            }

            var children = obj.GetChildren().Where(p => p is T && !excluding.Any(e => e != p)).Select(p => (T)p);

            return(children);
        }
Example #9
0
        public void Import(IEnumerable <string> records, IVortexObject crudDataObject = null, char separator = ';')
        {
            var documents = records.ToArray();
            var header    = documents[0];

            var headerItems = header.Split(separator);
            var dictionary  = new List <ImportItems>();

            // Prepare swappable object
            var onliner = typeof(T).Name.Replace("Plain", string.Empty);

            var adapter        = new Vortex.Connector.ConnectorAdapter(typeof(DummyConnectorFactory));
            var dummyConnector = adapter.GetConnector(new object[] { });

            var onlinerType = Assembly.GetAssembly(typeof(T)).GetTypes().FirstOrDefault(p => p.Name == onliner);

            IVortexObject prototype;

            if (crudDataObject == null)
            {
                prototype = Activator.CreateInstance(onlinerType, new object[] { dummyConnector, string.Empty, string.Empty }) as IVortexObject;
            }
            else
            {
                prototype = crudDataObject;
            }

            var valueTags = prototype.RetrieveValueTags();

            // Get headered dictionary
            foreach (var headerItem in headerItems)
            {
                dictionary.Add(new ImportItems()
                {
                    Key = headerItem
                });
            }


            // Load values
            for (int i = 2; i < documents.Count(); i++)
            {
                var documentItems = documents[i].Split(separator);
                for (int a = 0; a < documentItems.Count(); a++)
                {
                    dictionary[a].Value = documentItems[a];
                }

                UpdateDocument(dictionary, valueTags, prototype);
            }
        }
Example #10
0
        partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
        {
            _context = parent.GetParent <TcoContext>();

            // TODO: This is temporary should be made in in VortexBase library
            Task.Run(() =>
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(2000);
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsActive)));
                }
            });
        }
Example #11
0
        /// <summary>
        /// Searches recursively the parents of this <see cref="IVortexObject"/> until encounters object of given
        /// type. When the root object <see cref="Vortex.Connector.IConnector"/> is hit climbing up the hierarchy the method returns pre-existing parent.
        /// </summary>
        /// <remarks>
        /// Take into consideration possible performance degradation due to use of reflections in this method.
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj">Searched object</param>
        /// <param name="parent">[optional] Pre-existing parent. </param>
        /// <returns>Parent object of given type.</returns>
        public static T GetParent <T>(this IVortexObject obj, T parent = null) where T : class
        {
            if (obj is Vortex.Connector.RootVortexerObject || obj is Vortex.Connector.IConnector || obj == null)
            {
                return(parent);
            }

            if (obj is T)
            {
                parent = (T)obj;
                return(parent);
            }

            return(GetParent <T>(obj.GetParent()));
        }
Example #12
0
        partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
        {
            this._stopTask.LogPayloadDecoration         = () => this.CreatePlain();
            this._haltTask.LogPayloadDecoration         = () => this.CreatePlain();
            this._setPositionTask.LogPayloadDecoration  = () => this._setPositionTask.CreatePlain();
            this._soEResetTask.LogPayloadDecoration     = () => this.CreatePlain();
            this._resetTask.LogPayloadDecoration        = () => this.CreatePlain();
            this._homeTask.LogPayloadDecoration         = () => this._homeTask.CreatePlain();
            this._moveAbsoluteTask.LogPayloadDecoration = () => this._moveAbsoluteTask.CreatePlain();
            this._moveRelativeTask.LogPayloadDecoration = () => this._moveRelativeTask.CreatePlain();
            this._moveModuloTask.LogPayloadDecoration   = () => this._moveModuloTask.CreatePlain();
            this._moveVelocityTask.LogPayloadDecoration = () => this._moveVelocityTask.CreatePlain();

            this._moveAbsoluteTask.CodeProvider = new MoveAbsoluteTaskCodeProvider(this);
            this._moveRelativeTask.CodeProvider = new MoveRelativeTaskCodeProvider(this);
            this._moveModuloTask.CodeProvider   = new MoveModuloTaskCodeProvider(this);
            this._moveVelocityTask.CodeProvider = new MoveVelocityTaskCodeProvider(this);
        }
        /// <summary>
        /// Searches recursively the children of this <see cref="IVortexObject"/>
        /// </summary>
        /// <remarks>
        /// Take into consideration possible performance degradation due to use of reflections in this method.
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj">Searched object</param>
        /// <param name="children">[optional] Pre-existing children. </param>
        /// <returns>Children of this object.</returns>
        public static IEnumerable <T> GetDescendants <T>(this IVortexObject obj, IList <T> children = null) where T : IVortexObject
        {
            children = children != null ? children : new List <T>();

            if (obj is Vortex.Connector.IVortexObject && obj != null)
            {
                foreach (var child in obj.GetChildren())
                {
                    if (child is T)
                    {
                        children.Add((T)obj);
                    }

                    GetDescendants <T>(child, children);
                }
            }

            return(children);
        }
Example #14
0
        /// <summary>
        /// Searches recursively the children of this <see cref="IVortexObject"/>
        /// </summary>
        /// <remarks>
        /// Take into consideration possible performance degradation due to use of reflections in this method.
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj">Searched object</param>
        /// <param name="children">[optional] Pre-existing children. </param>
        /// <returns>Children of this object.</returns>
        public static IEnumerable <T> GetDescendants <T>(this IVortexObject obj, IList <T> children = null) where T : class
        {
            children = children != null ? children : new List <T>();

            if (obj != null)
            {
                foreach (var child in obj.GetChildren())
                {
                    var ch = child as T;
                    if (ch != null)
                    {
                        children.Add(ch);
                    }

                    GetDescendants <T>(child, children);
                }
            }

            return(children);
        }
Example #15
0
        /// <summary>
        /// Gets descendant objects of given type up to given tree depth.
        /// </summary>
        /// <remarks>
        /// Take into consideration possible performance degradation due to use of reflections in this method.
        /// </remarks>
        /// <typeparam name="T">Descendant type</typeparam>
        /// <param name="obj">Root object</param>
        /// <param name="depth">Depth to search for descendant objects</param>
        /// <param name="children">[optional] Pre-existing descendants.</param>
        /// <param name="currentDepth">[optional] Current depth</param>
        /// <returns>Descendant of given type up to given depth.</returns>
        public static IEnumerable <T> GetDescendants <T>(this IVortexObject obj, int depth, IList <T> children = null, int currentDepth = 0) where T : class
        {
            children = children != null ? children : new List <T>();

            currentDepth++;

            if (obj != null && currentDepth < depth)
            {
                foreach (var child in obj.GetChildren())
                {
                    var ch = child as T;
                    if (ch != null)
                    {
                        children.Add(ch);
                    }

                    GetDescendants <T>(child, depth, children, currentDepth);
                }
            }

            currentDepth--;

            return(children);
        }
Example #16
0
 public SwiftRecorderViewModel(IVortexObject treeRootObject)
 {
     TreeRootObject        = treeRootObject;
     StartRecordingCommand = new RelayCommand(a => StartRecording());
     StopRecordingCommand  = new RelayCommand(a => StopRecording());
 }
Example #17
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     ChangeTracker = new ValueChangeTracker(this);
 }
Example #18
0
        /// <summary>
        /// Get the children of given type of this <see cref="IVortexObject"/>
        /// </summary>
        /// <remarks>
        /// Take into consideration possible performance degradation due to use of reflections in this method.
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj">Searched object</param>
        /// <returns>Children of this object.</returns>
        public static IEnumerable <T> GetChildren <T>(this IVortexObject obj) where T : IVortexObject
        {
            var children = obj.GetChildren().Where(p => p is T).Select(p => (T)p);

            return(children);
        }
Example #19
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     this.Connector.IdentityProvider.AddIdentity(this);
 }
Example #20
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     this._enabled.Subscribe(ValidateCanExecute);
     this._isServiceable.Subscribe(ValidateCanExecute);
     CanExecuteChanged += TcoToggleTask_CanExecuteChanged;
 }
 public MoveAbsoluteTaskCodeProvider(IVortexObject origin)
 {
     Origin = origin;
 }
Example #22
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     _context = parent.GetParent <IsTcoContext>();
     _context?.AddMessage(this);
     _parentObject = parent.GetParent <IsTcoObject>();
 }
Example #23
0
        private void UpdateDocument(List <ImportItems> dictionary, IEnumerable <IValueTag> valueTags, IVortexObject prototype)
        {
            string id       = dictionary.FirstOrDefault(p => p.Key == "_EntityId").Value;
            var    existing = this.Repository.Queryable.Where(p => p._EntityId == id).FirstOrDefault();

            if (existing != null)
            {
                ((dynamic)prototype).CopyPlainToShadow(existing);
            }

            ((dynamic)prototype)._EntityId.Shadow = id;

            if (existing != null)
            {
                ((dynamic)prototype).ChangeTracker.StartObservingChanges();
            }
            // Swap values to shadow
            foreach (var item in dictionary)
            {
                if (!string.IsNullOrEmpty(item.Key))
                {
                    var             tag  = valueTags.FirstOrDefault(p => p.Symbol == item.Key);
                    OnlinerBaseType type = tag as OnlinerBaseType;

                    if (type is OnlinerString || type is OnlinerWString)
                    {
                        ((dynamic)tag).Shadow = (CastValue(type, item.Value) as string)?.Replace('►', ';');
                    }
                    else
                    {
                        ((dynamic)tag).Shadow = CastValue(type, item.Value);
                    }
                }
            }

            if (existing != null)
            {
                ((dynamic)prototype).ChangeTracker.StopObservingChanges();
            }


            if (existing != null)
            {
                ((dynamic)prototype).ChangeTracker.Import(existing);
                ((dynamic)existing).CopyShadowToPlain((dynamic)prototype);
                this.Repository.Update(existing._EntityId, existing);
            }
            else
            {
                T newRecord = new T();
                ((dynamic)prototype).ChangeTracker.Import(newRecord);
                ((dynamic)newRecord).CopyShadowToPlain((dynamic)prototype);
                this.Repository.Create(newRecord._EntityId, newRecord);
            }
        }
Example #24
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     this.Connector.IdentityProvider.AddIdentity(this);
     this.MessageHandler = new TcoObjectMessageHandler(this, this);
 }
 public void AddChild(IVortexObject vortexObject)
 {
     _obj.AddChild(vortexObject);
 }
Example #26
0
 public void AddChild(IVortexObject vortexObject)
 {
     _children.Add(vortexObject);
 }
Example #27
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
 }
 public MoveVelocityTaskCodeProvider(IVortexObject origin)
 {
     Origin = origin;
 }
Example #29
0
 partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
 {
     expectDequeingTags = this._buffer.Select(p => p.ExpectDequeing as IValueTag).ToList();
 }
 public TreeWrapperObject(IVortexObject obj)
 {
     _obj = obj;
 }