コード例 #1
0
 public EventArgumentValidator(string eventVarName, SectionObject objects)
 {
     RuleFor(x => x.Argument)
     .Cascade(CascadeMode.StopOnFirstFailure)
     .Must((x, y) => IsValidArguments(x.Argument, objects))
     .WithMessage($"The Event {eventVarName} contains argument " + "{PropertyValue} that has not been declared");
 }
コード例 #2
0
ファイル: FormSectionView.cs プロジェクト: jakedw7/iAM
        public override void NavigationTick(NavigationObject navigationObject)
        {
            NetworkNavigationObject nno = navigationObject.Networks.Find(delegate(NetworkNavigationObject network) { return(network.NetworkID == this.NetworkID); });

            if (nno != null)
            {
                SectionObject sectionObject = nno.CurrentSection;

                if (sectionObject != m_lastSectionObject)
                {
                    if (sectionObject != null)
                    {
                        foreach (DataGridViewRow row in dgvSection.Rows)
                        {
                            if (row.Cells["FACILITY"].Value.ToString() == sectionObject.Facility && row.Cells["SECTION"].Value.ToString() == sectionObject.Section)
                            {
                                row.Selected = true;
                                UpdateCategories(sectionObject.SectionID);
                                ScrollGrid();
                            }
                            else
                            {
                                row.Selected = false;
                            }
                        }
                    }
                    m_lastSectionObject = sectionObject;
                }
            }
        }
コード例 #3
0
ファイル: NavigationObject.cs プロジェクト: jakedw7/iAM
        /// <summary>
        /// Find current section for new Route/Direction
        /// </summary>
        /// <param name="strRoute"></param>
        /// <param name="strDirection"></param>
        /// <param name="imageObject"></param>
        public void UpdateRouteDirection(String strRoute, String strDirection, ImageObject imageObject)
        {
            bool below = true;
            bool above = true;

            m_listSections = GlobalDatabaseOperations.GetSections(strRoute, strDirection, this.NetworkID);

            if (m_listSections.Count != 0)
            {
                SectionObject minBeginSection = m_listSections[0];
                SectionObject maxEndSection   = m_listSections[0];


                //Search this list to find which section
                foreach (SectionObject so in m_listSections)
                {
                    if (imageObject.Milepost >= so.BeginStation && imageObject.Milepost <= so.EndStation)
                    {
                        this.CurrentSection = so;
                    }
                    else if (imageObject.Milepost < so.BeginStation)
                    {
                        above = false;
                    }
                    else if (imageObject.Milepost > so.EndStation)
                    {
                        below = false;
                    }

                    if (so.BeginStation < minBeginSection.BeginStation)
                    {
                        minBeginSection = so;
                    }
                    if (so.EndStation > maxEndSection.EndStation)
                    {
                        maxEndSection = so;
                    }
                }

                if (this.CurrentSection == null)                        //didn't find a match
                {
                    if (above)
                    {
                        this.CurrentSection = maxEndSection;
                    }

                    if (below)
                    {
                        this.CurrentSection = minBeginSection;
                    }
                }
            }
        }
コード例 #4
0
        public EventsMethodSignatureValidator(SectionObject objects)
        {
            RuleForEach(x => x.Argument_types)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .SetValidator(model => new EventArgumentValidator(model.Event_Var_Name, objects))
            .When(x => x.Argument_types != null)
            .WithMessage("The Event {PropertyValue} contains invalid arguments");

            RuleFor(x => x.Object_variable)
            .Must((x, y) => IsValidObjectVariable(x.Object_variable, objects))
            .When(x => x.Object_variable != null)
            .WithMessage((model) => $"The Event {model.Event_Var_Name} contains variable " + "{PropertyValue} that has not been declared");
        }
コード例 #5
0
        public override object VisitObjectssection(CryslGrammarParser.ObjectssectionContext context)
        {
            SectionObject objectSection = new SectionObject();
            string        sectionName   = context.OBJECTSSECTIONNAME().GetText();

            objectSection.Crysl_Section = sectionName;
            List <ObjectsDeclaration> objectsDeclarationList = (List <ObjectsDeclaration>)Visit(context.objects());

            objectSection.Objects_Declaration = objectsDeclarationList;

            cryslModel.Object_Section = objectSection;
            return(0);
        }
コード例 #6
0
        /// <summary>
        /// Retrieves list of Sections on a given Route/Direction  (USE TRY/CATCH)
        /// </summary>
        /// <param name="strRoute"></param>
        /// <param name="strDirection"></param>
        /// <param name="strNetworkID"></param>
        /// <returns></returns>
        public static List <SectionObject> GetSections(String strFacility, String strNetworkID)
        {
            List <SectionObject> listSectionObjects = new List <SectionObject>();
            String  strSelect = "SELECT * FROM SECTION_" + strNetworkID + " WHERE FACILITY='" + strFacility + "' AND DIRECTION IS NULL ORDER BY SECTIONID";
            DataSet ds        = DBMgr.ExecuteQuery(strSelect);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                SectionObject sectionObject = new SectionObject(row);
                listSectionObjects.Add(sectionObject);
            }
            return(listSectionObjects);
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectSection"></param>
        public CryslCryptoSignatureValidator(SectionObject objectSection)
        {
            RuleForEach(x => x.Crypto_Signature)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .SetValidator(new EventsMethodSignatureValidator(objectSection))
            .WithMessage("The arguments of the method in the EVENTS section has not been declared in the OBJECTS section");

            RuleForEach(x => x.Aggregator.Aggregators)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .SetValidator(model => new EventAggregatorValidator(model.Crypto_Signature))
            .When(x => x.Aggregator != null)
            .WithMessage("The Aggregators have not been defined in the event section. Please fix in the crysl file");
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectVariable"></param>
        /// <param name="sectionObject"></param>
        /// <returns></returns>
        private bool IsValidObjectVariable(string objectVariable, SectionObject sectionObject)
        {
            bool isObjectDeclared = false;

            foreach (var objectDeclarations in sectionObject.Objects_Declaration)
            {
                if (objectDeclarations.Var_name.Equals(objectVariable))
                {
                    isObjectDeclared = true;
                    break;
                }
            }
            bool isValidObjectVariable = isObjectDeclared ? true : false;

            return(isValidObjectVariable);
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="sectionObject"></param>
        /// <returns></returns>
        private bool IsValidArguments(string argument, SectionObject sectionObject)
        {
            bool isObjectDeclared = false;

            foreach (var objectDeclarations in sectionObject.Objects_Declaration)
            {
                if (objectDeclarations.Var_name.Equals(argument) || argument.Equals("_"))
                {
                    isObjectDeclared = true;
                    break;
                }
            }

            bool isValidArgument = isObjectDeclared ? true : false;

            return(isValidArgument);
        }
コード例 #10
0
        public async void AddSection(SectionObject word)
        {
            await Context.SectionObjects.AddAsync(word);

            await Context.SaveChangesAsync();
        }