Search Results for

    Show / Hide Table of Contents

    Class ModelHelper

    Inheritance
    System.Object
    ModelHelper
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Xbim.Common
    Assembly: Xbim.Common.dll
    Syntax
    public class ModelHelper

    Methods

    | Improve this Doc View Source

    Delete(IModel, IPersistEntity, Func<IPersistEntity, Boolean>)

    This will delete the entity from model dictionary and also from any references in the model. Be carefull as this might take a while to check for all occurances of the object. Also make sure you don't use this object anymore yourself because it won't get disposed until than. This operation doesn't guarantee that model is compliant with any kind of schema but it leaves it consistent. So if you serialize the model there won't be any references to the object which wouldn't be there.

    Declaration
    public static void Delete(IModel model, IPersistEntity entity, Func<IPersistEntity, bool> instanceRemoval)
    Parameters
    Type Name Description
    IModel model

    Model from which the entity should be deleted

    IPersistEntity entity

    Entity to be deleted

    System.Func<IPersistEntity, System.Boolean> instanceRemoval

    Delegate to be used to remove entity from instance collection. This should be reversable action within a transaction.

    | Improve this Doc View Source

    Delete(IModel, IPersistEntity[], Action<IPersistEntity[]>)

    This will delete the entity from model dictionary and also from any references in the model. Be carefull as this might take a while to check for all occurances of the object. Also make sure you don't use this object anymore yourself because it won't get disposed until than. This operation doesn't guarantee that model is compliant with any kind of schema but it leaves it consistent. So if you serialize the model there won't be any references to the object which wouldn't be there.

    Declaration
    public static void Delete(IModel model, IPersistEntity[] entities, Action<IPersistEntity[]> instanceRemoval)
    Parameters
    Type Name Description
    IModel model

    Model from which the entity should be deleted

    IPersistEntity[] entities

    Entities to be deleted

    System.Action<IPersistEntity[]> instanceRemoval

    Delegate to be used to remove entity from instance collection. This should be reversable action within a transaction.

    | Improve this Doc View Source

    Expand<IParentEntity, IUniqueEntity>(IModel, Func<IParentEntity, ICollection<IUniqueEntity>>)

    Declaration
    public static void Expand<IParentEntity, IUniqueEntity>(IModel model, Func<IParentEntity, ICollection<IUniqueEntity>> accessor)
        where IParentEntity : IPersistEntity where IUniqueEntity : IPersistEntity
    Parameters
    Type Name Description
    IModel model
    System.Func<IParentEntity, System.Collections.Generic.ICollection<IUniqueEntity>> accessor
    Type Parameters
    Name Description
    IParentEntity
    IUniqueEntity
    | Improve this Doc View Source

    GetStepFileSchemaVersion(Stream)

    Declaration
    public static List<string> GetStepFileSchemaVersion(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream
    Returns
    Type Description
    System.Collections.Generic.List<System.String>
    | Improve this Doc View Source

    InsertCopy<T>(IModel, T, XbimInstanceHandleMap, PropertyTranformDelegate, Boolean, Boolean, Func<Type, Int32, IPersistEntity>)

    Inserts deep copy of an object into this model. The entity must originate from the same schema (the same EntityFactory). This operation happens within a transaction which you have to handle yourself unless you set the parameter "noTransaction" to true. Insert will happen outside of transactional behaviour in that case. Resulting model is not guaranteed to be valid according to any model view definition. However, it is granted to be consistent. You can optionaly bring in all inverse relationships. Be carefull as it might easily bring in almost full model.

    Declaration
    public static T InsertCopy<T>(IModel model, T toCopy, XbimInstanceHandleMap mappings, PropertyTranformDelegate propTransform, bool includeInverses, bool keepLabels, Func<Type, int, IPersistEntity> getLabeledEntity)
        where T : IPersistEntity
    Parameters
    Type Name Description
    IModel model

    Model to be used as a target

    T toCopy

    Entity to be copied

    XbimInstanceHandleMap mappings

    Mappings of previous inserts

    PropertyTranformDelegate propTransform

    Optional delegate which you can use to filter the content which will get coppied over.

    System.Boolean includeInverses

    Option if to bring in all inverse entities (enumerations in original entity)

    System.Boolean keepLabels

    Option if to keep entity labels the same

    System.Func<System.Type, System.Int32, IPersistEntity> getLabeledEntity

    Functor to be used to create entity with specified label

    Returns
    Type Description
    T

    Copy from this model

    Type Parameters
    Name Description
    T

    Type of the copied entity

    | Improve this Doc View Source

    Replace<TEntity, TReplacement>(IModel, TEntity, TReplacement, Func<IPersistEntity, Boolean>)

    This will replace the entity with another entity and will optionally remove it from model dictionary. This will replace all references in the model. Be carefull as this might take a while to check for all occurances of the object.

    Declaration
    public static void Replace<TEntity, TReplacement>(IModel model, TEntity entity, TReplacement replacement, Func<IPersistEntity, bool> instanceRemoval = null)
        where TEntity : IPersistEntity where TReplacement : TEntity
    Parameters
    Type Name Description
    IModel model

    Model from which the entity should be deleted

    TEntity entity

    Entity to be replaces

    TReplacement replacement

    Entity to replace first entity

    System.Func<IPersistEntity, System.Boolean> instanceRemoval

    Optional delegate to be used to remove entity from the instance collection. This should be reversable action within a transaction.

    Type Parameters
    Name Description
    TEntity
    TReplacement
    | Improve this Doc View Source

    WritePartialFile(IModel, IPersistEntity, TextWriter, HashSet<Int32>)

    Writes data island of direct references into the writer

    Declaration
    public static void WritePartialFile(IModel model, IPersistEntity root, TextWriter writer, HashSet<int> written)
    Parameters
    Type Name Description
    IModel model

    Model to be used

    IPersistEntity root

    Entity from the model to be used as the root of data island

    System.IO.TextWriter writer

    Writer to be used

    System.Collections.Generic.HashSet<System.Int32> written

    List of entities written. In case multiple calls to this function are attempted using the same result stream this will make sure that the same entity gets serialized only once.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2022 xbim