Show / Hide Table of Contents

Class ElementFactory

Class for generating mutable AML objects

Inheritance
System.Object
ElementFactory
Innovator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Innovator.Client
Assembly: Innovator.Client.dll
Syntax
public class ElementFactory
Remarks

An ElementFactory is used to create AML objects (Items, properties, attributes, and more). A factory is needed to create these objects because the objects need to know how to serialize and deserialize base .Net types (e.g. System.DateTime) according to the time zone and context of a particular server connection. You can get a ElementFactory from a IConnection via the AmlContext property.
Alternatively, if you are processing AML without an Aras connection (e.g. reading an AML export file), you can easily get an ElementFactory in from the Local or the Utc static properties for a factory using either the local or the UTC time zone respectively.

To create an AML structure (that you can easily modify) with an ElementFactory, you can either start with a parameter substituted AML string, or by creating the AML objects directly

var aml = conn.AmlContext;
var query = aml.FromXml(
@"<Item type='Part' action='get'>
  <classification>@0</classification>
  <created_on condition='lt'>@1</created_on>
</Item>", classification, DateTime.Now.AddMinutes(-20)).AssertItem();
query.State().Set("Preliminary");

- OR -

var aml = conn.AmlContext;
var query = aml.Item(aml.Type("Part"), aml.Action("get")
  , aml.Classification(classification)
  , aml.CreatedOn(aml.Condition(Condition.LessThan), DateTime.Now.AddMinutes(-20))
  , aml.Property("state", "Preliminary")
);
return conn.Apply(query.ToAml()).Items();

When used in the second manner, the API should feel very similar to creating LINQ-to-XML objects. However, using ElementFactory should be preferred as, unlike LINQ, it properly serializes base types and handles time zone conversions

var query = new XElement(new XAttribute("type", "Part"), new XAttribute("action", "get")
  , new XElement("classification", classification)
  , new XElement("created_on", new XAttribute("condition", "lt"), DateTime.Now.AddMinutes(-20).ToString("s")
  , new XElement("state", "Preliminary")
);
Examples
var aml = conn.AmlContext;
// --- OR ---
var aml = ElementFactory.Local;

IItem myItem = aml.Item(aml.Type(myType), aml.Action(myAction));
IResult myResult = aml.Result(resultText);
ServerException = aml.ServerException(errorMessage);

Constructors

| Improve this Doc View Source

ElementFactory(IServerContext, IItemFactory)

Initializes a new instance of the ElementFactory class.

Declaration
public ElementFactory(IServerContext context, IItemFactory itemFactory = null)
Parameters
Type Name Description
IServerContext context

The context.

IItemFactory itemFactory

The item factory.

Properties

| Improve this Doc View Source

ItemFactory

Gets the factory for creating strongly-typed items.

Declaration
public IItemFactory ItemFactory { get; }
Property Value
Type Description
IItemFactory

The factory for creating strongly-typed items.

| Improve this Doc View Source

Local

Return an ElementFactory using the local time zone and culture

Declaration
public static ElementFactory Local { get; }
Property Value
Type Description
ElementFactory
| Improve this Doc View Source

LocalizationContext

Context for serializing/deserializing native types (e.g. DateTime, double, boolean, etc.)

Declaration
public IServerContext LocalizationContext { get; }
Property Value
Type Description
IServerContext
| Improve this Doc View Source

Utc

Return an ElementFactory using the UTC time zone and current culture

Declaration
public static ElementFactory Utc { get; }
Property Value
Type Description
ElementFactory

Methods

| Improve this Doc View Source

Action(String)

Create a new action attribute tag

Declaration
public IAttribute Action(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
Remarks

action [String] The name of the Method (or Built in Action Method) to apply to the Item.

| Improve this Doc View Source

Aml(Object[])

Create a new AML tag (for use with the ApplyAML method)

Declaration
public IElement Aml(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IElement
| Improve this Doc View Source

And(Object[])

Create a logical or AML tag used with 'get' queries

Declaration
public ILogical And(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
ILogical
| Improve this Doc View Source

Attribute(String)

Create a new attribute tag with the specified name

Declaration
public IAttribute Attribute(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
IAttribute
| Improve this Doc View Source

Attribute(String, Object)

Create a new attribute tag with the specified name and value

Declaration
public IAttribute Attribute(string name, object value)
Parameters
Type Name Description
System.String name
System.Object value
Returns
Type Description
IAttribute
| Improve this Doc View Source

CalcMd5(SecureToken)

Calculate the MD5 checksum of the securely stored value

Declaration
public string CalcMd5(SecureToken value)
Parameters
Type Name Description
SecureToken value
Returns
Type Description
System.String
| Improve this Doc View Source

CalcMd5(String)

Calculate the MD5 checksum of the string value

Declaration
public string CalcMd5(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
System.String
| Improve this Doc View Source

Classification(Object[])

Create a new classification property

Declaration
public IProperty Classification(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Condition(Condition)

Create a new condition attribute

Declaration
public IAttribute Condition(Condition value)
Parameters
Type Name Description
Condition value
Returns
Type Description
IAttribute
| Improve this Doc View Source

ConfigId(Object[])

Create a new config_id property

Declaration
public IProperty ConfigId(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

CreatedById(Object[])

Create a new created_by_id property

Declaration
public IProperty CreatedById(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

CreatedOn(Object[])

Create a new created_on property

Declaration
public IProperty CreatedOn(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Css(Object[])

Create a new css property

Declaration
public IProperty Css(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

CurrentState(Object[])

Create a new current_state property

Declaration
public IProperty CurrentState(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

DoGetItem(Boolean)

Create a new doGetItem attribute tag

Declaration
public IAttribute DoGetItem(bool value)
Parameters
Type Name Description
System.Boolean value
Returns
Type Description
IAttribute
Remarks

doGetItem [Boolean] If 0 then do not perform a final get action on the Item after the server performed that action as defined by the action attribute. Default is 1.

| Improve this Doc View Source

Element(String, Object[])

Create a generic AML tag given a name and the content

Declaration
public IElement Element(string name, params object[] content)
Parameters
Type Name Description
System.String name

The local name of the element

System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IElement
| Improve this Doc View Source

FormatAml(String, Object[])

Formats an AML string by substituting the @0 style parameters with the arguments specified.

Declaration
public string FormatAml(string format, params object[] args)
Parameters
Type Name Description
System.String format

Query to format

System.Object[] args

Arguments to substitute into the query

Returns
Type Description
System.String
| Improve this Doc View Source

FromXml(Command)

Return a result from a Command

Declaration
public IResult FromXml(Command aml)
Parameters
Type Name Description
Command aml

XML data

Returns
Type Description
IResult
| Improve this Doc View Source

FromXml(Stream)

Return a result from a stream

Declaration
public IResult FromXml(Stream xml)
Parameters
Type Name Description
System.IO.Stream xml

XML data

Returns
Type Description
IResult
| Improve this Doc View Source

FromXml(Stream, Command, IConnection)

Return a result from an AML stream indicating that it is the result of a query performed on a specific connection

Declaration
public IReadOnlyResult FromXml(Stream xml, Command query, IConnection conn)
Parameters
Type Name Description
System.IO.Stream xml

XML data

Command query

The original query which produced the xml response

IConnection conn

The connection which was queried

Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

FromXml(TextReader)

Return a result from an AML text reader

Declaration
public IResult FromXml(TextReader xml)
Parameters
Type Name Description
System.IO.TextReader xml

XML data

Returns
Type Description
IResult
| Improve this Doc View Source

FromXml(String, Command, IConnection)

Return a result from an AML string indicating that it is the result of a query performed on a specific connection

Declaration
public IReadOnlyResult FromXml(string xml, Command query, IConnection conn)
Parameters
Type Name Description
System.String xml

XML data

Command query

The original query which produced the xml response

IConnection conn

The connection which was queried

Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

FromXml(String, Object[])

Return a result from an AML string by substituting the @0 style parameters with the arguments specified.

Declaration
public IResult FromXml(string xml, params object[] args)
Parameters
Type Name Description
System.String xml

Query to format

System.Object[] args

Arguments to substitute into the query

Returns
Type Description
IResult
| Improve this Doc View Source

FromXml(XmlReader)

Return a result from an XML reader

Declaration
public IResult FromXml(XmlReader xml)
Parameters
Type Name Description
System.Xml.XmlReader xml

XML data

Returns
Type Description
IResult
| Improve this Doc View Source

FromXml(XmlReader, Command, String)

Return a result from an XmlReader indicating that it is the result of a query performed on a specific connection

Declaration
public IReadOnlyResult FromXml(XmlReader xml, Command query, string database)
Parameters
Type Name Description
System.Xml.XmlReader xml

XML data

Command query

The original query which produced the xml response

System.String database

The name of the database which was queried

Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

Generation(Object[])

Create a new generation property

Declaration
public IProperty Generation(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Id(Nullable<Guid>)

Create a new where id attribute

Declaration
public IAttribute Id(Guid? value)
Parameters
Type Name Description
System.Nullable<System.Guid> value
Returns
Type Description
IAttribute
| Improve this Doc View Source

Id(String)

Create a new where id attribute

Declaration
public IAttribute Id(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
| Improve this Doc View Source

IdList(String)

Create a new idlist attribute

Declaration
public IAttribute IdList(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
| Improve this Doc View Source

IdProp(Object[])

Create a new id property

Declaration
public IProperty IdProp(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

IsCurrent(Object[])

Create a new is_current property

Declaration
public IProperty IsCurrent(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

IsNull(Boolean)

Create a new is_null attribute

Declaration
public IAttribute IsNull(bool value)
Parameters
Type Name Description
System.Boolean value
Returns
Type Description
IAttribute
| Improve this Doc View Source

IsReleased(Object[])

Create a new is_released property

Declaration
public IProperty IsReleased(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Item(Object[])

Create a new Item AML tag

Declaration
public IItem Item(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IItem
| Improve this Doc View Source

KeyedName(Object[])

Create a new keyed_name property

Declaration
public IProperty KeyedName(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

LockedById(Object[])

Create a new locked_by_id property

Declaration
public IProperty LockedById(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

MajorRev(Object[])

Create a new major_rev property

Declaration
public IProperty MajorRev(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

ManagedById(Object[])

Create a new managed_by_id property

Declaration
public IProperty ManagedById(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

MaxRecords(Int32)

Create a new maxRecords attribute

Declaration
public IAttribute MaxRecords(int value)
Parameters
Type Name Description
System.Int32 value
Returns
Type Description
IAttribute
| Improve this Doc View Source

MinorRev(Object[])

Create a new minor_rev property

Declaration
public IProperty MinorRev(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

ModifiedById(Object[])

Create a new modified_by_id property

Declaration
public IProperty ModifiedById(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

ModifiedOn(Object[])

Create a new modified_on property

Declaration
public IProperty ModifiedOn(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

NewId()

Generate a new GUID id

Declaration
public string NewId()
Returns
Type Description
System.String
| Improve this Doc View Source

NewVersion(Object[])

Create a new new_version property

Declaration
public IProperty NewVersion(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

NoItemsFoundException(String)

Creates a 'No items found' exception

Declaration
public NoItemsFoundException NoItemsFoundException(string message)
Parameters
Type Name Description
System.String message
Returns
Type Description
NoItemsFoundException
| Improve this Doc View Source

NoItemsFoundException(String, Command)

Creates a 'No items found' exception

Declaration
public NoItemsFoundException NoItemsFoundException(string type, Command query)
Parameters
Type Name Description
System.String type

The ItemType name for the item which couldn't be found

Command query

The AML query which didn't return any results

Returns
Type Description
NoItemsFoundException
| Improve this Doc View Source

NoItemsFoundException(String, Exception)

Creates a 'No items found' exception

Declaration
public NoItemsFoundException NoItemsFoundException(string message, Exception innerException)
Parameters
Type Name Description
System.String message
System.Exception innerException
Returns
Type Description
NoItemsFoundException
| Improve this Doc View Source

Not(Object[])

Create a logical not AML tag used with 'get' queries

Declaration
public ILogical Not(params object[] content)
Parameters
Type Name Description
System.Object[] content
Returns
Type Description
ILogical
| Improve this Doc View Source

NotLockable(Object[])

Create a new not_lockable property

Declaration
public IProperty NotLockable(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Or(Object[])

Create a logical or AML tag used with 'get' queries

Declaration
public ILogical Or(params object[] content)
Parameters
Type Name Description
System.Object[] content
Returns
Type Description
ILogical
| Improve this Doc View Source

OrderBy(String)

Create a new orderBy attribute

Declaration
public IAttribute OrderBy(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
| Improve this Doc View Source

OwnedById(Object[])

Create a new owned_by_id property

Declaration
public IProperty OwnedById(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Page(Int32)

Create a new page attribute

Declaration
public IAttribute Page(int value)
Parameters
Type Name Description
System.Int32 value
Returns
Type Description
IAttribute
| Improve this Doc View Source

PageSize(Int32)

Create a new pagesize attribute

Declaration
public IAttribute PageSize(int value)
Parameters
Type Name Description
System.Int32 value
Returns
Type Description
IAttribute
| Improve this Doc View Source

PermissionId(Object[])

Create a new permission_id property

Declaration
public IProperty PermissionId(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Property(String, Object[])

Create a new property tag with the specified name

Declaration
public IProperty Property(string name, params object[] content)
Parameters
Type Name Description
System.String name

Name of the property to create

System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

QueryDate(DateTime)

Create a new queryDate attribute

Declaration
public IAttribute QueryDate(DateTime value)
Parameters
Type Name Description
System.DateTime value
Returns
Type Description
IAttribute
| Improve this Doc View Source

QueryType(QueryType)

Create a new queryType attribute

Declaration
public IAttribute QueryType(QueryType value)
Parameters
Type Name Description
QueryType value
Returns
Type Description
IAttribute
| Improve this Doc View Source

RelatedExpand(Boolean)

Create a new related_expand attribute

Declaration
public IAttribute RelatedExpand(bool value)
Parameters
Type Name Description
System.Boolean value
Returns
Type Description
IAttribute
| Improve this Doc View Source

RelatedId(Object[])

Create a new related_id property

Declaration
public IProperty RelatedId(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Relationships(Object[])

Create a new Relationships tag

Declaration
public IRelationships Relationships(params object[] content)
Parameters
Type Name Description
System.Object[] content
Returns
Type Description
IRelationships
| Improve this Doc View Source

Result(Object[])

Create a new Result AML tag

Declaration
public IResult Result(params object[] content)
Parameters
Type Name Description
System.Object[] content
Returns
Type Description
IResult
| Improve this Doc View Source

Select(SelectNode[])

Create a new select attribute

Declaration
public IAttribute Select(params SelectNode[] properties)
Parameters
Type Name Description
SelectNode[] properties
Returns
Type Description
IAttribute
| Improve this Doc View Source

Select(String)

Create a new select attribute

Declaration
public IAttribute Select(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
| Improve this Doc View Source

ServerEvents(Boolean)

Create a new serverEvents attribute

Declaration
public IAttribute ServerEvents(bool value)
Parameters
Type Name Description
System.Boolean value
Returns
Type Description
IAttribute
| Improve this Doc View Source

ServerException(String)

Create a new server exception

Declaration
public ServerException ServerException(string message)
Parameters
Type Name Description
System.String message
Returns
Type Description
ServerException
| Improve this Doc View Source

ServerException(String, Exception)

Create a new server exception

Declaration
public ServerException ServerException(string message, Exception innerException)
Parameters
Type Name Description
System.String message
System.Exception innerException
Returns
Type Description
ServerException
| Improve this Doc View Source

SourceId(Object[])

Create a new source_id property

Declaration
public IProperty SourceId(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

State(Object[])

Create a new state property

Declaration
public IProperty State(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

TeamId(Object[])

Create a new team_id property

Declaration
public IProperty TeamId(params object[] content)
Parameters
Type Name Description
System.Object[] content

The initial content of the elment (attributes, elements, or values)

Returns
Type Description
IProperty
| Improve this Doc View Source

Type(String)

Create a new type attribute

Declaration
public IAttribute Type(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
Remarks

type [String] The ItemType name for which the Item is an instance.

| Improve this Doc View Source

TypeId(String)

Create a new typeId attribute

Declaration
public IAttribute TypeId(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
| Improve this Doc View Source

ValidationException(String, IReadOnlyItem, String)

Create a new validation exception

Declaration
public ValidationReportException ValidationException(string message, IReadOnlyItem item, string report)
Parameters
Type Name Description
System.String message

Exception message

IReadOnlyItem item

Item being validated

System.String report

HTML report to present to the user

Returns
Type Description
ValidationReportException
| Improve this Doc View Source

ValidationException(String, IReadOnlyItem, String[])

Create a new validation exception

Declaration
public ValidationException ValidationException(string message, IReadOnlyItem item, params string[] properties)
Parameters
Type Name Description
System.String message

Exception message

IReadOnlyItem item

Item being validated

System.String[] properties

Properties with errors

Returns
Type Description
ValidationException
| Improve this Doc View Source

ValidationException(String, Exception, IReadOnlyItem, String)

Create a new validation exception

Declaration
public ValidationReportException ValidationException(string message, Exception innerException, IReadOnlyItem item, string report)
Parameters
Type Name Description
System.String message

Exception message

System.Exception innerException

Inner exception

IReadOnlyItem item

Item being validated

System.String report

HTML report to present to the user

Returns
Type Description
ValidationReportException
| Improve this Doc View Source

ValidationException(String, Exception, IReadOnlyItem, String[])

Create a new validation exception

Declaration
public ValidationException ValidationException(string message, Exception innerException, IReadOnlyItem item, params string[] properties)
Parameters
Type Name Description
System.String message

Exception message

System.Exception innerException

Inner exception

IReadOnlyItem item

Item being validated

System.String[] properties

Properties with errors

Returns
Type Description
ValidationException
| Improve this Doc View Source

Where(String)

Create a new where attribute

Declaration
public IAttribute Where(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
IAttribute
Remarks

where [String] Used instead of the id attribute to specify the WHERE clause for the search criteria. Include the table name with the column name using the dot notation: where="[user].first_name like 'Tom%'"

  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX