Example #1
0
 public MainPage WriteIntoDestinationField(string text)
 {
     Logger.Info($"WriteIntoDestinationField: {text}.");
     DestinationField.Clear();
     DestinationField.SendKeys(text);
     return(this);
 }
        public void TestProperties()
        {
            var obj = new DestinationField(new Connection());
            TestsHelper.TestPublicPropertiesGetSet(obj, null, true);

            //IsGroupingField has private setter
            var isGroupingFieldProperty = typeof(DestinationField).GetProperty("IsGroupingField");
            Assert.IsNotNull(isGroupingFieldProperty);
            var accessors = isGroupingFieldProperty.GetAccessors(false);
            Assert.AreEqual(1, accessors.Length);
            Assert.AreEqual("get_IsGroupingField", accessors[0].Name);

            //KeepSubfieldsAlive has private setter
            var keepSubfieldsAliveProperty = typeof(DestinationField).GetProperty("KeepSubfieldsAlive");
            Assert.IsNotNull(keepSubfieldsAliveProperty);
            accessors = keepSubfieldsAliveProperty.GetAccessors(false);
            Assert.AreEqual(1, accessors.Length);
            Assert.AreEqual("get_KeepSubfieldsAlive", accessors[0].Name);

            //IsGroupingField has private setter
            var hideConnectorProperty = typeof(DestinationField).GetProperty("HideConnector");
            Assert.IsNotNull(hideConnectorProperty);
            accessors = hideConnectorProperty.GetAccessors(false);
            Assert.AreEqual(1, accessors.Length);
            Assert.AreEqual("get_HideConnector", accessors[0].Name);
        }
Example #3
0
 public MainPage WriteIntoDestinationField(string text)
 {
     LogInfo(nameof(MainPage), $" write Into Destination Field: {text}.");
     DestinationField.Clear();
     DestinationField.SendKeys(text);
     return(this);
 }
        private void m_btnOK_Click(object sender, EventArgs e)
        {
            DestinationField dest = m_cbDestination.SelectedItem as DestinationField;

            m_rsfm.m_flid  = dest.Flid;
            m_rsfm.m_sName = dest.Name;
            Debug.Assert(m_groupOptions.Controls.Count == 1);
            Control ctrl = m_groupOptions.Controls[0];

            if (ctrl == m_listOpt)
            {
                m_rsfm.m_tlo.m_sEmptyDefault   = m_listOpt.DefaultValue;
                m_rsfm.m_tlo.m_fHaveMulti      = m_listOpt.HaveMultiple;
                m_rsfm.m_tlo.m_sDelimMulti     = m_listOpt.DelimForMultiple;
                m_rsfm.m_tlo.m_fHaveSub        = m_listOpt.HaveHierarchy;
                m_rsfm.m_tlo.m_sDelimSub       = m_listOpt.DelimForHierarchy;
                m_rsfm.m_tlo.m_fHaveBetween    = m_listOpt.HaveBetweenMarkers;
                m_rsfm.m_tlo.m_sMarkStart      = m_listOpt.LeadingBetweenMarkers;
                m_rsfm.m_tlo.m_sMarkEnd        = m_listOpt.TrailingBetweenMarkers;
                m_rsfm.m_tlo.m_fHaveBefore     = m_listOpt.HaveCommentMarker;
                m_rsfm.m_tlo.m_sBefore         = m_listOpt.CommentMarkers;
                m_rsfm.m_tlo.m_fIgnoreNewStuff = m_listOpt.DiscardNewStuff;
                m_rsfm.m_tlo.m_rgsMatch        = m_listOpt.Matches;
                m_rsfm.m_tlo.m_rgsReplace      = m_listOpt.Replacements;
                m_rsfm.m_tlo.m_wsId            = m_textOpt.WritingSystem;
            }
            else if (ctrl == m_textOpt)
            {
                m_rsfm.m_txo.m_fStartParaNewLine   = m_textOpt.ParaForEachLine;
                m_rsfm.m_txo.m_fStartParaBlankLine = m_textOpt.ParaAfterBlankLine;
                m_rsfm.m_txo.m_fStartParaIndented  = m_textOpt.ParaWhenIndented;
                m_rsfm.m_txo.m_fStartParaShortLine = m_textOpt.ParaAfterShortLine;
                m_rsfm.m_txo.m_cchShortLim         = m_textOpt.ShortLineLimit;
                m_rsfm.m_txo.m_sStyle = m_textOpt.Style;
                m_rsfm.m_txo.m_wsId   = m_textOpt.WritingSystem;
            }
            else if (ctrl == m_stringOpt)
            {
                m_rsfm.m_sto.m_wsId = m_stringOpt.WritingSystem;
            }
            else if (ctrl == m_dateOpt)
            {
                m_rsfm.m_dto.m_rgsFmt = m_dateOpt.Formats;
            }
            else if (ctrl == m_linkOpt)
            {
                // No options to set, but preserve the flid and name.
            }
            else if (ctrl == m_discardOpt)
            {
                m_rsfm.m_flid  = 0;
                m_rsfm.m_sName = LexTextControls.ksDoNotImport;
            }
            else
            {
                m_rsfm.m_flid  = 0;
                m_rsfm.m_sName = LexTextControls.ksDoNotImport;
            }
            DialogResult = DialogResult.OK;
        }
        private void m_cbDestination_SelectedIndexChanged(object sender, EventArgs e)
        {
            DestinationField dest = m_cbDestination.SelectedItem as DestinationField;

            m_rsfm.m_flid  = dest.Flid;
            m_rsfm.m_sName = dest.Name;
            SetSubControl();
        }
        public void OneArgumentConstructorTest()
        {
            var expressionObject = new Connection();
            var field = new DestinationField(expressionObject);

            Assert.IsNotNull(field.ConnectorIn);
            Assert.AreEqual(field.ConnectorIn.Id, field.Id);
            Assert.AreEqual(field.ConnectorIn.Owner, expressionObject);
        }
        public void HasSubfieldsShouldReturnTrueIfSubfieldsRetriverIsNotNullAndSubfieldsCountGreaterThatZero()
        {
            var df = new DestinationField(null);
            df.ConnectorIn = new ConnectorIn(null);
            df.SubfieldsRetriever = Mock.Create<IExpressionFieldsRetriever>();
            df.Subfields.Add(new DestinationField(null));

            Assert.IsTrue(df.HasSubfields);
        }
            public override bool Equals(object obj)
            {
                DestinationField that = obj as DestinationField;

                if (that == null)
                {
                    return(false);
                }
                else
                {
                    return(this.m_flid == that.m_flid && this.m_name == that.m_name);
                }
            }
        public void TwoArgumentConstructorTest()
        {
            var expressionObject = new Connection();
            var field = new DestinationField(expressionObject, true);

            Assert.IsNotNull(field.ConnectorIn);
            Assert.AreEqual(field.ConnectorIn.Id, field.Id);
            Assert.AreEqual(field.ConnectorIn.Owner, expressionObject);

            Assert.IsTrue(field.IsGroupingField);
            Assert.IsTrue(field.IsGroupCollapsed);
            Assert.IsTrue(field.KeepSubfieldsAlive);
            Assert.IsTrue(field.HideConnector);
        }
            static bool Prefix(Projectile __instance)
            {
                if (!Enabled)
                {
                    return(true);
                }

                var projectile = __instance;

                var ticksToImpact         = (int)TicksToImpactField.GetValue(projectile);
                var startingTicksToImpact = (int)StartingTicksToImpactProperty.GetValue(projectile, null);

                var origin      = Common.ToVector2((Vector3)OriginField.GetValue(projectile));
                var destination = Common.ToVector2((Vector3)DestinationField.GetValue(projectile));
                var position    = Vector2.Lerp(origin, destination, 1.0f - ticksToImpact / (float)startingTicksToImpact);

                try
                {
                    if (projectile.def.projectile.flyOverhead)
                    {
                        // the shield has blocked the projectile - invert to get if harmony should allow the original block
                        return(!Mod.ShieldManager.ImpactShield(projectile.Map, position, origin, destination, (shield, vector2) =>
                        {
                            if (shield.Damage(projectile.def.projectile.GetDamageAmount(1f), position))
                            {
                                projectile.Destroy();
                                return true;
                            }
                            return false;
                        }));
                    }

                    var ray = new Ray2D(position, Vector2.Lerp(origin, destination, 1.0f - (ticksToImpact - 1) / (float)startingTicksToImpact));
                    Mod.ShieldManager.ImpactShield(projectile.Map, origin, ray, 1, (shield, point) =>
                    {
                        if (shield.Damage(projectile.def.projectile.GetDamageAmount(1f), point))
                        {
                            DestinationField.SetValue(projectile, Common.ToVector3(point, projectile.def.Altitude));
                            TicksToImpactField.SetValue(projectile, 0);
                            UsedTargetField.SetValue(projectile, null);
                            IntendedTargetField.SetValue(projectile, null);
                            return(true);
                        }
                        return(false);
                    });
                }
                catch (InvalidOperationException) {}
                return(true);
            }
Example #11
0
 void AddDestBtn_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();
     if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         DestinationField destField = new DestinationField();
         destField.Path    = openFile.FileName;
         destField.Keys    = keys;
         SourceAdded      += destField.OnSourceAdded;
         SourceDeleted    += destField.OnSourceDeleted;
         SourceKeyChanged += destField.OnSourceKeyChange;
         DestStack.Children.Add(destField);
         destField.KeyChanged += DestField_KeyChanged;
     }
 }
        void ReleaseDesignerOutlets()
        {
            if (DestinationField != null)
            {
                DestinationField.Dispose();
                DestinationField = null;
            }

            if (MapView != null)
            {
                MapView.Dispose();
                MapView = null;
            }

            if (OkButton != null)
            {
                OkButton.Dispose();
                OkButton = null;
            }
        }
        /// <summary>
        /// Adds the identifier fields.
        /// </summary>
        /// <param name="destination">The destination.</param>
        private static void AddIdFields(DestinationFieldList destination)
        {
            var dataType = DestinationNodeFactory.GetDataType(typeof(int));

            var df = new DestinationField(destination)
                         {
                             Name = "Id",
                             SystemName = Constants.IdColumnName,
                             DataType = dataType,
                             SetName = SourceFieldSetNames.Item,
                             ConnectorIn = { DataType = dataType, Name = "Id", IsNullable = false },
                             IsKeyEnabled = true,
                             IsKeyVisible = true
                         };

            destination.Fields.Add(df);
        }
        /// <summary>
        /// Adds the state fields.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="destination">The destination.</param>
        private static void AddStateFields(ProcessEdit process, DestinationFieldList destination)
        {
            if (!process.IsStateEnabled)
                return;

            var dataType = DestinationNodeFactory.GetDataType(typeof(string));
            var df = new DestinationField(destination)
            {
                Name = "Current State",
                SystemName = Constants.CurrentStateColumnName,
                DataType = dataType,
                SetName = SourceFieldSetNames.Item,
                ConnectorIn = { DataType = dataType, Name = "Current State", IsNullable = false },
                IsKeyVisible = true,
                IsKeyEnabled = false
            };

            destination.Fields.Add(df);
        }
        /// <summary>
        /// Creates the destination field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>The <see cref="DestinationField"/>.</returns>
        /// <exception cref="System.ArgumentException">Invalid destination field.</exception>
        private DestinationField CreateDestinationField(FieldInfo field, ExpressionObjectBase owner)
        {
            if (!CanBeDestinationField(field))
                throw new ArgumentException("Invalid destination field.");

            var dataType = GetNodeDataType(field);

            var result = new DestinationField(owner)
                         {
                             DataType = dataType,
                             Name = field.Name,
                             ConnectorIn = { DataType = dataType, Name = field.Name },
                             SystemName = field.SystemName,
                             SetName = SourceFieldSetNames.Item,
                             SubfieldsRetriever = GetDestinationFieldsRetriever(field)
                         };

            return result;
        }
Example #16
0
        public void HasParentFieldOfTypeMethodTest()
        {
            var field = new DestinationField(new Connection());
            field.ParentField = new DestinationField(new Connection()){DataType = NodeDataType.Boolean, 
                    ParentField = new DestinationField(new Connection()){DataType = NodeDataType.GageRR}};

            //Doesn't match
            Assert.IsFalse(field.HasParentFieldOfType(NodeDataType.File));

            //Matches
            Assert.IsTrue(field.HasParentFieldOfType(NodeDataType.GageRR));
        }
Example #17
0
        private DestinationFieldEdit GetDestinationField(DestinationField field, string namePrefix = "")
        {
            var fieldEdit = DestinationFieldEdit.NewDestinationField();

            fieldEdit.Name = field.Name;
            fieldEdit.SystemName = field.SystemName;
            fieldEdit.Type = field.DataType.ToNodeDataType().FullName;
            fieldEdit.IsKey = field.IsKey;

            if (field.ConnectorIn != null && field.ConnectorIn.Connection != null && field.ConnectorIn.Connection.Source != null)
                fieldEdit.MappedTo = namePrefix + field.SystemName;

            if (field.Subfields != null)
            {
                foreach (var subfield in field.Subfields.OfType<DestinationField>())
                {
                    fieldEdit.Subfields.Add(GetDestinationField(subfield, namePrefix + field.SystemName + "."));
                }
            }

            return fieldEdit;
        }
 public void ConnectorShouldReturnConnectorIn()
 {
     var df = new DestinationField(null);
     df.ConnectorIn = new ConnectorIn(null);
     Assert.AreSame(df.ConnectorIn, df.Connector);
 }
Example #19
0
        /// <summary>
        /// Adds the destination node.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="destinationNode">The destination node.</param>
        /// <param name="prefix">The prefix.</param>
        private void AddDestinationNode(DestinationField field, DestinationNode destinationNode, string prefix = "")
        {
            if (field.ConnectorIn.Connection != null && field.ConnectorIn.Connection.Source != null)
            {
                var name = prefix + field.SystemName;

                destinationNode.ResultNodes.Add(
                    CreateResultNode(field.ConnectorIn, field.DataType, name));
            }

            foreach (var subfield in field.Subfields.OfType<DestinationField>())
            {
                AddDestinationNode(subfield, destinationNode, prefix + field.SystemName + ".");
            }
        }
        /// <summary>
        /// Creates the cross reference destination field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>DestinationField.</returns>
        private static DestinationField CreateCrossReferenceDestinationField(FieldEdit field, ExpressionObjectBase owner)
        {
            var isSingleRef = field.IsSingleCrossReference();

            var df = new DestinationField(owner)
            {
                DataType = NodeDataType.CrossReference,
                Name = field.Name,
                ConnectorIn = { DataType = NodeDataType.CrossReference, Name = field.Name },
                SystemName = field.SystemName,
                SetName = SourceFieldSetNames.Item,
                IsKeyVisible = true,
                IsKeyEnabled = isSingleRef,
                SubfieldsRetriever = new CrossReferenceSubfieldsRetriever(field)
            };

            return df;
        }
Example #21
0
        public void SerializationOfAdditionalInfoTest()
        {
            var field = new DestinationField(new Connection(), true);
            field.AdditionalInfo = new CrossReferenceFieldInfo("Process");

            //Serialize properties
            var tw = new StringWriter();

            using (var xw = XmlWriter.Create(tw))
            {
                xw.WriteStartElement("DestinationField");
                field.Serialize(xw);
                xw.WriteEndElement();
            }

            //Deserialize field and restore properties' values            
            var sr = new StringReader(tw.ToString());

            using (var wr = XmlReader.Create(sr))
            {
                wr.ReadToFollowing("DestinationField");
                var restoredField = new DestinationField(new Connection());
                restoredField.Deserialize(wr);

                Assert.IsNotNull(restoredField.AdditionalInfo);
                Assert.AreEqual(
                    ((CrossReferenceFieldInfo)field.AdditionalInfo).ReferencedProcessName,
                    ((CrossReferenceFieldInfo)restoredField.AdditionalInfo).ReferencedProcessName);
            }
        }
Example #22
0
        public void SerializationOfGroupingRelatedPropertiesTest()
        {
            var field = new DestinationField(new Connection(), true);

            //Serialize properties
            var tw = new StringWriter();

            using (var xw = XmlWriter.Create(tw))
            {
                xw.WriteStartElement("Node");
                field.Serialize(xw);
                xw.WriteEndElement();
            }

            //Deserialize field and restore properties' values            
            var sr = new StringReader(tw.ToString());

            using (var wr = XmlReader.Create(sr))
            {
                wr.ReadToFollowing("Node");
                var restoredField = new DestinationField(new Connection());
                restoredField.Deserialize(wr);

                Assert.AreEqual(field.IsGroupingField, restoredField.IsGroupingField);
                Assert.AreEqual(field.IsGroupCollapsed, restoredField.IsGroupCollapsed);
                Assert.AreEqual(field.KeepSubfieldsAlive, restoredField.KeepSubfieldsAlive);
                Assert.AreEqual(field.HideConnector, restoredField.HideConnector);
            }
        }
            private DestinationField CreateField(string name, string systemName, NodeDataType type, ExpressionObjectBase owner)
            {
                var field = new DestinationField(owner)
                                {
                                    DataType = type,
                                    Name = name,
                                    IsKey = false,
                                    IsKeyVisible = true,
                                    IsKeyEnabled = true,
                                    ConnectorIn = { DataType = type, Name = name },
                                    SystemName = systemName,
                                    SetName = SourceFieldSetNames.Item
                                };

                field.ConnectorIn.Validator = _connectionValidatorFactory(field);

                return field;
            }
 /// <summary>
 /// Creates the connection validator.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>The IConnectionValidator.</returns>
 private IConnectionValidator CreateConnectionValidator(DestinationField field)
 {
     return new ConnectionValidator(ExpressionDesigner.Value.Diagram, ExpressionValidator, ExpressionNodeFactory);
 }
        /// <summary>
        /// Creates the destination field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>The DestinationField.</returns>
        /// <exception cref="System.InvalidOperationException">Invalid destination field.</exception>
        private DestinationField CreateDestinationField(FieldInfo field, ExpressionObjectBase owner)
        {
            if (!CanBeDestinationField(field))
                throw new InvalidOperationException("Invalid destination field.");

            var dataType = GetNodeDataType(field);

            var result = new DestinationField(owner)
                             {
                                 DataType = dataType,
                                 Name = field.Name,
                                 IsKeyVisible = true,
                                 IsKeyEnabled = CanBeKeyField(field),
                                 ConnectorIn = { DataType = dataType, Name = field.Name },
                                 SystemName = field.SystemName,
                                 SetName = SourceFieldSetNames.Item,
                                 SubfieldsRetriever = GetDestinationFieldsRetriever(field)
                             };

            result.ConnectorIn.Validator = CreateConnectionValidator(result);

            return result;
        }
        /// <summary>
        /// Adds the version fields.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="destination">The destination.</param>
        private static void AddVersionFields(ProcessEdit process, DestinationFieldList destination)
        {
            if (process.ProcessOptionChoose != ProcessOption.VersionEnabled)
                return;

            var dataType = DestinationNodeFactory.GetDataType(typeof(string));
            var df = new DestinationField(destination)
            {
                Name = "Version",
                SystemName = Constants.Version,
                DataType = dataType,
                SetName = SourceFieldSetNames.Item,
                ConnectorIn = { DataType = dataType, Name = Constants.Version, IsNullable = false },
                SubfieldsRetriever = new VersionSubfieldsRetriever(process),
                IsKeyVisible = true,
                IsKeyEnabled = false
            };

            destination.Fields.Add(df);
        }
        private DestinationField CreateDestinationField(IServiceExposedTypeFieldEdit field, ExpressionObjectBase owner)
        {
            var dataType = GetDataType(field);
            var subfieldsRetriever = GetSubfieldsRetriever(field);
            var result = new DestinationField(owner)
                             {
                                 DataType = dataType,
                                 Name = field.Name,
                                 ConnectorIn = { DataType = dataType, Name = field.Name },
                                 InnerName = field.Name,
                                 SystemName = field.Name,
                                 SubfieldsRetriever = subfieldsRetriever
                             };

            return result;
        }
        /// <summary>
        /// Creates the generic destination field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>DestinationField.</returns>
        private static DestinationField CreateGenericDestinationField(FieldEdit field, ExpressionObjectBase owner)
        {
            var dataType = DestinationNodeFactory.GetDataType(GetType(field));

            var df = new DestinationField(owner)
            {
                DataType = dataType,
                Name = field.Name,
                IsKeyVisible = true,
                IsKeyEnabled = CanBeKeyField(field),
                ConnectorIn = { DataType = dataType, Name = field.Name },
                SystemName = field.SystemName,
                SetName = SourceFieldSetNames.Item
            };

            return df;
        }
        /// <summary>
        /// Creates the destination field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="processName">The process name.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>The DestinationField.</returns>
        /// <exception cref="System.InvalidOperationException">Invalid destination field.</exception>
        private DestinationField CreateDestinationField(FieldInfo field, string processName, ExpressionObjectBase owner)
        {
            if (!CanBeDestinationField(field))
                throw new InvalidOperationException("Invalid destination field.");

            var dataType = GetDataType(field);
            if (field.ColumnType == ColumnTypes.Sample)
                dataType = NodeDataType.Sample;

            var df = new DestinationField(owner)
                         {
                             DataType = dataType,
                             Name = field.Name,
                             ConnectorIn = { DataType = dataType, Name = field.Name, Validator = ConnectionValidator },
                             SetName = SourceFieldSetNames.DataTriggerDestinationItem,
                             InnerName = field.SystemName,
                             SystemName = field.SystemName,
                             IsKeyEnabled = KeyFieldsEnabled && CanBeKeyField(field),
                             IsKeyVisible = KeyFieldsEnabled && CanBeKeyField(field),
                             IsRequired = field.IsRequired,
                             SubfieldsRetriever = GetDestinationFieldsRetriever(field)
                         };

            if (dataType == NodeDataType.CrossReference)
            {
                PublishedProcessInfo.BeginGetProcessInfoByCrossReferenceField(
                    processName,
                    field.SystemName,
                    true,
                    result =>
                        {
                            if (result.Error == null && result.Object != null)
                            {
                                df.AdditionalInfo = new CrossReferenceFieldInfo(result.Object.SystemName);
                            }
                        });
            }

            return df;
        }
        /// <summary>
        /// Creates the file destination field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>DestinationField.</returns>
        private static DestinationField CreateFileDestinationField(FieldEdit field, ExpressionObjectBase owner)
        {
            var dataType = DestinationNodeFactory.GetDataType(typeof(string));

            var df = new DestinationField(owner)
            {
                DataType = dataType,
                Name = field.Name,
                ConnectorIn = { DataType = dataType, Name = field.Name },
                SystemName = field.SystemName,
                SetName = SourceFieldSetNames.Item,
                IsKeyVisible = true,
                IsKeyEnabled = false
            };

            return df;
        }
Example #31
0
 public MainPage WriteIntoDestinationField(string text)
 {
     DestinationField.Clear();
     DestinationField.SendKeys(text);
     return(new MainPage(Driver));
 }
Example #32
0
        private void DoctorAviation_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            DestinationField desField = desFieldAviation.Where(x => x.fieldName == e.PropertyName).FirstOrDefault();
            var val = TypeDescriptor.GetProperties(sender)[e.PropertyName].GetValue(sender);

            if (desField != null)
            {
                char?valChar = ConvertToChar(val);
                if (valChar == 'A')
                {
                    desField.txtBox.Enabled = true;
                }
                else
                {
                    TypeDescriptor.GetProperties(sender)[desField.fieldRemarkName].SetValue(sender, null);
                    desField.txtBox.Enabled = false;
                }
            }
            else if (e.PropertyName == "trav_recomment")
            {
                char?valChar = ConvertToChar(val);
                txtfitcls.DataBindings.Clear();
                txtunitcls.DataBindings.Clear();
                txtdeferred.DataBindings.Clear();
                txtfitcls.Text   = "";
                txtunitcls.Text  = "";
                txtdeferred.Text = "";
                if (valChar == 'F')
                {
                    txtfitcls.Enabled   = true;
                    txtunitcls.Enabled  = false;
                    txtdeferred.Enabled = false;
                }
                else if (valChar == 'U')
                {
                    txtfitcls.Enabled   = false;
                    txtunitcls.Enabled  = true;
                    txtdeferred.Enabled = false;
                }
                else if (valChar == 'D')
                {
                    txtfitcls.Enabled   = false;
                    txtunitcls.Enabled  = false;
                    txtdeferred.Enabled = true;
                }
                else
                {
                    txtfitcls.Enabled   = false;
                    txtunitcls.Enabled  = false;
                    txtdeferred.Enabled = false;
                }
            }
            else
            {
                trn_audiometric_hdr PatientAudio = bsPatientAudio.OfType <trn_audiometric_hdr>().FirstOrDefault();
                if (PatientAudio != null)
                {
                    int?valInt = val == null ? null : ConvertToInt(val);
                    switch (e.PropertyName)
                    {
                    case "trav_rear_500":
                        PatientAudio.tdh_right_level_500 = valInt;
                        break;

                    case "trav_lear_500":
                        PatientAudio.tdh_left_level_500 = valInt;
                        break;

                    case "trav_rear_1000":
                        PatientAudio.tdh_right_level_1000 = valInt;
                        break;

                    case "trav_lear_1000":
                        PatientAudio.tdh_left_level_1000 = valInt;
                        break;

                    case "trav_rear_2000":
                        PatientAudio.tdh_right_level_2000 = valInt;
                        break;

                    case "trav_lear_2000":
                        PatientAudio.tdh_left_level_2000 = valInt;
                        break;

                    case "trav_rear_3000":
                        PatientAudio.tdh_right_level_3000 = valInt;
                        break;

                    case "trav_lear_3000":
                        PatientAudio.tdh_left_level_3000 = valInt;
                        break;

                    case "trav_rear_4000":
                        PatientAudio.tdh_right_level_4000 = valInt;
                        break;

                    case "trav_lear_4000":
                        PatientAudio.tdh_left_level_4000 = valInt;
                        break;
                    }
                }
            }
        }
        private static DestinationField CreateDestinationField(FieldInfo field, ExpressionObjectBase owner)
        {
            switch (field.ColumnType)
            {
                case ColumnTypes.Integer:
                case ColumnTypes.String:
                case ColumnTypes.Numeric:
                case ColumnTypes.Double:
                case ColumnTypes.Boolean:
                case ColumnTypes.DateTime:
                case ColumnTypes.SampleType:
                case ColumnTypes.Reference:
                case ColumnTypes.Result:
                case ColumnTypes.Sample:
                case ColumnTypes.Checklist:
                    {
                        var dataType = GetDataType(field);
                        var df = new DestinationField(owner)
                                     {
                                         DataType = dataType,
                                         Name = field.Name,
                                         ConnectorIn = { DataType = dataType, Name = field.Name },
                                         SetName = SourceFieldSetNames.DataTriggerDestinationItem,
                                         InnerName = field.SystemName,
                                         SystemName = field.SystemName
                                     };

                        return df;
                    }

                default:
                    throw new ArgumentException("Field type not supported.", "field");
            }
        }
            /// <summary>
            /// Creates the field.
            /// </summary>
            /// <param name="name">The field name.</param>
            /// <param name="type">The field type.</param>
            /// <param name="owner">The owner.</param>
            /// <returns>The <see cref="DestinationField"/>.</returns>
            private DestinationField CreateField(string name, NodeDataType type, ExpressionObjectBase owner)
            {
                var field = new DestinationField(owner)
                            {
                                DataType = type,
                                Name = name,
                                IsKeyVisible = false,
                                IsKeyEnabled = false,
                                ConnectorIn = { DataType = type, Name = name },
                                SystemName = name,
                                SetName = SourceFieldSetNames.Item
                            };

                return field;
            }
            /// <summary>
            /// Begins the load.
            /// </summary>
            /// <param name="destinationField">The destination field.</param>
            /// <param name="action">The action.</param>
            /// <exception cref="System.ArgumentNullException">
            /// action
            /// or
            /// destinationField
            /// </exception>
            public void BeginLoad(IExpressionField destinationField, Action<IExpressionField, IEnumerable<IExpressionField>> action)
            {
                if (action == null) throw new ArgumentNullException("action");
                if (destinationField == null) throw new ArgumentNullException("destinationField");

                var fields = new List<IExpressionField>();
                var owner = destinationField.Connector.Owner;

                // Version Date.
                var dataType = DestinationNodeFactory.GetDataType(typeof(DateTime));
                var df = new DestinationField(owner)
                             {
                                 Name = "Version Date",
                                 SystemName = Constants.VersionDate,
                                 DataType = dataType,
                                 SetName = SourceFieldSetNames.Item,
                                 ConnectorIn = { DataType = dataType, Name = "Version Date" },
                                 IsKeyVisible = true,
                                 IsKeyEnabled = false
                             };

                fields.Add(df);

                // Version Number.
                dataType = DestinationNodeFactory.GetDataType(typeof(string));
                df = new DestinationField(owner)
                         {
                             Name = Constants.VersionNumberName,
                             SystemName = Constants.VersionNumber,
                             DataType = dataType,
                             SetName = SourceFieldSetNames.Item,
                             ConnectorIn = { DataType = dataType, Name = Constants.VersionNumberName, IsNullable = false },
                             IsKeyVisible = true,
                             IsKeyEnabled = false
                         };

                fields.Add(df);

                // Version Master.
                dataType = DestinationNodeFactory.GetDataType(typeof (string));
                df = new DestinationField(owner)
                         {
                             Name = "Version Master",
                             SystemName = Constants.VersionMaster,
                             DataType = dataType,
                             ConnectorIn = { DataType = dataType, Name = "Version Master", IsNullable = false },
                             SubfieldsRetriever = new VersionMasterSubfieldsRetriever(_process),
                             IsKeyVisible = true,
                             IsKeyEnabled = false
                         };

                fields.Add(df);

                action(destinationField, fields);
            }
        public void Constructor_FillConnectorsIn()
        {
            //Mock DestinationFieldsExpressionNode
            var nodeMock = Mock.Create<DestinationFieldsExpressionNode>(Constructor.Mocked, Behavior.Loose);

            //Arrange
            Mock.NonPublic.Arrange(nodeMock, "ExpandSubconnectors", 
                ArgExpr.IsAny<ExpressionConnectorViewModel>(), false, true).IgnoreInstance().DoNothing();

            Mock.NonPublic.Arrange(nodeMock, "ConnectorsInCollectionChanged",
                                ArgExpr.IsAny<object>(), ArgExpr.IsAny<NotifyCollectionChangedEventArgs>())
                          .IgnoreInstance().DoNothing();

            var expressionObjectMock = Mock.Create<DestinationFieldList>();

            var field1 = new DestinationField(new Connection());
            var field2 = new DestinationField(new Connection());

            expressionObjectMock.Fields.Add(field1);
            expressionObjectMock.Fields.Add(field2);

            var vmMock = Mock.Create<IDiagramViewModel>();

            Mock.Arrange(() => new ExpressionConnector(ConnectorType.In, Arg.IsAny<IExpressionField>())).
                DoInstead<ConnectorType, IExpressionField>((connectorType, expressionField) =>
                {
                    if (expressionField != field1 && expressionField != field2)
                    {
                        Assert.Fail();
                    }
                })
                .MustBeCalled();

            //Act
            var result = new DestinationFieldsExpressionNode(vmMock, expressionObjectMock);

            //Assert
            Assert.AreEqual(2, result.ConnectorsIn.Count);

            Mock.NonPublic.Assert(result, "ExpandSubconnectors", Occurs.Exactly(2),
                         ArgExpr.IsAny<ExpressionConnectorViewModel>(), false, true);
        }
        public void GetResultFields_Returns_ConnectedDestinationFields()
        {
            // Arrange.
            var expressionService = CreateExpressionService();

            var expressions = new List<IExpressionObjectBase>();
            var source = new ConstantExpression();
            expressions.Add(source);

            var destination = new DestinationFieldList();
            expressions.Add(destination);

            // This field is connected.
            var destinationField1 = new DestinationField(destination) { SystemName = "Field1" };
            destination.Fields.Add(destinationField1);
            expressions.Add(CreateConnection(source.ConnectorOut, destinationField1.ConnectorIn));

            // This field is not connected, but has subfields that are connected.
            var destinationField2 = new DestinationField(destination) { SystemName = "Field2" };
            destination.Fields.Add(destinationField2);

            var subfield1 = new DestinationField(destination) { SystemName = "Subfield1" };
            destinationField2.Subfields.Add(subfield1);
            expressions.Add(CreateConnection(source.ConnectorOut, subfield1.ConnectorIn));

            var subfield2 = new DestinationField(destination) { SystemName = "Subfield2" };
            destinationField2.Subfields.Add(subfield2);

            // This field is not connected and doesn't have any subfields that are connected.
            var destinationField3 = new DestinationField(destination) { SystemName = "Field3" };
            destination.Fields.Add(destinationField3);

            var subfield3 = new DestinationField(destination) { SystemName = "Subfield3" };
            destinationField3.Subfields.Add(subfield3);

            var xml = _expressionsSerializer.Serialize(new ExpressionContainer(expressions));

            // Act.
            var resultFields = expressionService.GetResultFields(xml).ToList();

            // Assert.
            Assert.AreEqual(2, resultFields.Count);

            Assert.AreEqual("Field1", resultFields[0].SystemName);

            Assert.AreEqual("Field2", resultFields[1].SystemName);
            Assert.AreEqual(1, resultFields[1].Subfields.Count);
            Assert.AreEqual("Subfield1", resultFields[1].Subfields[0].SystemName);
        }
Example #38
0
        /// <summary>
        /// Adds the destination key fields.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="connections">The connections.</param>
        /// <param name="keyFields">The key fields.</param>
        /// <param name="prefix">The prefix.</param>
        private void AddDestinationKeyFields(DestinationField field, IEnumerable<Connection> connections, ICollection<string> keyFields, string prefix = "")
        {
            var enumerable = connections as Connection[] ?? connections.ToArray();

            if (field.IsKey && enumerable.Any(c => c.Sink.Id == field.ConnectorIn.Id))
            {
                keyFields.Add(prefix + field.SystemName);
            }

            foreach (var subfield in field.Subfields.OfType<DestinationField>())
            {
                AddDestinationKeyFields(subfield, enumerable, keyFields, prefix + field.SystemName + ".");
            }
        }
        public void InsertSubconnectorsMethod_ExpandGroupsTest()
        {
            var vmMock = Mock.Create<IDiagramViewModel>();

            var listMock = Mock.Create<DestinationFieldList>(Behavior.Loose);
            Mock.Arrange(() => listMock.Fields).Returns(new ObservableCollection<DestinationField>());

            //Mock DestinationFieldsExpressionNode
            var nodeMock = Mock.Create<DestinationFieldsExpressionNode>(Behavior.Loose, vmMock, listMock);
            var privateAccessor = new PrivateAccessor(nodeMock);

            //Arrange
            Mock.NonPublic.Arrange(nodeMock, "InsertSubconnectors",
                ArgExpr.IsAny<ExpressionConnectorViewModel>(), ArgExpr.IsAny<bool>(),
                ArgExpr.IsAny<bool>(), ArgExpr.IsAny<ExpressionConnector>()).CallOriginal();

            Mock.Arrange(() => nodeMock.ConnectorsIn).Returns(new List<IConnectorViewModel>());

            var expressionConnectorMock = Mock.Create<ExpressionConnector>(Constructor.Mocked, Behavior.Loose);
            var subfieldMock = new DestinationField(null, true);
            Mock.Arrange(() => expressionConnectorMock.GetSubconnectors()).Returns(new List<IExpressionField>{subfieldMock});

            //Act
            privateAccessor.CallMethod("InsertSubconnectors", Mock.Create<ExpressionConnectorViewModel>(), false, true, expressionConnectorMock);

            //Assert
            Mock.NonPublic.Assert(nodeMock, "ExpandSubconnectors", Occurs.Never(), ArgExpr.IsAny<ExpressionConnectorViewModel>(), ArgExpr.IsAny<bool>(), ArgExpr.IsAny<bool>());
        }