コード例 #1
0
 private VmDescription CreateVmDescription(DescriptionTypeEnum descriptionType)
 {
     return(new VmDescription()
     {
         Description = "desc",
         TypeId = Guid.NewGuid()//descriptionType
     });
 }
コード例 #2
0
ファイル: TestHelper.cs プロジェクト: mvirenius/ptv-1.7
 public static VmDescription CreateVmDescriptionModel(DescriptionTypeEnum descriptionType)
 {
     return(new VmDescription()
     {
         Description = "channelDescription",
         TypeId = Guid.NewGuid()//descriptionType
     });
 }
コード例 #3
0
		public string GetDescription(DescriptionTypeEnum type)
		{
			string description = string.Empty;

			try
			{
				if (!m_parsed)
				{
					ExpressionParser parser = new ExpressionParser(m_expression, m_options);
					m_expressionParts = parser.Parse();
					m_parsed = true;
				}

				switch (type)
				{
					case DescriptionTypeEnum.FULL:
						description = GetFullDescription();
						break;
					case DescriptionTypeEnum.TIMEOFDAY:
						description = GetTimeOfDayDescription();
						break;
					case DescriptionTypeEnum.HOURS:
						description = GetHoursDescription();
						break;
					case DescriptionTypeEnum.MINUTES:
						description = GetMinutesDescription();
						break;
					case DescriptionTypeEnum.SECONDS:
						description = GetSecondsDescription();
						break;
					case DescriptionTypeEnum.DAYOFMONTH:
						description = GetDayOfMonthDescription();
						break;
					case DescriptionTypeEnum.MONTH:
						description = GetMonthDescription();
						break;
					case DescriptionTypeEnum.DAYOFWEEK:
						description = GetDayOfWeekDescription();
						break;
					default:
						description = GetSecondsDescription();
						break;
				}
			}
			catch (Exception ex)
			{
				if (!m_options.ThrowExceptionOnParseError)
				{
					description = ex.Message;
				}
				else
				{
					throw;
				}
			}

			return description;
		}
コード例 #4
0
        /// <summary>
        ///     Generates a human readable string for the Cron Expression
        /// </summary>
        /// <param name="type">Which part(s) of the expression to describe</param>
        /// <returns>The cron expression description</returns>
        public string GetDescription(DescriptionTypeEnum type)
        {
            string description;

            try
            {
                if (!_parsed)
                {
                    var parser = new ExpressionParser(_expression, _options);
                    _expressionParts = parser.Parse();
                    _parsed = true;
                }

                switch (type)
                {
                    case DescriptionTypeEnum.Full:
                        description = GetFullDescription();
                        break;
                    case DescriptionTypeEnum.Timeofday:
                        description = GetTimeOfDayDescription();
                        break;
                    case DescriptionTypeEnum.Hours:
                        description = GetHoursDescription();
                        break;
                    case DescriptionTypeEnum.Minutes:
                        description = GetMinutesDescription();
                        break;
                    case DescriptionTypeEnum.Seconds:
                        description = GetSecondsDescription();
                        break;
                    case DescriptionTypeEnum.DayOfmonth:
                        description = GetDayOfMonthDescription();
                        break;
                    case DescriptionTypeEnum.Month:
                        description = GetMonthDescription();
                        break;
                    case DescriptionTypeEnum.DayOfweek:
                        description = GetDayOfWeekDescription();
                        break;
                    case DescriptionTypeEnum.Year:
                        description = GetYearDescription();
                        break;
                    default:
                        description = GetSecondsDescription();
                        break;
                }
            }
            catch (Exception exception)
            {
                if (!_options.ThrowExceptionOnParseError)
                    description = exception.Message;
                else
                    throw;
            }

            return description;
        }
コード例 #5
0
        public void TranslateOrganizationDescriptionToEntity(DescriptionTypeEnum descriptionType)
        {
            var vmDescription = TestHelper.CreateVmDescriptionModel(descriptionType);
            var toTranslate   = new List <VmDescription>()
            {
                vmDescription
            };

            var translations = RunTranslationModelToEntityTest <VmDescription, OrganizationDescription>(translators, toTranslate, unitOfWorkMock);
            var translation  = translations.First();

            Assert.Equal(toTranslate.Count, translations.Count);
            Assert.Equal(vmDescription.Description, translation.Description);
            Assert.Equal(vmDescription.TypeId, translation.TypeId);
        }
コード例 #6
0
        public void TranslateServiceDescriptionToEntity(DescriptionTypeEnum descriptionType)
        {
            var vmDescription = CreateVmDescription(descriptionType);
            var toTranslate   = new List <VmDescription>()
            {
                vmDescription
            };

            RegisterDbSet(CreateCodeData <DescriptionType>(typeof(DescriptionTypeEnum)), unitOfWorkMockSetup);
            RegisterDbSet(CreateCodeData <Language>(typeof(LanguageCode)), unitOfWorkMockSetup);

            var translations = RunTranslationModelToEntityTest <VmDescription, ServiceDescription>(new List <ITranslator> {
                serviceDescriptionTranslator, descriptionTypeCodeTranslator, languageCodeTranslator
            }, toTranslate, unitOfWorkMock);
            var translation = translations.First();

            Assert.Equal(toTranslate.Count, translations.Count);
            Assert.Equal(vmDescription.Description, translation.Description);
            Assert.Equal(vmDescription.TypeId, translation.TypeId);
        }
コード例 #7
0
    public DescriptionAttribute(string text, DescriptionTypeEnum descriptionType = DescriptionTypeEnum.NONE, int order = 0)
    {
        Text = text;
        this.order = order;

        switch (descriptionType)
        {
            case DescriptionTypeEnum.ERROR:
                messageType = MessageType.Error;
                break;
            case DescriptionTypeEnum.INFO:
                messageType = MessageType.Info;
                break;
            case DescriptionTypeEnum.NONE:
                messageType = MessageType.None;
                break;
            case DescriptionTypeEnum.WARNING:
                messageType = MessageType.Warning;
                break;
            default:
                break;
        }
    }
コード例 #8
0
 private ICollection <ServiceDescription> GetDescription(ServiceVersioned serviceVersioned, DescriptionTypeEnum type)
 {
     return(serviceVersioned.ServiceDescriptions.Where(x => x.TypeId == typesCache.Get <DescriptionType>(type.ToString())).ToList());
 }
コード例 #9
0
 private IEnumerable <IDescription> GetDescription(StatutoryServiceGeneralDescriptionVersioned generalDescriptionVersioned, DescriptionTypeEnum type)
 {
     return(generalDescriptionVersioned.Descriptions.Where(x => typesCache.Compare <DescriptionType>(x.TypeId, type.ToString())));
 }
コード例 #10
0
 private VmDescription CreateDescription(string language, string value, VmGeneralDescriptionBase vModel, DescriptionTypeEnum typeEnum, bool isEmpty = false)
 {
     return(new VmDescription
     {
         Description = isEmpty ? null : value,
         TypeId = typesCache.Get <DescriptionType>(typeEnum.ToString()),
         OwnerReferenceId = vModel.Id,
         LocalizationId = languageCache.Get(language)
     });
 }
コード例 #11
0
 private IEnumerable <IDescription> GetDescription(OrganizationVersioned organizationVersioned, DescriptionTypeEnum type)
 {
     return(organizationVersioned.OrganizationDescriptions.Where(x => x.TypeId == typesCache.Get <DescriptionType>(type.ToString())));
 }
コード例 #12
0
 public DescriptionType(uint value)
 {
     this.EnumValue = this.GetType(value);
 }
コード例 #13
0
 public DescriptionType(DescriptionTypeEnum value)
 {
     this.EnumValue = value;
 }
コード例 #14
0
 private ICollection <StatutoryServiceDescription> GetDescription(StatutoryServiceGeneralDescriptionVersioned gdVersioned, DescriptionTypeEnum type)
 {
     return(gdVersioned.Descriptions.Where(x => x.TypeId == typesCache.Get <DescriptionType>(type.ToString())).ToList());
 }
コード例 #15
0
 private IEnumerable <IDescription> GetDescription(GeneralDescriptionServiceChannel generalDescriptionServiceChannel, DescriptionTypeEnum type)
 {
     return(generalDescriptionServiceChannel.GeneralDescriptionServiceChannelDescriptions.Where(x => typesCache.Compare <DescriptionType>(x.TypeId, type.ToString())));
 }
コード例 #16
0
 private VmDescription CreateDescription(string language, string value, VmServiceChannel vModel, DescriptionTypeEnum typeEnum)
 {
     return(new VmDescription
     {
         Description = value,
         TypeId = typesCache.Get <DescriptionType>(typeEnum.ToString()),
         OwnerReferenceId = vModel.Id,
         LocalizationId = languageCache.Get(language)
     });
 }
コード例 #17
0
 private VmDescription CreateDescription(string language, string value, VmConnectionInput vModel, DescriptionTypeEnum typeEnum, bool isEmpty = false)
 {
     return(new VmDescription
     {
         Description = isEmpty ? null : value,
         TypeId = typesCache.Get <DescriptionType>(typeEnum.ToString()),
         OwnerReferenceId = vModel.MainEntityId,
         OwnerReferenceId2 = vModel.ConnectedEntityId,
         LocalizationId = languageCache.Get(language)
     });
 }
コード例 #18
0
 private IEnumerable <IDescription> GetDescription(ServiceChannelVersioned serviceChannelVersioned, DescriptionTypeEnum type)
 {
     return(serviceChannelVersioned.ServiceChannelDescriptions.Where(x => typesCache.Compare <DescriptionType>(x.TypeId, type.ToString())));
 }
コード例 #19
0
 public DescriptionType(string value)
 {
     this.EnumValue = this.GetType(value);
 }
コード例 #20
0
        /// <summary>
        /// Generates a human readable string for the Cron Expression
        /// </summary>
        /// <param name="type">Which part(s) of the expression to describe</param>
        /// <returns>The cron expression description</returns>
        public string GetDescription(DescriptionTypeEnum type)
        {
            string description = string.Empty;

            try
            {
                if (!m_parsed)
                {
                    ExpressionParser parser = new ExpressionParser(m_expression, m_options);
                    m_expressionParts = parser.Parse();
                    m_parsed          = true;
                }

                switch (type)
                {
                case DescriptionTypeEnum.FULL:
                    description = GetFullDescription();
                    break;

                case DescriptionTypeEnum.TIMEOFDAY:
                    description = GetTimeOfDayDescription();
                    break;

                case DescriptionTypeEnum.HOURS:
                    description = GetHoursDescription();
                    break;

                case DescriptionTypeEnum.MINUTES:
                    description = GetMinutesDescription();
                    break;

                case DescriptionTypeEnum.SECONDS:
                    description = GetSecondsDescription();
                    break;

                case DescriptionTypeEnum.DAYOFMONTH:
                    description = GetDayOfMonthDescription();
                    break;

                case DescriptionTypeEnum.MONTH:
                    description = GetMonthDescription();
                    break;

                case DescriptionTypeEnum.DAYOFWEEK:
                    description = GetDayOfWeekDescription();
                    break;

                case DescriptionTypeEnum.YEAR:
                    description = GetYearDescription();
                    break;

                default:
                    description = GetSecondsDescription();
                    break;
                }
            }
            catch (Exception ex)
            {
                if (!m_options.ThrowExceptionOnParseError)
                {
                    description = ex.Message;
                }
                else
                {
                    throw;
                }
            }

            // Uppercase the first letter
            description = string.Concat(m_culture.TextInfo.ToUpper(description[0]), description.Substring(1));

            return(description);
        }
コード例 #21
0
        private IEnumerable <VmDescription> GetDescription(IEnumerable <JsonLanguageLabel> descriptions, DescriptionTypeEnum type, StatutoryServiceGeneralDescriptionVersioned generalDescription)
        {
            var typeId = typesCache.Get <DescriptionType>(type.ToString());

            return(descriptions?.Select(
                       x =>
                       new VmDescription
            {
                Description = x.Label,
                TypeId = typeId,
                OwnerReferenceId = generalDescription.Id,
                LocalizationId = languageCache.Get(x.Lang)
            })
                   ?? new List <VmDescription>());
        }