/// <summary>Determines whether the Id of this entity is equal to the Id of the other entity.</summary>
 /// <returns>True if the two entities have the same Id.</returns>
 /// <remarks>See <see cref="M:IdentityEquals(BplEntity,object"/> for an explanation of the Id comparison rules.</remarks>
 public static bool IdentityEquals(this BplContextNode entity, BplContextNode otherEntity) {
    if (otherEntity == null) return entity == null;
    if (otherEntity.IsA<BplEntity>()) {
       return entity.IdentityEquals(((BplEntity)otherEntity).Id);
    } else {
       var idProperty = entity.Class.IdentityProperty;
       if (idProperty != null) {
          return IdentityEquals(entity, (BplIdentity)idProperty.GetValue(entity));
       }
    }
    return IdentityEquals(entity, BplIdentity.Empty);
 }
Beispiel #2
0
      // attaches a node to the given context
      private void _attachToContext(BplContextNode node, BplContext context) {
         // check that the node can and needs to be attached to the context
         // assumptions: node and context are not null and node.Context != context
         if (node.Context != null) {
            _verifyContextCompatibility(node.Context, context);
            return;
         }
         if (context.IsA<BplGlobalContext>() && !node.IsA<BplTaxonomy>()) {
            return;
         }

         // attach node to context, and index/seal it as needed
         context.AttachNode(node);

         // recursively attach the node's children
         foreach (var child in node.Children.Where(child => child.Context != context)) {
            _attachToContext(child, context);
         }

         // recursively attach the node's target associations
         if (node.HasTargets) {
            foreach (var target in node.Targets.Where(target => target.Context != context)) {
               _attachToContext(target, context);
            }
         }

         // recursively attach the node's source associations
         if (node.HasSources) {
            foreach (var source in node.Sources.Where(source => BplContext.GetOwner(source) != context)) {
               if (source.IsA<BplContext>()) {
                  _verifyContextCompatibility((BplContext)source, context);
               } else {
                  _attachToContext((BplContextNode)source, context);
               }
            }
         }
      }
 private static BplContextNode _unwrapMessage(BplContextNode node) {
    if (node.IsA<OscarRequestWrapper>()) {
       return ((OscarRequestWrapper)node).Input;
    } else if (node.IsA<OscarResponseWrapper>()) {
       return ((OscarResponseWrapper)node).Output;
    } else if (node.IsA<OscarFailureWrapper>()) {
       return ((OscarFailureWrapper)node).Error;
    }
    return node;
 }