/** * To create a HttpRequest object with required headers set for the * relationship in the $binding. This is used in non-batch mode. * * @param RelatedEnd $binding * @return HttpRequest */ protected function CreateRequestHeaderForBinding($binding) { $sourceResourceBox = null; $this->_context->ObjectToResource->TryGetValue($binding->GetSourceResource(), $sourceResourceBox); $targetResourceBox = null; if ($binding->GetTargetResource() != null) { $this->_context->ObjectToResource->TryGetValue($binding->GetTargetResource(), $targetResourceBox); } if ($sourceResourceBox->Identity == null) { throw new InvalidOperation(Resource::LinkResourceInsertFailure); } if ($targetResourceBox != null && $targetResourceBox->Identity == null) { throw new InvalidOperation(Resource::LinkResourceInsertFailure); } return $this->_context->CreateRequest($this->CreateRequestUri($sourceResourceBox, $binding), $this->GetBindingHttpMethod($binding), false, "application/xml", Resource::DataServiceVersion_1); }
/** *To check current resource is participating in the binding represented by *$related * *@param RelatedEnd $related *@Return bool */ public function IsRelatedEntity($related) { if ($this->_resource->getObjectID() == $related->GetSourceResource()->getObjectID()) { return TRUE; } return FALSE; }
/** * To check the equality of two RelatedEnd instances. * * @param RelatedEnd $relatedEnd1 * @param RelatedEnd $relatedEnd2 * @Return bool if both ends are equal else false */ public static function Equals($relatedEnd1, $relatedEnd2) { $targetObjectID1 = $targetObjectID2 = '00000000-0000-0000-0000-000000000000'; if ($relatedEnd1->GetTargetResource() != null) { $targetObjectID1 = $relatedEnd1->GetTargetResource()->getObjectID(); } if ($relatedEnd2->GetTargetResource() != null) { $targetObjectID2 = $relatedEnd2->GetTargetResource()->getObjectID(); } if ($relatedEnd1->GetSourceResource()->getObjectID() == $relatedEnd2->GetSourceResource()->getObjectID() && $targetObjectID1 == $targetObjectID2 && $relatedEnd1->GetSourceProperty() == $relatedEnd2->GetSourceProperty()) { return TRUE; } return FALSE; }