コード例 #1
0
        public void AddPropertyToDictionary(FullCalendarParameters fullCalendarParameters, ref Dictionary <string, string> dictionary)
        {
            object value = _property.GetValue(fullCalendarParameters, null);

            if (value == null)
            {
                return;
            }

            EventCollection eventCollection = (EventCollection)value;

            switch (eventCollection.Type)
            {
            case EventCollectionType.Array:
                if (eventCollection.Events == null || !eventCollection.Events.Any())
                {
                    return;
                }

                dictionary.Add("data-fc-" + _property.Name, _serializer.Serialize(eventCollection.SerializableEventArray()).ToSingleQuotes());
                break;

            case EventCollectionType.JsonFeed:
                dictionary.Add("data-fc-" + _property.Name, eventCollection.Url);
                break;

            case EventCollectionType.Function:
                dictionary.Add("data-fc-" + _property.Name, eventCollection.Function);
                break;

            case EventCollectionType.GoogleCalendarFeed:
                dictionary.Add("data-fc-" + _property.Name, _serializer.Serialize(new { googleCalendarId = eventCollection.GoogleCalendarId }).ToSingleQuotes());
                break;
            }
        }
コード例 #2
0
        public void SerializableEventArray_InitializedAsArray_ObjectIsSerialized()
        {
            DateTime        start           = DateTime.Now;
            EventCollection eventCollection = new EventCollection(new List <Event>
            {
                new Event
                {
                    Id         = 1,
                    AllDay     = false,
                    End        = start.AddHours(1),
                    Url        = "https://www.google.co.uk/",
                    ClassName  = "test-class",
                    Constraint = new EventConstraint(new BusinessHour
                    {
                        Dow = new List <DayOfWeek> {
                            DayOfWeek.Thursday, DayOfWeek.Friday
                        },
                        Start = TimeSpan.FromHours(10),
                        End   = TimeSpan.FromHours(15)
                    }),
                    Color            = Color.DarkRed,
                    AdditionalFields = new Dictionary <string, string>
                    {
                        { "description", "this is the description" },
                        { "other", "this is another additional field" }
                    },
                    Title            = "Title",
                    Start            = start,
                    GoogleCalendarId = "*****@*****.**"
                }
            });
            IEnumerable <SerializableEvent> target = eventCollection.SerializableEventArray();

            target.ShouldBeEquivalentTo(new List <SerializableEvent>
            {
                new SerializableEvent
                {
                    id               = 1,
                    title            = "Title",
                    allDay           = false,
                    start            = start.ToString("s"),
                    end              = start.AddHours(1).ToString("s"),
                    url              = "https://www.google.co.uk/",
                    className        = "test-class",
                    editable         = false,
                    startEditable    = true,
                    durationEditable = true,
                    rendering        = null,
                    overlap          = true,
                    constraint       = new SerializableBusinessHour
                    {
                        dow = new List <DayOfWeek> {
                            DayOfWeek.Thursday, DayOfWeek.Friday
                        },
                        start = "10:00",
                        end   = "15:00"
                    },
                    color            = Color.DarkRed.ToHexString(),
                    backgroundColor  = null,
                    borderColor      = null,
                    textColor        = null,
                    googleCalendarId = "*****@*****.**",
                    additionalFields = new Dictionary <string, string>
                    {
                        { "description", "this is the description" },
                        { "other", "this is another additional field" }
                    }
                }
            });
        }