Example #1
0
        private string InternalGetStreamETag(object entity, DataServiceOperationContext operationContext)
        {
            if (DataServiceStreamProvider.GetPostWriteStreamETagOverride != null && GetWriteStreamCalled == true)
            {
                return(DataServiceStreamProvider.GetPostWriteStreamETagOverride(entity, operationContext));
            }
            else if (DataServiceStreamProvider.GetStreamETagOverride != null)
            {
                return(DataServiceStreamProvider.GetStreamETagOverride(entity, operationContext));
            }

            return(null);
        }
Example #2
0
 public Uri GetReadStreamUri(object entity, DataServiceOperationContext operationContext)
 {
     this.ThrowIfDisposed();
     CallOrderLog += "-GetReadStreamUri";
     ValidateArguments(entity, operationContext);
     if (DataServiceStreamProvider.GetReadStreamUriOverride != null)
     {
         return(DataServiceStreamProvider.GetReadStreamUriOverride(entity, operationContext));
     }
     else
     {
         return(GetReadStreamUri(entity));
     }
 }
Example #3
0
 public string GetStreamContentType(object entity, DataServiceOperationContext operationContext)
 {
     this.ThrowIfDisposed();
     CallOrderLog += "-GetStreamContentType";
     ValidateArguments(entity, operationContext);
     if (DataServiceStreamProvider.GetStreamContentTypeOverride != null)
     {
         return(DataServiceStreamProvider.GetStreamContentTypeOverride(entity, operationContext));
     }
     else
     {
         return(GetContentType(entity));
     }
 }
Example #4
0
        public string ResolveType(string entitySetName, DataServiceOperationContext operationContext)
        {
            // This code is required by a test verifying that we can call GetQueryStringItem in an stream provider method.
            var forceErrorValue = operationContext.GetQueryStringValue("Query-String-Header-Force-Error");

            if (forceErrorValue == "yes")
            {
                throw new DataServiceException(418, "User code threw a Query-String-Header-Force-Error exception.");
            }

            this.ThrowIfDisposed();
            CallOrderLog += "-ResolveType";
            if (DataServiceStreamProvider.ResolveTypeOverride != null)
            {
                return(DataServiceStreamProvider.ResolveTypeOverride(entitySetName, operationContext));
            }

            return(operationContext.RequestHeaders["CustomRequestHeader_ItemType"]);
        }
Example #5
0
        public static void PopulateData()
        {
            ClearData();

            // populate data here...
            Item i = new Item()
            {
                ID          = NextItemID++,
                Description = "Default Item0",
                Name        = "Item0",
            };

            _items.Add(i);

            Photo p = new Photo()
            {
                ID          = NextItemID++,
                Description = "Default Photo1",
                Name        = "Photo1",
                Rating      = 3,
            };

            _items.Add(p);

            DerivedFromPhoto p2 = new DerivedFromPhoto()
            {
                ID          = NextItemID++,
                Description = "Derived Photo2",
                Name        = "Photo2",
                Rating      = 3,
            };

            _items.Add(p2);

            DerivedFromPhoto p3 = new DerivedFromPhoto()
            {
                ID          = NextItemID++,
                Description = "A Derived Photo3",
                Name        = "A Photo2",
                Rating      = 3,
            };

            _items.Add(p3);


            DataServiceStreamProvider.Init();

            using (Stream s = File.OpenWrite(DataServiceStreamProvider.GetStoragePath(p)))
            {
                byte[] buffer = new byte[] { 1, 2, 3, 4 };
                s.Write(buffer, 0, 4);
                s.Close();
            }

            Folder f = new Folder()
            {
                ID   = NextFolderID++,
                Name = "Folder1"
            };

            f.Items.Add(i);
            i.ParentFolder = f;
            f.Icon         = p;
            i.Icon         = p;

            f.Items.Add(p);
            p.ParentFolder = f;
            p.Icon         = p;

            f.Items.Add(p2);
            p2.ParentFolder = f;
            p2.Icon         = p;
            _folders.Add(f);

            Folder f1 = new Folder()
            {
                ID   = NextFolderID++,
                Name = "A Folder2"
            };

            f1.Items.Add(p3);
            p3.ParentFolder = f1;
            f1.Icon         = p;
            p3.Icon         = p3;
        }