예제 #1
0
        public override string SerializeToString()
        {
            Type type = GetType();

            // Let's first see if we need to force this
            // date-time value into UTC time
            if (type != typeof(iCalDateTimeUTCSerializer) && !type.IsSubclassOf(typeof(iCalDateTimeUTCSerializer)))
            {
                foreach (object obj in m_DateTime.Attributes)
                {
                    if (obj is ForceUTCAttribute)
                    {
                        iCalDateTimeUTCSerializer serializer = new iCalDateTimeUTCSerializer(m_DateTime);
                        return(serializer.SerializeToString());
                    }
                }
            }

            string value = string.Empty;

            value += string.Format("{0:0000}{1:00}{2:00}", m_DateTime.Year, m_DateTime.Month, m_DateTime.Day);
            if (m_DateTime.HasTime)
            {
                value += string.Format("T{0:00}{1:00}{2:00}", m_DateTime.Hour, m_DateTime.Minute, m_DateTime.Second);
                if (m_DateTime.IsUniversalTime)
                {
                    value += "Z";
                }
            }
            return(value);
        }
예제 #2
0
        public override string SerializeToString()
        {
            List<string> values = new List<string>();

            values.Add("FREQ=" + Enum.GetName(typeof(FrequencyType), m_Recur.Frequency));

            //-- FROM RFC2445 --
            //The INTERVAL rule part contains a positive integer representing how
            //often the recurrence rule repeats. The default value is "1", meaning
            //every second for a SECONDLY rule, or every minute for a MINUTELY
            //rule, every hour for an HOURLY rule, every day for a DAILY rule,
            //every week for a WEEKLY rule, every month for a MONTHLY rule and
            //every year for a YEARLY rule.

            int interval = m_Recur.Interval;
            if (interval == int.MinValue)
                interval = 1;

            if (interval != 1)
                values.Add("INTERVAL=" + interval);

            if (m_Recur.Until != null)
            {
                IXCalSerializable serializer = new iCalDateTimeUTCSerializer(m_Recur.Until);
                if (serializer != null)
                    values.Add("UNTIL=" + serializer.SerializeToString());
            }

            if (m_Recur.Wkst != DayOfWeek.Monday)
                values.Add("WKST=" + Enum.GetName(typeof(DayOfWeek), m_Recur.Wkst).ToUpper().Substring(0, 2));

            if (m_Recur.Count != int.MinValue)
                values.Add("COUNT=" + m_Recur.Count);

            if (m_Recur.ByDay.Count > 0)
            {
                List<string> bydayValues = new List<string>();

                foreach (DaySpecifier byday in m_Recur.ByDay)
                {
                    IXCalSerializable serializer = new DaySpecifierSerializer(byday);
                    if (serializer != null)
                        bydayValues.Add(serializer.SerializeToString());
                }

                values.Add("BYDAY=" + string.Join(",", bydayValues.ToArray()));
            }

            SerializeByValue(values, m_Recur.ByHour, "BYHOUR");
            SerializeByValue(values, m_Recur.ByMinute, "BYMINUTE");
            SerializeByValue(values, m_Recur.ByMonth, "BYMONTH");
            SerializeByValue(values, m_Recur.ByMonthDay, "BYMONTHDAY");
            SerializeByValue(values, m_Recur.BySecond, "BYSECOND");
            SerializeByValue(values, m_Recur.BySetPos, "BYSETPOS");
            SerializeByValue(values, m_Recur.ByWeekNo, "BYWEEKNO");
            SerializeByValue(values, m_Recur.ByYearDay, "BYYEARDAY");

            return string.Join(";", values.ToArray());
        }
예제 #3
0
        public override string SerializeToString()
        {
            Type type = GetType();

            // Let's first see if we need to force this
            // date-time value into UTC time
            if (type != typeof(iCalDateTimeUTCSerializer) && !type.IsSubclassOf(typeof(iCalDateTimeUTCSerializer)))
            {
                foreach (object obj in m_DateTime.Attributes)
                {
                    if (obj is ForceUTCAttribute)
                    {
                        iCalDateTimeUTCSerializer serializer = new iCalDateTimeUTCSerializer(m_DateTime);
                        return serializer.SerializeToString();
                    }
                }
            }

            string value = string.Empty;
            value += string.Format("{0:0000}{1:00}{2:00}", m_DateTime.Year, m_DateTime.Month, m_DateTime.Day);
            if (m_DateTime.HasTime)
            {
                value += string.Format("T{0:00}{1:00}{2:00}", m_DateTime.Hour, m_DateTime.Minute, m_DateTime.Second);
                if (m_DateTime.IsUniversalTime)
                    value += "Z";
            }
            return value;
        }
        public override string SerializeToString()
        {
            List <string> values = new List <string>();

            values.Add("FREQ=" + Enum.GetName(typeof(FrequencyType), m_Recur.Frequency));

            //-- FROM RFC2445 --
            //The INTERVAL rule part contains a positive integer representing how
            //often the recurrence rule repeats. The default value is "1", meaning
            //every second for a SECONDLY rule, or every minute for a MINUTELY
            //rule, every hour for an HOURLY rule, every day for a DAILY rule,
            //every week for a WEEKLY rule, every month for a MONTHLY rule and
            //every year for a YEARLY rule.

            int interval = m_Recur.Interval;

            if (interval == int.MinValue)
            {
                interval = 1;
            }

            if (interval != 1)
            {
                values.Add("INTERVAL=" + interval);
            }

            if (m_Recur.Until != null)
            {
                IXCalSerializable serializer = new iCalDateTimeUTCSerializer(m_Recur.Until);
                if (serializer != null)
                {
                    values.Add("UNTIL=" + serializer.SerializeToString());
                }
            }

            if (m_Recur.Wkst != DayOfWeek.Monday)
            {
                values.Add("WKST=" + Enum.GetName(typeof(DayOfWeek), m_Recur.Wkst).ToUpper().Substring(0, 2));
            }

            if (m_Recur.Count != int.MinValue)
            {
                values.Add("COUNT=" + m_Recur.Count);
            }

            if (m_Recur.ByDay.Count > 0)
            {
                List <string> bydayValues = new List <string>();

                foreach (DaySpecifier byday in m_Recur.ByDay)
                {
                    IXCalSerializable serializer = new DaySpecifierSerializer(byday);
                    if (serializer != null)
                    {
                        bydayValues.Add(serializer.SerializeToString());
                    }
                }

                values.Add("BYDAY=" + string.Join(",", bydayValues.ToArray()));
            }

            SerializeByValue(values, m_Recur.ByHour, "BYHOUR");
            SerializeByValue(values, m_Recur.ByMinute, "BYMINUTE");
            SerializeByValue(values, m_Recur.ByMonth, "BYMONTH");
            SerializeByValue(values, m_Recur.ByMonthDay, "BYMONTHDAY");
            SerializeByValue(values, m_Recur.BySecond, "BYSECOND");
            SerializeByValue(values, m_Recur.BySetPos, "BYSETPOS");
            SerializeByValue(values, m_Recur.ByWeekNo, "BYWEEKNO");
            SerializeByValue(values, m_Recur.ByYearDay, "BYYEARDAY");

            return(string.Join(";", values.ToArray()));
        }