本文整理汇总了C#中IElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.GetType方法的具体用法?C# IElement.GetType怎么用?C# IElement.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddElement
/**
* Adds content to this object.
* @param element
* @throws BadElementException
*/
public void AddElement(IElement element) {
if (cellgroup) {
if (element is SimpleCell) {
if (((SimpleCell)element).Cellgroup) {
throw new BadElementException("You can't add one row to another row.");
}
content.Add(element);
return;
}
else {
throw new BadElementException("You can only add cells to rows, no objects of type " + element.GetType().ToString());
}
}
if (element.Type == Element.PARAGRAPH
|| element.Type == Element.PHRASE
|| element.Type == Element.ANCHOR
|| element.Type == Element.CHUNK
|| element.Type == Element.LIST
|| element.Type == Element.MARKED
|| element.Type == Element.JPEG
|| element.Type == Element.JPEG2000
|| element.Type == Element.JBIG2
|| element.Type == Element.IMGRAW
|| element.Type == Element.IMGTEMPLATE) {
content.Add(element);
}
else {
throw new BadElementException("You can't add an element of type " + element.GetType().ToString() + " to a SimpleCell.");
}
}
示例2: ReflectiveVisit
public void ReflectiveVisit(IElement element)
{
var types = new Type[] { element.GetType() };
var mi = this.GetType().GetMethod("Visit", types);
if (mi != null)
{
mi.Invoke(this, new object[] { element });
}
}
示例3: BindTemplate
public IWebControlTemplate BindTemplate(IElement element, RenderContext renderContext)
{
Type type = element.GetType();
var types = this.GetType().Assembly.GetTypes().Where(t => typeof(IWebControlTemplate).IsAssignableFrom(t));
Type template = types.Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GenericTypeArguments.All(a => a.Equals(type)))).Single(t => typeof(IWebControlTemplate).IsAssignableFrom(t));
var templateInstance = (IWebControlTemplate)Activator.CreateInstance(template, element, renderContext);
var collectionTemplate = templateInstance as IWebControlCollectionTemplate;
if (collectionTemplate != null)
{
var elementContainer = element as IElementContainer;
foreach(IElement childElement in elementContainer.Elements)
{
collectionTemplate.ChildTemplates.Add(BindTemplate(childElement, renderContext));
}
}
return templateInstance;
}
示例4: GetTypeId
/// <summary>
/// Returns the Guid element type id corresponding to <paramref name="elementType"/>. If
/// elementType is not an element type, then Guid.Empty is returned.
/// </summary>
/// <param name="elementType">An element Type.</param>
/// <returns>The unique Guid id corresponding to a type of element, or Guid.Empty.</returns>
public static Guid GetTypeId(IElement element)
{
var elementType = element.GetType();
return GetTypeId(elementType);
}
示例5: AddElement
/**
* Add an element to be rendered in a column.
* Note that you can only add a <CODE>Phrase</CODE>
* or a <CODE>Chunk</CODE> if the columns are
* not all simple. This is an underlying restriction in
* {@link com.lowagie.text.pdf.ColumnText}
*
* @param element element to add
* @throws DocumentException if element can't be added
*/
public void AddElement(IElement element)
{
if (simple) {
columnText.AddElement(element);
} else if (element is Phrase) {
columnText.AddText((Phrase) element);
} else if (element is Chunk) {
columnText.AddText((Chunk) element);
} else {
throw new DocumentException(MessageLocalization.GetComposedMessage("can.t.add.1.to.multicolumntext.with.complex.columns", element.GetType().ToString()));
}
}
示例6: setStatusDisplay
/// <summary>
/// Met en place l'affichage pour un élément
/// </summary>
/// <param name="_item"></param>
/// <param name="_element"></param>
private void setStatusDisplay(ListViewItem _item, IElement _element)
{
Font _itemFont = _item.Font;
// On fait un traitement sépcifique selon le type
if (_element.GetType().Name.Equals("Person"))
{
Person _myPerson = (Person)_element;
if (_myPerson.TypePerson.Equals(Constantes.cstProf)) { _item.Font = new Font(_itemFont, _itemFont.Style | FontStyle.Italic); }
_itemFont = _item.Font;
if (!_myPerson.Absent.Equals(Constantes.cstNon)) { _item.Font = new Font(_itemFont, _itemFont.Style | FontStyle.Strikeout); }
else { _item.Font = new Font(_itemFont, _itemFont.Style & ~FontStyle.Strikeout); }
}
Color _colorItem;
string _free = String.Empty;
string _nbEx = String.Empty;
if (!_element.PoseB && (_element.InfosPDV.NbExemplaires > 0)) { _nbEx = _element.InfosPDV.NbExemplaires.ToString(); }
if (_element.InfosPDV.IsGratis) { _free = Constantes.cstOui; }
if (_element.Passed)
{
_item.SubItems[0].Text = "OK";
_item.UseItemStyleForSubItems = false;
_colorItem = SystemColors.GrayText;
_item.SubItems[4].BackColor = Color.Red;
_item.SubItems[4].Text = "-";
_item.SubItems[5].Text = _free;
_item.SubItems[6].Text = _nbEx;
}
else {
_item.SubItems[0].Text = String.Empty;
_item.UseItemStyleForSubItems = false;
_colorItem = SystemColors.WindowText;
_item.SubItems[4].BackColor = Color.Transparent;
_item.SubItems[4].Text = String.Empty;
_item.SubItems[5].Text = _free;
_item.SubItems[6].Text = _nbEx;
}
if (_element.InfosPDV.Ignore) { _item.Font = new Font(_itemFont, _itemFont.Style | FontStyle.Strikeout); }
for (int i = 0; i <= 3; i++)
{
_item.SubItems[i].ForeColor = _colorItem;
_item.SubItems[i].Font = _item.Font;
}
}
示例7: AddElement
/**
* Add an element to be rendered in a column.
* Note that you can only add a <CODE>Phrase</CODE>
* or a <CODE>Chunk</CODE> if the columns are
* not all simple. This is an underlying restriction in
* {@link com.lowagie.text.pdf.ColumnText}
*
* @param element element to add
* @throws DocumentException if element can't be added
*/
public void AddElement(IElement element)
{
if (simple) {
columnText.AddElement(element);
} else if (element is Phrase) {
columnText.AddText((Phrase) element);
} else if (element is Chunk) {
columnText.AddText((Chunk) element);
} else {
throw new DocumentException("Can't add " + element.GetType().ToString() + " to MultiColumnText with complex columns");
}
}
示例8: ApplyProperties
/// <summary>
/// Applies the provided values to the properties of the provided element.
/// </summary>
/// <param name="element"></param>
/// <param name="propertyValues"></param>
private void ApplyProperties(IElement element, NameValueCollection propertyValues)
{
using (LogGroup logGroup = LogGroup.StartDebug("Applying property values to dynamically loaded element."))
{
if (element == null)
throw new ArgumentNullException("element");
if (propertyValues == null)
throw new ArgumentNullException("propertyValues");
ApplyDataSourceProperty(element);
foreach (string propertyName in propertyValues.Keys)
{
using (LogGroup logGroup2 = LogGroup.StartDebug("Applying property '" + propertyName + "'."))
{
LogWriter.Debug("Value: " + propertyValues[propertyName]);
Type elementType = element.GetType();
LogWriter.Debug("Element type: " + elementType.ToString());
PropertyInfo propertyInfo = elementType.GetProperty(propertyName);
if (propertyInfo == null)
{
LogWriter.Error("Property not found.");
throw new ArgumentException("Can't find property '" + propertyName + "' on type '" + elementType + "'.");
}
if (propertyInfo.CanWrite)
propertyInfo.SetValue(Target, ConvertValue(propertyValues[propertyName], propertyInfo.PropertyType), null);
}
}
}
}
示例9: ApplyDataSourceProperty
private void ApplyDataSourceProperty(IElement element)
{
if (DataSource != null)
{
PropertyInfo property = element.GetType().GetProperty("DataSource");
if (property != null)
{
property.SetValue(element, DataSource, null);
}
}
}