예제 #1
0
        public void GivenSerializedRasterLayesrWhenConvertToReferenceLayerThenStringRepresentationsAreConverted()
        {
            var serialzedReferenceLayer = new SerializableReferenceLayer();
            var stringRepresentation1   = new StringRepresentation
            {
                Description     = "First One",
                Code            = "Code1",
                CodeSource      = RepresentationCodeSourceEnum.ISO11783_DDI,
                LongDescription = "Long Description 1"
            };

            var stringRepresentation2 = new StringRepresentation
            {
                Description     = "Second One",
                Code            = "Code2",
                CodeSource      = RepresentationCodeSourceEnum.ADAPT,
                LongDescription = "Long Description 2"
            };

            serialzedReferenceLayer.StringValues = new List <SerializableRasterData <string> >
            {
                new SerializableRasterData <string> {
                    Representation = stringRepresentation1
                },
                new SerializableRasterData <string> {
                    Representation = stringRepresentation2
                }
            };
            serialzedReferenceLayer.RasterReferenceLayer = _referenceLayer;

            var referenceLayer = _converter.ConvertToReferenceLayer(serialzedReferenceLayer) as RasterReferenceLayer;

            for (int rasterDataIndex = 0;
                 rasterDataIndex < serialzedReferenceLayer.StringValues.Count;
                 rasterDataIndex++)
            {
                var serializableData   = serialzedReferenceLayer.StringValues[rasterDataIndex];
                var referenceLayerData = referenceLayer.StringRasterValues[rasterDataIndex];

                Assert.AreSame(serializableData.Representation, referenceLayerData.Representation);
            }
        }
        void GetCountOfRoots()
        {
            string countsOfRoots = StringRepresentation.Split('.')[0];
            bool   isLetter;

            foreach (char ch in countsOfRoots)
            {
                if (!char.IsLetter(ch))
                {
                    throw new ArgumentException("Некорректный ключ", "key");
                }
            }
            int result = 0;

            if (countsOfRoots.Length == 3)
            {
                result = ParseFromWordsToNum(countsOfRoots, false, true, true);
            }
            else
            {
                throw new ArgumentException("Некорректный ключ", "key");
            }

            string strResult = result.ToString();

            if (strResult.Length != 5)
            {
                throw new ArgumentException("Некорректный ключ", "key");
            }
            else
            {
                for (int i = 0; i < 5; i++)
                {
                    KeysStringRepresentations[i] += $"{strResult[i]}.";
                }
            }
        }
        void GetBoolSettings()
        {
            string maxRoots1 = StringRepresentation.Split('.')[4];

            foreach (char ch in maxRoots1)
            {
                if (!char.IsLetter(ch))
                {
                    throw new ArgumentException("Некорректный ключ", "key");
                }
            }
            int result = 0;

            if (maxRoots1.Length == 3)
            {
                result = ParseFromWordsToNum(maxRoots1, false, true, false);
                string newRes = string.Empty;
                while (result > 0)
                {
                    newRes  = $"{result % 4}{newRes}";
                    result /= 4;
                }
                result = int.Parse(newRes.PadLeft(1, '0'));
            }
            else
            {
                throw new ArgumentException("Некорректный ключ", "key");
            }

            string strResult = result.ToString().PadLeft(5, '0');

            for (int i = 0; i < 5; i++)
            {
                KeysStringRepresentations[i] += $"{strResult[i]}";
            }

            string maxRoots2 = StringRepresentation.Split('.')[5];

            foreach (char ch in maxRoots2)
            {
                if (!char.IsLetter(ch))
                {
                    throw new ArgumentException("Некорректный ключ", "key");
                }
            }
            result = 0;
            if (maxRoots2.Length == 3)
            {
                result = ParseFromWordsToNum(maxRoots2, false, true, true);
            }
            else
            {
                throw new ArgumentException("Некорректный ключ", "key");
            }

            strResult = result.ToString().PadLeft(5, '0');
            for (int i = 0; i < 5; i++)
            {
                KeysStringRepresentations[i] += $"{strResult[i]}.";
            }
        }
예제 #4
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(StringRepresentation != null?StringRepresentation.GetHashCode() : 0);
 }
예제 #5
0
 public SetTitleCommand(string newTitleValue, StringRepresentation title)
 {
     _newTitleValue = newTitleValue;
     _title         = title;
 }
예제 #6
0
 public ReplaceTextCommand(StringRepresentation stringRepresentation, string text)
 {
     _stringRepresentation = stringRepresentation;
     _newText = text;
 }
예제 #7
0
		public static void SetStringRepresentationMethod(Type type, StringRepresentation stringRepresentation)
		{
			if (sStringRepresentations.ContainsKey(type))
			{
				sStringRepresentations[type] = stringRepresentation;
			}
			else
			{
				sStringRepresentations.Add(type, stringRepresentation);
			}
		}