示例#1
0
        private static void EnsureFileMetadataIsValid(IElementDescriptor elementDescriptor, Language language, IUploadedFileMetadata uploadedFileMetadata)
        {
            var constraints = (IBinaryElementConstraints)elementDescriptor.Constraints.For(language);

            if (constraints.MaxFilenameLength < uploadedFileMetadata.FileName.Length)
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new FilenameTooLongError(uploadedFileMetadata.FileName.Length));
            }

            if (constraints.MaxSize < uploadedFileMetadata.FileLength)
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new BinaryTooLargeError(uploadedFileMetadata.FileLength));
            }

            if (constraints is CompositeBitmapImageElementConstraints compositeBitmapImageElementConstraints &&
                uploadedFileMetadata.FileType == FileType.SizeSpecificBitmapImage &&
                compositeBitmapImageElementConstraints.SizeSpecificImageMaxSize < uploadedFileMetadata.FileLength)
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new SizeSpecificImageTooLargeError(uploadedFileMetadata.FileLength));
            }

            var extension = GetDotLessExtension(uploadedFileMetadata.FileName);

            if (!ValidateFileExtension(extension, constraints))
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new BinaryInvalidFormatError(extension));
            }
        }
示例#2
0
 bool MoveToElement(IElementDescriptor element)
 {
     if (element != null)
     {
         _state = new NavigatorState(element);
         return(true);
     }
     return(false);
 }
示例#3
0
 public MultipartUploadSession(Guid sessionId, SessionDescriptor sessionDescriptor, DateTime expiresAt, IElementDescriptor elementDescriptor, string fileKey, string fileName, string uploadId)
 {
     SessionId         = sessionId;
     SessionDescriptor = sessionDescriptor;
     ElementDescriptor = elementDescriptor;
     FileKey           = fileKey;
     FileName          = fileName;
     UploadId          = uploadId;
     SessionExpiresAt  = expiresAt;
 }
 public MultipartUploadSession(
     Guid sessionId,
     SessionDescriptor sessionDescriptor,
     DateTime expiresAt,
     IElementDescriptor elementDescriptor,
     IUploadedFileMetadata uploadedFileMetadata,
     string fileKey,
     string uploadId)
 {
     SessionId            = sessionId;
     SessionDescriptor    = sessionDescriptor;
     ElementDescriptor    = elementDescriptor;
     UploadedFileMetadata = uploadedFileMetadata;
     FileKey          = fileKey;
     UploadId         = uploadId;
     SessionExpiresAt = expiresAt;
 }
示例#5
0
        private static void EnsureFileMetadataIsValid(IElementDescriptor elementDescriptor, long inputStreamLength, Language language, string fileName)
        {
            var constraints = (IBinaryElementConstraints)elementDescriptor.Constraints.For(language);

            if (constraints.MaxFilenameLength < fileName.Length)
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new FilenameTooLongError(fileName.Length));
            }

            if (constraints.MaxSize < inputStreamLength)
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new BinaryTooLargeError(inputStreamLength));
            }

            var extension = GetDotLessExtension(fileName);

            if (!ValidateFileExtension(extension, constraints))
            {
                throw new InvalidBinaryException(elementDescriptor.TemplateCode, new BinaryInvalidFormatError(extension));
            }
        }
 public ObjectElementPersistenceDescriptor(IElementDescriptor elementDescriptor, IObjectElementValue value)
 {
     _elementDescriptor = elementDescriptor;
     Value = value;
 }
示例#7
0
 public ObjectNavigator(IElementDescriptor element)
 {
     _state = new NavigatorState(element);
     _nameTable.Add(element.Name);
 }
示例#8
0
 public NavigatorState(IElementDescriptor element)
 {
     Element  = element;
     NodeType = XPathNodeType.Element;
 }