Show / Hide Table of Contents

Class ItemExtensions

Various extension methods pertaining to various AML interfaces

Inheritance
System.Object
ItemExtensions
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 static class ItemExtensions

Methods

| Improve this Doc View Source

Add(IElement, Object[])

Add multiple elements to an IElement at the same time

Declaration
public static IElement Add(this IElement elem, params object[] content)
Parameters
Type Name Description
IElement elem
System.Object[] content
Returns
Type Description
IElement
| Improve this Doc View Source

Apply(IReadOnlyItem, IConnection)

Apply this item in the database

Declaration
public static IReadOnlyResult Apply(this IReadOnlyItem item, IConnection conn)
Parameters
Type Name Description
IReadOnlyItem item
IConnection conn
Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

ApplyAsync(IReadOnlyItem, IAsyncConnection)

Get the result of executing the specified AML query

Declaration
public static IPromise<IReadOnlyResult> ApplyAsync(this IReadOnlyItem item, IAsyncConnection conn)
Parameters
Type Name Description
IReadOnlyItem item

AML query to apply

IAsyncConnection conn

Connection to execute the query on

Returns
Type Description
IPromise<IReadOnlyResult>

A read-only result

| Improve this Doc View Source

ApplyAsync(IReadOnlyItem, IAsyncConnection, CancellationToken)

Get the result of executing the specified AML query

Declaration
public static IPromise<IReadOnlyResult> ApplyAsync(this IReadOnlyItem item, IAsyncConnection conn, CancellationToken ct)
Parameters
Type Name Description
IReadOnlyItem item

AML query to apply

IAsyncConnection conn

Connection to execute the query on

System.Threading.CancellationToken ct

A System.Threading.CancellationToken used to cancel the asynchronous operation

Returns
Type Description
IPromise<IReadOnlyResult>

A read-only result

| Improve this Doc View Source

AsClrValue(IReadOnlyProperty_Base, Property)

Return the value of a property parsed into the appropriate CLR type

Declaration
public static object AsClrValue(this IReadOnlyProperty_Base prop, Property meta)
Parameters
Type Name Description
IReadOnlyProperty_Base prop
Property meta
Returns
Type Description
System.Object
| Improve this Doc View Source

AsDateRange(Range<DateOffset>, IServerContext)

Given a range of dynamic date offsets (e.g. 3 days ago to today) and a sever context giving a current date, calculate the corresponding static date range

Declaration
public static Range<DateTime> AsDateRange(this Range<DateOffset> range, IServerContext context)
Parameters
Type Name Description
Range<DateOffset> range
IServerContext context
Returns
Type Description
Range<System.DateTime>
| Improve this Doc View Source

AsDateRange(Range<DateOffset>, DateTimeOffset)

Given a range of dynamic date offsets (e.g. 3 days ago to today) and a specific date for "today", calculate the corresponding static date range

Declaration
public static Range<DateTime> AsDateRange(this Range<DateOffset> range, DateTimeOffset todaysDate)
Parameters
Type Name Description
Range<DateOffset> range
System.DateTimeOffset todaysDate
Returns
Type Description
Range<System.DateTime>
| Improve this Doc View Source

AsFile(IReadOnlyProperty, IConnection)

Download the file represented by the property

Declaration
public static Stream AsFile(this IReadOnlyProperty prop, IConnection conn)
Parameters
Type Name Description
IReadOnlyProperty prop
IConnection conn
Returns
Type Description
System.IO.Stream

This will return the file contents for item properties of type 'File' and image properties that point to vault files

| Improve this Doc View Source

AsFile(IReadOnlyProperty, IConnection, Boolean)

Asynchronously download the file represented by the property

Declaration
public static IPromise<Stream> AsFile(this IReadOnlyProperty prop, IConnection conn, bool async)
Parameters
Type Name Description
IReadOnlyProperty prop
IConnection conn
System.Boolean async
Returns
Type Description
IPromise<System.IO.Stream>

This will return the file contents for item properties of type 'File' and image properties that point to vault files

| Improve this Doc View Source

AsModel<T>(IReadOnlyProperty_Item<T>)

Return an item cast as the specified type if that type of item can be derived from the property value. Otherwise, an exception is thrown

Declaration
public static T AsModel<T>(this IReadOnlyProperty_Item<T> prop)where T : IReadOnlyItem
Parameters
Type Name Description
IReadOnlyProperty_Item<T> prop
Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

AsResult(IReadOnlyItem)

Convert an item to a result object so that it can be more easily returned from a server method

Declaration
public static IReadOnlyResult AsResult(this IReadOnlyItem item)
Parameters
Type Name Description
IReadOnlyItem item
Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

AssertItem<T>(IReadOnlyResult)

Return a single item cast as the specified type. If that is not possible, throw an appropriate exception (e.g. the exception returned by the server where possible)

Declaration
public static T AssertItem<T>(this IReadOnlyResult result)where T : IReadOnlyItem
Parameters
Type Name Description
IReadOnlyResult result
Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

ClassStartsWith(IReadOnlyItem, String[])

Determine if the classification of the item starts with one of the specified root paths

Declaration
public static bool ClassStartsWith(this IReadOnlyItem item, params string[] roots)
Parameters
Type Name Description
IReadOnlyItem item
System.String[] roots
Returns
Type Description
System.Boolean
| Improve this Doc View Source

CreateReader(IReadOnlyElement)

Create an System.Xml.XmlReader for reading the XML contents of elem

Declaration
public static XmlReader CreateReader(this IReadOnlyElement elem)
Parameters
Type Name Description
IReadOnlyElement elem
Returns
Type Description
System.Xml.XmlReader
Examples
var xml = XElement.Load(item.CreateReader());

Note, this approach should be more performant than first generating a string (e.g. with ToAml(IAmlNode, AmlWriterSettings) and then parsing the string)

| Improve this Doc View Source

CreateReader(IReadOnlyResult)

Create an System.Xml.XmlReader for reading the XML contents of elem

Declaration
public static XmlReader CreateReader(this IReadOnlyResult elem)
Parameters
Type Name Description
IReadOnlyResult elem
Returns
Type Description
System.Xml.XmlReader
Examples
var xml = XElement.Load(result.CreateReader());

Note, this approach should be more performant than first generating a string (e.g. with ToAml(IAmlNode, AmlWriterSettings) and then parsing the string)

| Improve this Doc View Source

Edit(IItemRef, IConnection, Object[])

Send an AML edit query to the database with the body of the <Item /> tag being the contents specified

Declaration
public static IReadOnlyResult Edit(this IItemRef item, IConnection conn, params object[] contents)
Parameters
Type Name Description
IItemRef item

Item to edit

IConnection conn

Connection to use for applying the edit

System.Object[] contents

Body of the <Item action='edit' /> tag

Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

Element(IReadOnlyElement, String)

Returns either first element from the parent with a local name of name or a 'null' element (where Exists is false) if there are no elements

Declaration
public static IReadOnlyElement Element(this IReadOnlyElement element, string name)
Parameters
Type Name Description
IReadOnlyElement element

Parent element to search through

System.String name

Name of the element to find

Returns
Type Description
IReadOnlyElement
| Improve this Doc View Source

FetchLockStatus(IItemRef, IConnection)

Retrieve the lock status from the database

Declaration
public static LockStatusType FetchLockStatus(this IItemRef item, IConnection conn)
Parameters
Type Name Description
IItemRef item

Item to check the lock status of

IConnection conn

Connection to use for executing this query

Returns
Type Description
LockStatusType
Remarks

If the item is editable, the locked_by_id property will be updated

| Improve this Doc View Source

FirstOrNullElement(IEnumerable<IElement>)

Returns either the first element from the enumerable or a 'null' element (where Exists is false) if there are no elements

Declaration
public static IElement FirstOrNullElement(this IEnumerable<IElement> elements)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<IElement> elements

Elements to search through

Returns
Type Description
IElement
| Improve this Doc View Source

FirstOrNullItem<T>(IEnumerable<T>)

Returns either the first item from the enumerable or a 'null' item (where Exists is false) if there are no items

Declaration
public static T FirstOrNullItem<T>(this IEnumerable<T> items)where T : IReadOnlyItem
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> items

Items to search through

Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

FirstOrNullItem<T>(IEnumerable<T>, Func<T, Boolean>)

Returns either the first matching item from the enumerable or a 'null' item (where Exists is false) if there are no items which match the predicate

Declaration
public static T FirstOrNullItem<T>(this IEnumerable<T> items, Func<T, bool> predicate)where T : IReadOnlyItem
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> items

Items to search through

System.Func<T, System.Boolean> predicate

Criteria to match

Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

HasValue(IReadOnlyAttribute)

Indicates that the attribute is neither null nor empty

Declaration
public static bool HasValue(this IReadOnlyAttribute attr)
Parameters
Type Name Description
IReadOnlyAttribute attr
Returns
Type Description
System.Boolean
| Improve this Doc View Source

HasValue(IReadOnlyProperty_Base)

Indicates that the property is neither null nor empty

Declaration
public static bool HasValue(this IReadOnlyProperty_Base prop)
Parameters
Type Name Description
IReadOnlyProperty_Base prop
Returns
Type Description
System.Boolean
Remarks

If the property is empty but has is_null='0', then this will return true

| Improve this Doc View Source

InnerText(IReadOnlyElement)

Gets the XML inner text of the element

Declaration
public static string InnerText(this IReadOnlyElement elem)
Parameters
Type Name Description
IReadOnlyElement elem

The element to retrieve text for.

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

ItemMax(IReadOnlyResult)

Returns the total number of items founds including those returned on other pages

Declaration
public static int ItemMax(this IReadOnlyResult result)
Parameters
Type Name Description
IReadOnlyResult result
Returns
Type Description
System.Int32
| Improve this Doc View Source

ItemsWithNoAccessCount(IReadOnlyResult)

Returns the number of matching items which the user does not have access to see

Declaration
public static int ? ItemsWithNoAccessCount(this IReadOnlyResult result)
Parameters
Type Name Description
IReadOnlyResult result
Returns
Type Description
System.Nullable<System.Int32>
| Improve this Doc View Source

ItemsWithNoAccessCount(NoItemsFoundException)

Returns the number of matching items which the user does not have access to see

Declaration
public static int ? ItemsWithNoAccessCount(this NoItemsFoundException ex)
Parameters
Type Name Description
NoItemsFoundException ex
Returns
Type Description
System.Nullable<System.Int32>
| Improve this Doc View Source

LazyMap<T>(IReadOnlyItem, IConnection, Func<IReadOnlyItem, T>)

Maps an item to a new object. If there are properties which couldn't be found during the initial mapping, the method will query the database and run the mapper again with the database results

Declaration
public static T LazyMap<T>(this IReadOnlyItem item, IConnection conn, Func<IReadOnlyItem, T> mapper)
Parameters
Type Name Description
IReadOnlyItem item

Item to map

IConnection conn

Connection used for querying the database when property values are not available

System.Func<IReadOnlyItem, T> mapper

Function which creates a new object by referencing values from the item

Returns
Type Description
T
Type Parameters
Name Description
T
Examples
var result = item.LazyMap(conn, i => new
{
  FirstName = i.CreatedById().AsItem().Property("first_name").Value,
  PermName = i.PermissionId().AsItem().Property("name").Value,
  KeyedName = i.Property("id").KeyedName().Value,
  Empty = i.OwnedById().Value
});
| Improve this Doc View Source

Lock(IItemRef, IConnection)

Lock an item

Declaration
public static void Lock(this IItemRef item, IConnection conn)
Parameters
Type Name Description
IItemRef item
IConnection conn
| Improve this Doc View Source

LockStatus(IReadOnlyItem, IConnection)

Determine the lock status of an item based on the data loaded into memory.

Declaration
public static LockStatusType LockStatus(this IReadOnlyItem item, IConnection conn)
Parameters
Type Name Description
IReadOnlyItem item

Item to check the status of

IConnection conn

Connection containing the ID of the current user

Returns
Type Description
LockStatusType
Remarks

A call will not be made to the database

| Improve this Doc View Source

Now(IServerContext)

Return the system time expressed in the timezone of the server

Declaration
public static DateTimeOffset Now(this IServerContext context)
Parameters
Type Name Description
IServerContext context
Returns
Type Description
System.DateTimeOffset
| Improve this Doc View Source

Parents(IReadOnlyElement)

Return the list of all parents of the element, elem

Declaration
public static IEnumerable<IReadOnlyElement> Parents(this IReadOnlyElement elem)
Parameters
Type Name Description
IReadOnlyElement elem
Returns
Type Description
System.Collections.Generic.IEnumerable<IReadOnlyElement>

The first element is the direct parent of elem

| Improve this Doc View Source

ParentsAndSelf(IReadOnlyElement)

Return a list consisting of elem and all of its parents

Declaration
public static IEnumerable<IReadOnlyElement> ParentsAndSelf(this IReadOnlyElement elem)
Parameters
Type Name Description
IReadOnlyElement elem

Element to start the search with

Returns
Type Description
System.Collections.Generic.IEnumerable<IReadOnlyElement>

The list starts with the element (if it exists), followed by its parent, and so on

| Improve this Doc View Source

Path(Activity, IConnection, String)

Retrieve the Workflow Process Path by name

Declaration
public static IReadOnlyItem Path(this Activity act, IConnection conn, string name)
Parameters
Type Name Description
Activity act
IConnection conn
System.String name
Returns
Type Description
IReadOnlyItem
| Improve this Doc View Source

PerformVote(Activity, IConnection, String, String, String)

Perform a vote for a specified assignment and path

Declaration
public static IReadOnlyResult PerformVote(this Activity act, IConnection conn, string assignmentId, string pathName, string comment = null)
Parameters
Type Name Description
Activity act
IConnection conn
System.String assignmentId
System.String pathName
System.String comment
Returns
Type Description
IReadOnlyResult
| Improve this Doc View Source

Promote(IItemRef, IConnection, String, String)

Promote the itme to the specified state

Declaration
public static IReadOnlyResult Promote(this IItemRef item, IConnection conn, string state, string comments = null)
Parameters
Type Name Description
IItemRef item

Item to promote

IConnection conn

Connection to execute the promotion on

System.String state

New state of the item

System.String comments

Comments to include with the promotion

Returns
Type Description
IReadOnlyResult
Examples
// Promote the item. Throw an exception if an error occurs.
comp.Promote(conn, "Released").AssertNoError();
| Improve this Doc View Source

Property(ILogical, String, String)

Returns a reference to the property with the specified name and language

Declaration
public static IProperty Property(this ILogical logical, string name, string lang = null)
Parameters
Type Name Description
ILogical logical

Logical element to return a property for

System.String name

Name of the property

System.String lang

Language of the (multilingual) property

Returns
Type Description
IProperty
  • If the property exists, a valid IReadOnlyProperty will be returned
  • If the property does not exists, a "null" IReadOnlyProperty will be returned where Exists = false
| Improve this Doc View Source

Property(IReadOnlyLogical, String, String)

Returns a reference to the property with the specified name and language

Declaration
public static IReadOnlyProperty Property(this IReadOnlyLogical logical, string name, string lang = null)
Parameters
Type Name Description
IReadOnlyLogical logical

Logical element to return a property for

System.String name

Name of the property

System.String lang

Language of the (multilingual) property

Returns
Type Description
IReadOnlyProperty
  • If the property exists, a valid IReadOnlyProperty will be returned
  • If the property does not exists, a "null" IReadOnlyProperty will be returned where Exists = false
| Improve this Doc View Source

RelatedModel<T>(IRelationship<T>)

Return an item cast as the specified type if that type of item can be derived from the property value. Otherwise, an exception is thrown

Declaration
public static T RelatedModel<T>(this IRelationship<T> item)where T : IReadOnlyItem
Parameters
Type Name Description
IRelationship<T> item
Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

SetDurationByDate(Activity, IConnection, DateTime, Int32, Int32)

Set the duration of a workflow activity act so that it will be due on dueDate

Declaration
public static void SetDurationByDate(this Activity act, IConnection conn, DateTime dueDate, int minDuration = 1, int maxDuration = 2147483647)
Parameters
Type Name Description
Activity act
IConnection conn
System.DateTime dueDate
System.Int32 minDuration
System.Int32 maxDuration
| Improve this Doc View Source

SetIsAuto(Activity, IConnection, Boolean)

Set the activity act to be an automatic activity

Declaration
public static void SetIsAuto(this Activity act, IConnection conn, bool isAuto)
Parameters
Type Name Description
Activity act
IConnection conn
System.Boolean isAuto
| Improve this Doc View Source

SourceModel<T>(INullRelationship<T>)

Return an item cast as the specified type if that type of item can be derived from the property value. Otherwise, an exception is thrown

Declaration
public static T SourceModel<T>(this INullRelationship<T> item)where T : IReadOnlyItem
Parameters
Type Name Description
INullRelationship<T> item
Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

ToAml(IAmlNode, AmlWriterSettings)

Converts an AML node into an AML string

Declaration
public static string ToAml(this IAmlNode node, AmlWriterSettings settings = null)
Parameters
Type Name Description
IAmlNode node
AmlWriterSettings settings
Returns
Type Description
System.String
| Improve this Doc View Source

ToAml(IAmlNode, XmlWriter)

Converts an AML node into an AML string

Declaration
public static void ToAml(this IAmlNode node, XmlWriter writer)
Parameters
Type Name Description
IAmlNode node
System.Xml.XmlWriter writer
| Improve this Doc View Source

ToNormalizedAml(Command, ElementFactory)

Perform parameter substitutions and return the resulting AML

Declaration
public static string ToNormalizedAml(this Command cmd, ElementFactory factory)
Parameters
Type Name Description
Command cmd
ElementFactory factory
Returns
Type Description
System.String
| Improve this Doc View Source

ToXml(IAmlNode)

Renders an AML node to XML

Declaration
public static XElement ToXml(this IAmlNode node)
Parameters
Type Name Description
IAmlNode node
Returns
Type Description
System.Xml.Linq.XElement
| Improve this Doc View Source

Unlock(IItemRef, IConnection)

Unlock an item

Declaration
public static void Unlock(this IItemRef item, IConnection conn)
Parameters
Type Name Description
IItemRef item
IConnection conn
  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX