예제 #1
0
        private static void AddMissingOperations(ODataResource entry, IEdmEntityType entityType, SelectedPropertiesNode selectedProperties, IEdmModel model, Func <IEdmType, IEdmOperation[]> getOperations, Func <ODataResourceBase, ODataResourceMetadataBuilder> getEntityMetadataBuilder = null, Func <IEdmStructuredType, bool> typeIsOpen = null)
        {
            var metadataContext = new TestMetadataContext
            {
                GetModelFunc = () => model,
                GetMetadataDocumentUriFunc       = () => new Uri("http://temp.org/$metadata"),
                GetServiceBaseUriFunc            = () => new Uri("http://temp.org/"),
                GetBindableOperationsForTypeFunc = getOperations,
                GetEntityMetadataBuilderFunc     = getEntityMetadataBuilder,
                OperationsBoundToStructuredTypeMustBeContainerQualifiedFunc = typeIsOpen,
            };

            var entryContext               = ODataResourceMetadataContext.Create(entry, new TestFeedAndEntryTypeContext(), /*serializationInfo*/ null, entityType, metadataContext, selectedProperties);
            var generator                  = new ODataMissingOperationGenerator(entryContext, metadataContext);
            List <ODataAction>   actions   = generator.GetComputedActions().ToList();
            List <ODataFunction> functions = generator.GetComputedFunctions().ToList();

            actions.ForEach(entry.AddAction);
            functions.ForEach(entry.AddFunction);
        }