示例#1
0
        public override bool Equals(ModelBase otherModel)
        {
            if (otherModel.GetType() != typeof(KeyModel))
            {
                return(false);
            }

            KeyModel otherKey = otherModel as KeyModel;

            if (otherKey.ID != this.ID)
            {
                return(false);
            }
            else if (otherKey.IsControl != this.IsControl)
            {
                return(false);
            }
            else if (otherKey.Code != this.Code)
            {
                return(false);
            }
            else if (otherKey.KeywayID != this.KeywayID)
            {
                return(false);
            }
            else if (otherKey.LastSerial != this.LastSerial)
            {
                return(false);
            }
            else if (otherKey.Cuts != this.Cuts)
            {
                return(false);
            }
            else if (otherKey.Sidebar != this.Sidebar)
            {
                return(false);
            }
            else if (otherKey.SiteID != this.SiteID)
            {
                return(false);
            }
            else if (otherKey.Door != this.Door)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#2
0
        public static List <int?> PadKey(KeyModel inputKey, int paddingLength, bool isEndStoppedLeft = true)
        {
            List <int?> output           = new List <int?>();
            int         currentKeyLength = inputKey.CutsList.Count;
            int         paddingDelta     = paddingLength - currentKeyLength;

            if (paddingDelta >= 0) // Pad
            {
                if (isEndStoppedLeft == false)
                {
                    for (int paddingIndex = 0; paddingIndex < paddingDelta; paddingIndex++)
                    {
                        output.Add(null);
                    }
                }

                foreach (int currentCut in inputKey.CutsList)
                {
                    output.Add(currentCut);
                }

                if (isEndStoppedLeft == true)
                {
                    for (int paddingIndex = 0; paddingIndex < paddingDelta; paddingIndex++)
                    {
                        output.Add(null);
                    }
                }
            }
            else if (isEndStoppedLeft) // Trim right
            {
                for (int columnIndex = 0; columnIndex < paddingLength; columnIndex++)
                {
                    output.Add(inputKey.CutsList[columnIndex]);
                }
            }
            else // Trim left
            {
                for (int columnIndex = Math.Abs(paddingDelta); columnIndex < currentKeyLength; columnIndex++)
                {
                    output.Add(inputKey.CutsList[columnIndex]);
                }
            }

            return(output);
        }