Пример #1
0
        public void GetPropertyParser_DateAlignmentIsSent_EnumPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DateAlignment));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <EnumPropertyParser>();
        }
Пример #2
0
        public void GetPropertyParser_DragOpacityIsSent_FloatPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DragOpacity));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <FloatPropertyParser>();
        }
Пример #3
0
        public void GetPropertyParser_SlotLabelIntervalIsSent_TimeSpanPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.SlotLabelInterval));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <TimeSpanPropertyParser>();
        }
Пример #4
0
        public void GetPropertyParser_BootstrapGlyphiconsIconsIsSent_ButtonIconsPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.BootstrapGlyphicons));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <ButtonIconsPropertyParser>();
        }
Пример #5
0
        public void GetPropertyParser_SelectLongPressDelayIsSent_IntegerPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.SelectLongPressDelay));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <IntegerPropertyParser>();
        }
Пример #6
0
        public void GetPropertyParser_DayPopoverFormatIsSent_FunctionPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DayPopoverFormat));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <StringPropertyParser>();
        }
Пример #7
0
        public void GetPropertyParser_SelectConstraintIsSent_ObjectPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.SelectConstraint));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <ObjectPropertyParser>();
        }
Пример #8
0
        public void GetPropertyParser_EventDurationEditableIsSent_BoolPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.EventDurationEditable));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <BoolPropertyParser>();
        }
Пример #9
0
        public void GetPropertyParser_EventOrderIsSent_ArrayPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.EventOrder));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <ArrayPropertyParser>();
        }
Пример #10
0
        public void GetPropertyParser_DefaultAllDayEventDurationIsSent_TimeSpanPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DefaultAllDayEventDuration));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <TimeSpanPropertyParser>();
        }
Пример #11
0
        public void GetPropertyParser_DragRevertDurationIsSent_IntegerPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DragRevertDuration));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <IntegerPropertyParser>();
        }
Пример #12
0
        public void GetPropertyParser_HandleWindowResizeIsSent_DoublePropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.HandleWindowResize));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <BoolPropertyParser>();
        }
Пример #13
0
        public void GetPropertyParser_ViewsIsSent_CustomViewPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Views));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <CustomViewPropertyParser>();
        }
Пример #14
0
        public void GetPropertyParser_ContentHeightIsSent_UnitPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ContentHeight));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <UnitPropertyParser>();
        }
Пример #15
0
        public void GetPropertyParser_AspectRatioIsSent_DoublePropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.AspectRatio));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <DoublePropertyParser>();
        }
Пример #16
0
        public void GetPropertyParser_BusinessHoursIsSent_BusinessHoursPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.BusinessHours));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <BusinessHoursPropertyParser>();
        }
Пример #17
0
        public void GetPropertyParser_WeekNumberCalculationIsSent_FunctionPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.WeekNumberCalculation));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <FunctionPropertyParser>();
        }
Пример #18
0
        public void GetPropertyParser_FirstDayIsSent_DayOfWeekPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.FirstDay));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <DayOfWeekPropertyParser>();
        }
Пример #19
0
        public void GetPropertyParser_TimezoneParamIsSent_StringPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.TimezoneParam));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <StringPropertyParser>();
        }
Пример #20
0
        public void GetPropertyParser_NextDayThresholdIsSent_TimeSpanPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.NextDayThreshold));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <TimeSpanPropertyParser>();
        }
Пример #21
0
        public void GetPropertyParser_LazyFetchingIsSent_BoolPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.LazyFetching));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <BoolPropertyParser>();
        }
Пример #22
0
        public void GetPropertyParser_DefaultDateIsSent_DateTimePropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DefaultDate));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <DateTimePropertyParser>();
        }
Пример #23
0
        public void GetPropertyParser_ColumnHeaderHtmlIsSent_FunctionPropertyParserIsCreated()
        {
            PropertyInfo    property       = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ColumnHeaderHtml));
            IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);

            propertyParser.Should().BeOfType <FunctionPropertyParser>();
        }
            static ParseResult <IPropertyValue> Parse <T>(IPropertyParser propertyParserUntyped, string textValue)
            {
                var propertyParserTyped = (IPropertyParser <T>)propertyParserUntyped;

                return(propertyParserTyped
                       .ValueParser
                       .Parse(textValue)
                       .Map(value => (IPropertyValue) new PropertyValue <T>(propertyParserTyped.TargetProperty, value, ValueSource.Defined)));
            }
        public static Option <IPropertyValue> Parse <T>(IPropertyParser propertyParserUntyped, string textValue)
        {
            var propertyParser = (IPropertyParser <T>)propertyParserUntyped;

            return(propertyParser
                   .ValueParser
                   .Parse(textValue)
                   .Map(value => (IPropertyValue) new PropertyValue <T>(propertyParser.TargetProperty, value, ValueSource.Defined)));
        }
Пример #26
0
        public IEnumerable <ILinkedEntity> GetLinkedEntities(object propertyValue)
        {
            if (propertyValue == null)
            {
                return(Enumerable.Empty <ILinkedEntity>());
            }

            var entities     = new List <ILinkedEntity>();
            var contentTypes = new Dictionary <string, IContentType>();
            var dataTypes    = new Dictionary <int, IDataTypeDefinition>();

            try
            {
                var items = JsonConvert.DeserializeObject <EmbeddedContentItem[]>(propertyValue.ToString());

                foreach (EmbeddedContentItem item in items)
                {
                    if (false == contentTypes.TryGetValue(item.ContentTypeAlias, out IContentType contentType))
                    {
                        contentTypes[item.ContentTypeAlias] = contentType = _contentTypeService.GetContentType(item.ContentTypeAlias);
                    }
                    if (contentType == null)
                    {
                        continue;
                    }
                    foreach (PropertyType propertyType in contentType.PropertyTypes)
                    {
                        if (false == item.Properties.TryGetValue(propertyType.Alias, out object value))
                        {
                            continue;
                        }

                        if (false == dataTypes.TryGetValue(propertyType.DataTypeDefinitionId, out IDataTypeDefinition dataTypeDefinition))
                        {
                            dataTypes[propertyType.DataTypeDefinitionId] = dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId);
                        }
                        if (dataTypeDefinition == null)
                        {
                            continue;
                        }
                        IPropertyParser parser = PropertyParserResolver.Current.Parsers.FirstOrDefault(x => x.IsParserFor(dataTypeDefinition));

                        if (parser != null)
                        {
                            entities.AddRange(parser.GetLinkedEntities(value));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error <EmbeddedContentParser>("Error parsing embedded content", exception);
            }
            return(entities);
        }
Пример #27
0
        public static Option <IPropertyValue> GetDefaultValue <T>(this IPropertyParser propertyParserUntyped)
        {
            IPropertyParser <T> propertyParser = (IPropertyParser <T>)propertyParserUntyped;

            if (propertyParser.DefaultValue != null)
            {
                var defaultValue = propertyParser.DefaultValue();
                return(new PropertyValue <T>(propertyParser.TargetProperty, defaultValue, ValueSource.DefaultValue));
            }
            return(None);
        }
Пример #28
0
        internal IDictionary <string, object> Extract(IEventRecord record)
        {
            var dict = new Dictionary <string, object>();

            dict.Add("EtwEventId", record.Id);
            dict.Add("Etw" + nameof(record.Timestamp), record.Timestamp);
            dict.Add("Etw" + nameof(record.ProcessId), record.ProcessId);
            dict.Add("Etw" + nameof(record.ThreadId), record.ThreadId);
            dict.Add("Etw" + nameof(record.ProviderName), record.ProviderName);

            if (_includeVerboseProperties)
            {
                dict.Add("EtwEventName", record.Name);
                dict.Add("Etw" + nameof(record.ProviderId), record.ProviderId);
                dict.Add("Etw" + nameof(record.Version), record.Version);
                dict.Add("Etw" + nameof(record.Level), record.Level);
            }

            IPropertyParser parser = null;

            if (providerDictionary.Contains(record.ProviderId))
            {
                parser = providerDictionary.GetByProviderGuid(record.ProviderId);
            }

            foreach (var p in record.Properties)
            {
                var parsed = parser?.ParseProperty(p.Name, record);
                if (parsed != null && parsed.Any())
                {
                    foreach (var parsedProp in parsed)
                    {
                        dict.Add(parsedProp.Key, parsedProp.Value);
                    }
                }
                else
                {
                    dict.Add(p.Name, ParseBasicProperty(p, record));
                }
            }


            return(dict);
        }
Пример #29
0
        private string GetRecursiveValue(ICmsContent content, string propertyname, IPropertyParser parser)
        {
            this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("Property {0} is set as recursive, searching ancestors for node {1}", (object)propertyname, (object)content.Name), (Exception)null);
            string str = string.Empty;

            if (content.ParentId < 0)
            {
                return(str);
            }
            for (ICmsContent cmsContent = this.cmsIndexer.GetContentById(content.ParentId); cmsContent != null && cmsContent.Id != this.cmsIndexer.CmsRootId; cmsContent = this.cmsIndexer.GetParent(cmsContent))
            {
                ICmsProperty property = this.cmsIndexer.GetProperty(cmsContent, propertyname);
                if (property != null && !string.IsNullOrEmpty(property.Value as string))
                {
                    str = parser.GetPropertyValue(property.Value);
                    this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("Found recursive value {0} for property {1} on node {2}", (object)str, (object)propertyname, (object)cmsContent.Name), (Exception)null);
                    break;
                }
            }
            return(str);
        }
Пример #30
0
        public static IHtmlString FullCalendar(this HtmlHelper htmlHelper, Action <FullCalendarParameters> parameters)
        {
            var fullCalendarParameters = new FullCalendarParameters();

            parameters(fullCalendarParameters);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            foreach (var property in typeof(FullCalendarParameters).GetProperties())
            {
                if (property.Name == nameof(FullCalendarParameters.Name) || property.Name == nameof(FullCalendarParameters.CssClass))
                {
                    continue;
                }
                IPropertyParser propertyParser = PropertyParserFactory.GetPropertyParser(property);
                propertyParser.AddPropertyToDictionary(fullCalendarParameters, ref attributes);
            }

            return(MvcHtmlString.Create(string.Format("<div {0} {1} class=\"fc {2}\" {3}></div>", !string.IsNullOrEmpty(fullCalendarParameters.Name) ?
                                                      string.Format("id='{0}'", fullCalendarParameters.Name) : "", !string.IsNullOrEmpty(fullCalendarParameters.Name) ?
                                                      string.Format("name='{0}'", fullCalendarParameters.Name) : "", fullCalendarParameters.CssClass,
                                                      string.Join(" ", attributes.Select(x => x.Key + "=\"" + x.Value + "\"")))));
        }