本文整理汇总了C#中DDay.iCal.Components.iCalObject类的典型用法代码示例。如果您正苦于以下问题:C# iCalObject类的具体用法?C# iCalObject怎么用?C# iCalObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
iCalObject类属于DDay.iCal.Components命名空间,在下文中一共展示了iCalObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Copy
public override iCalObject Copy(iCalObject parent)
{
Parameter p = (Parameter)base.Copy(parent);
foreach (string s in Values)
p.Values.Add(s);
return p;
}
示例2: AddChild
public override void AddChild(iCalObject child)
{
if (child is TimeZoneInfo)
TimeZoneInfos.Add((TimeZoneInfo)child);
base.AddChild(child);
}
示例3: Copy
public override iCalObject Copy(iCalObject parent)
{
Property p = (Property)base.Copy(parent);
p.Name = Name;
p.Value = Value;
return p;
}
示例4: RemoveChild
public override void RemoveChild(iCalObject child)
{
if (child is TimeZoneInfo &&
TimeZoneInfos.Contains((TimeZoneInfo)child))
TimeZoneInfos.Remove((TimeZoneInfo)child);
base.RemoveChild(child);
}
示例5: Create
static public new ComponentBase Create(iCalObject parent, string name)
{
switch (name)
{
case "VEVENT": return new CustomEvent1(parent);
default: return ComponentBase.Create(parent, name);
}
}
示例6: Create
static public ComponentBase Create(iCalObject parent, string name)
{
switch (name)
{
case "VEVENT":
// For event objects, use our custom event class
return new CustomEvent(parent);
default:
// Otherwise, use the default classes
return ComponentBase.Create(parent, name);
}
}
示例7: Create
static public ComponentBase Create(iCalObject parent, string name)
{
switch(name.ToUpper())
{
case "VALARM": return new Alarm(parent); break;
case "VEVENT": return new Event(parent); break;
case "VFREEBUSY": return new FreeBusy(parent); break;
case "VJOURNAL": return new Journal(parent); break;
case "VTIMEZONE": return new DDay.iCal.Components.TimeZone(parent); break;
case "VTODO": return new Todo(parent); break;
case "DAYLIGHT":
case "STANDARD":
return new DDay.iCal.Components.TimeZone.TimeZoneInfo(name.ToUpper(), parent); break;
default: return new ComponentBase(parent, name); break;
}
}
示例8: Create
static public ComponentBase Create(iCalObject parent, string name)
{
switch(name.ToUpper())
{
case ALARM: return new Alarm(parent); break;
case EVENT: return new Event(parent); break;
case FREEBUSY: return new FreeBusy(parent); break;
case JOURNAL: return new Journal(parent); break;
case TIMEZONE: return new DDay.iCal.Components.TimeZone(parent); break;
case TODO: return new Todo(parent); break;
case DAYLIGHT:
case STANDARD:
return new DDay.iCal.Components.TimeZone.TimeZoneInfo(name.ToUpper(), parent); break;
default: return new ComponentBase(parent, name); break;
}
}
示例9: component
public ComponentBase component(
iCalObject o
) //throws RecognitionException, TokenStreamException
{
ComponentBase c = null;;
{ // ( ... )+
int _cnt11=0;
for (;;)
{
if ((LA(1)==BEGIN) && (LA(2)==COLON) && (LA(3)==X_NAME))
{
c=x_comp(o);
}
else if ((LA(1)==BEGIN) && (LA(2)==COLON) && (LA(3)==IANA_TOKEN)) {
c=iana_comp(o);
}
else if ((LA(1)==CRLF) && (tokenSet_1_.member(LA(2))) && (tokenSet_2_.member(LA(3)))) {
match(CRLF);
}
else
{
if (_cnt11 >= 1) { goto _loop11_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
}
_cnt11++;
}
_loop11_breakloop: ;
} // ( ... )+
return c;
}
示例10: DeserializeToObject
/// <summary>
/// For iCalendar components, automatically finds and retrieves fields that
/// match the field specified in the <see cref="ContentLine"/>, and sets
/// their value.
/// <example>
/// For example, if a public DTStart field exists in the specified component,
/// (i.e. <c>public Date_Time DTStart;</c>)
/// and a content line of <c>DTSTART;TZID=US-Eastern:20060830T090000</c> is
/// encountered, this method will automatically set the value of the
/// DTStart field to Aug. 30, 2006, 9:00 AM in the US-Eastern TimeZone.
/// </example>
/// <note>
/// It should not be necessary to invoke this method manually as it
/// is handled automatically during the iCalendar parsing.
/// </note>
/// </summary>
/// <param name="cl">The <see cref="ContentLine"/> to process.</param>
/// <param name="obj">The <see cref="iCalObject"/> to assign information to.</param>
static public void DeserializeToObject(ContentLine cl, iCalObject obj)
{
if (cl.Name != null)
{
string name = cl.Name;
Type type = obj.GetType();
// Remove X- from the property name, since
// non-standard properties are named like
// everything else, but also have the NonstandardAttribute
// attached.
if (name.StartsWith("X-"))
name = name.Remove(0, 2);
// Replace invalid characters
name = name.Replace("-", "_");
//
// Find the public field that matches the name of our content line (ignoring case)
//
FieldInfo field = type.GetField(name, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Static);
PropertyInfo property = null;
if (field == null)
property = type.GetProperty(name, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Static);
if (field != null ||
property != null)
{
// Get the field/property's value
object value = field == null ? property.GetValue(obj, null) : field.GetValue(obj);
Type itemType = field == null ? property.PropertyType : field.FieldType;
object[] itemAttributes = field == null ? property.GetCustomAttributes(true) : field.GetCustomAttributes(true);
Type elementType = itemType.IsArray ? itemType.GetElementType() : itemType;
// If it's an iCalDataType, or an array of iCalDataType, then let's fill it!
if (itemType.IsSubclassOf(typeof(iCalDataType)) ||
(itemType.IsArray && itemType.GetElementType().IsSubclassOf(typeof(iCalDataType))))
{
iCalDataType icdt = null;
if (!itemType.IsArray)
icdt = (iCalDataType)value;
if (icdt == null)
icdt = (iCalDataType)Activator.CreateInstance(elementType);
// Assign custom attributes for the specific field
icdt.Attributes = itemAttributes;
// Set the content line for the object.
icdt.ContentLine = cl;
// It's an array, let's add an item to the end
if (itemType.IsArray)
{
ArrayList arr = new ArrayList();
if (value != null)
arr.AddRange((ICollection)value);
arr.Add(icdt);
if (field != null)
field.SetValue(obj, arr.ToArray(elementType));
else
property.SetValue(obj, arr.ToArray(elementType), null);
}
// Otherwise, set the value directly!
else
{
if (field != null)
field.SetValue(obj, icdt);
else property.SetValue(obj, icdt, null);
}
}
else
{
FieldInfo minValue = itemType.GetField("MinValue");
object minVal = (minValue != null) ? minValue.GetValue(null) : null;
if (itemType.IsArray)
{
ArrayList arr = new ArrayList();
if (value != null)
arr.AddRange((ICollection)value);
//.........这里部分代码省略.........
示例11: Copy
virtual public iCalObject Copy(iCalObject parent)
{
iCalObject obj = null;
Type type = GetType();
ConstructorInfo[] constructors = type.GetConstructors();
foreach (ConstructorInfo ci in constructors)
{
// Try to find a constructor with the following signature:
// .ctor(iCalObject parent, string name)
ParameterInfo[] parms = ci.GetParameters();
if (parms.Length == 2 &&
parms[0].ParameterType == typeof(iCalObject) &&
parms[1].ParameterType == typeof(string))
{
obj = ci.Invoke(new object[] { parent, Name }) as iCalObject;
}
}
if (obj == null)
{
foreach (ConstructorInfo ci in constructors)
{
// Try to find a constructor with the following signature:
// .ctor(iCalObject parent)
ParameterInfo[] parms = ci.GetParameters();
if (parms.Length == 1 &&
parms[0].ParameterType == typeof(iCalObject))
{
obj = ci.Invoke(new object[] { parent }) as iCalObject;
}
}
}
// No complex constructor was found, use the default constructor!
if (obj == null)
obj = (iCalObject)Activator.CreateInstance(type);
// Add properties
foreach (Property p in Properties)
p.Copy(obj);
// Add parameters
foreach (Parameter p in Parameters)
p.Copy(obj);
// Add each child
foreach (iCalObject child in Children)
child.Copy(obj);
//
// Get a list of serialized items,
// iterate through each, make a copy
// of each item, and assign it to our
// copied object.
//
List<object> items = SerializedItems;
foreach (object item in items)
{
FieldInfo field = null;
PropertyInfo prop = null;
if (item is FieldInfo)
field = (FieldInfo)item;
else
prop = (PropertyInfo)item;
// Get the item's value
object itemValue = (field == null) ? prop.GetValue(this, null) : field.GetValue(this);
// Make a copy of the item, if it's copyable.
if (itemValue is iCalObject)
itemValue = ((iCalObject)itemValue).Copy(obj);
else { } // FIXME: make an exact copy, if possible.
// Set the item's value in our copied object
if (field == null)
prop.SetValue(obj, itemValue, null);
else field.SetValue(obj, itemValue);
}
return obj;
}
示例12: RemoveChild
/// <summary>
/// Removed an <see cref="iCalObject"/>-based object from the <see cref="Children"/>
/// collection.
/// </summary>
/// <param name="child"></param>
virtual public void RemoveChild(iCalObject child)
{
if (Children.Contains(child))
Children.Remove(child);
}
示例13: Copy
public override iCalObject Copy(iCalObject parent)
{
iCalDataType icdt = (iCalDataType)Activator.CreateInstance(GetType());
icdt.CopyFrom(this);
// Add parameters
foreach (DictionaryEntry de in Parameters)
((Parameter)(de.Value)).Copy(icdt);
icdt.Parent = parent;
return icdt;
}
示例14: param
public void param(
iCalObject o
) //throws RecognitionException, TokenStreamException
{
Parameter p; string n; string v;
n=param_name();
p = new Parameter(o, n);
match(EQUAL);
v=param_value();
p.Values.Add(v);
{ // ( ... )*
for (;;)
{
if ((LA(1)==COMMA))
{
match(COMMA);
v=param_value();
p.Values.Add(v);
}
else
{
goto _loop54_breakloop;
}
}
_loop54_breakloop: ;
} // ( ... )*
}
示例15: contentline
public void contentline(
iCalObject o
) //throws RecognitionException, TokenStreamException
{
ContentLine c = new ContentLine(o);
string n;
string v;
n=name();
c.Name = n;
{ // ( ... )*
for (;;)
{
if ((LA(1)==SEMICOLON))
{
match(SEMICOLON);
{
switch ( LA(1) )
{
case IANA_TOKEN:
{
param(c);
break;
}
case X_NAME:
{
xparam(c);
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
}
else
{
goto _loop50_breakloop;
}
}
_loop50_breakloop: ;
} // ( ... )*
match(COLON);
v=value();
c.Value = v; DDay.iCal.Serialization.iCalendar.Components.ContentLineSerializer.DeserializeToObject(c, o);
match(CRLF);
}