Beispiel #1
0
        public async Task CreateAsync(string inputPath, string outputPath)
        {
            await using var outputStream = ArchiveStream.Create(outputPath);

            var metadata         = new Metadata.Metadata(inputPath);
            var directoryHeaders = await metadata.GenerateDirectoryHeadersAsync();

            var fileHeaders = await metadata.GenerateFileHeadersAsync();

            var archiveInfo = new ArchiveInfo()
            {
                Header              = ArchiveResource.ArchiveHeader,
                IsEncrypted         = Compressor.Settings.IsEncryptEnable,
                NumberOfDirectories = directoryHeaders.Count,
                NumberOfFiles       = fileHeaders.Count,
            };

            archiveInfo.DirectoriesBlockPosition = archiveInfo.SizeOf;
            outputStream.Seek(archiveInfo.SizeOf, SeekOrigin.Current);

            await outputStream.WriteDirectoriesAsync(directoryHeaders);

            archiveInfo.FilesBlockPosition = outputStream.Position;

            await outputStream.WriteArchiveInfoAsync(archiveInfo);

            outputStream.Position = archiveInfo.FilesBlockPosition;

            await Compressor.CompressAsync(fileHeaders, outputStream);
        }
 public ParameterCreator(int position, ParameterAttributes parameterAttributes, string parameterName, Metadata.Metadata type)
 {
     this.position            = position;
     this.parameterAttributes = parameterAttributes;
     Name      = parameterName;
     this.type = type;
 }
Beispiel #3
0
 internal FieldCreator(Metadata.Metadata declaringType, string name, Metadata.Metadata metadata, FieldAttributes fieldAttributes)
 {
     this.DeclaringType   = declaringType;
     this.Name            = name;
     this.type            = metadata;
     this.State           = Metadata.State.NotDefined;
     this.fieldAttributes = fieldAttributes;
 }
 internal GenericParameterCreator(Metadata.Metadata parent, string name)
 {
     Name               = name;
     State              = Metadata.State.NotDefined;
     IsClass            = false;
     IsEnum             = false;
     IsInterface        = false;
     IsGenericParameter = true;
     DeclaringType      = parent;
 }
 /// <summary>
 /// Remove all CustomAttribute
 /// </summary>
 /// <exception cref="System.Exception">Throw when type has been already compile</exception>
 public void RemoveBaseConstraint()
 {
     if (State == Metadata.State.NotDefined)
     {
         typeConstraint = null;
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The type has been partialy compile" : "The type has been compile");
     }
 }
Beispiel #6
0
        public PropertyCreator AddProperty(string name, Metadata.Metadata returnType, PropertyAttributes propertyAttributes)
        {
            if (!VerificationName(name))
            {
                throw new Exception("The name is already taken");
            }
            PropertyCreator property = new PropertyCreator(name, returnType, propertyAttributes);

            properties.Add(property);
            return(property);
        }
Beispiel #7
0
 /// <summary>
 /// Set return type of the method
 /// </summary>
 /// <param name="returnType"> Return type</param>
 public void SetReturnType(Metadata.Metadata returnType)
 {
     if (State == Metadata.State.NotDefined)
     {
         this.returnType = returnType;
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The method has been partialy compile" : "The method has been compile");
     }
 }
Beispiel #8
0
 /// <summary>
 /// Remove return type
 /// </summary>
 public void RemoveReturnType()
 {
     if (State == Metadata.State.NotDefined)
     {
         returnType = null;
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The method has been partialy compile" : "The method has been compile");
     }
 }
 /// <summary>
 /// Set class constraint
 /// </summary>
 /// <param name="type">class used for constraint</param>
 /// <exception cref="System.Exception">Throw when type has been already compile</exception>
 public void SetBaseConstraint(Metadata.Metadata type)
 {
     if (State == Metadata.State.NotDefined)
     {
         if (!type.IsClass)
         {
             throw new Exception(string.Format("The type '{0}' is not an class", type.Name));
         }
         this.typeConstraint = type;
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The type has been partialy compile" : "The type has been compile");
     }
 }
Beispiel #10
0
 /// <summary>
 /// Set the parent of the new type
 /// </summary>
 /// <param name="parent">Parent type</param>
 /// <exception cref="System.Exception"> Throw when parent is not an class</exception>
 /// <exception cref="System.Exception">Throw when type has been already compile</exception>
 public void SetParent(Metadata.Metadata parent)
 {
     if (State == Metadata.State.NotDefined)
     {
         if (!parent.IsClass)
         {
             throw new Exception(string.Format("The type {0} is not an class", parent.Name));
         }
         Parent = parent;
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The type has been partialy compile" : "The type has been compile");
     }
 }
Beispiel #11
0
 /// <summary>
 /// Remove Interfaces to type
 /// </summary>
 /// <param name="interfaces">interfaces to add</param>
 /// <exception cref="System.Exception">Throw when interfaces is not an interfaces</exception>
 /// <exception cref="System.Exception">Throw when type has been already compile</exception>
 public void RemoveInterface(Metadata.Metadata interfaces)
 {
     if (State == Metadata.State.NotDefined)
     {
         if (!interfaces.IsInterface)
         {
             throw new Exception(string.Format("The type {0} is not an interfaces", interfaces.Name));
         }
         this.interfaces.RemoveAll(i => i.Name == interfaces.Name);
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The type has been partialy compile" : "The type has been compile");
     }
 }
Beispiel #12
0
 /// <summary>
 /// Add Field to type
 /// </summary>
 /// <param name="name">name of the field</param>
 /// <param name="returnType">return type of the field</param>
 /// <param name="fieldAttributes"></param>
 /// <returns></returns>
 /// <exception cref="System.Exception">Throw when type has been already compile</exception>
 public FieldCreator AddField(string name, Metadata.Metadata returnType, FieldAttributes fieldAttributes)
 {
     if (State == Metadata.State.NotDefined || State == Metadata.State.BaseDefinition)
     {
         if (!VerificationName(name))
         {
             throw new Exception("The name is already taken");
         }
         FieldCreator fieldCreator = new FieldCreator(this, name, returnType, fieldAttributes);
         fields.Add(fieldCreator);
         return(fieldCreator);
     }
     else
     {
         throw new Exception((State == Metadata.State.AllDefiniton) ? "The type has been partialy compile" : "The type has been compile");
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseViewModel"/> class.
        /// </summary>
        /// <param name="breadcrumbProvider">The breadcrumb provider to replace the default <see cref="BreadcrumbTrailFromConfig"/>.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        protected BaseViewModel(IBreadcrumbProvider breadcrumbProvider)
        {
            if (breadcrumbProvider == null)
            {
                throw new ArgumentNullException(nameof(breadcrumbProvider));
            }

            IsPublicView    = true;
            EsccWebsiteSkin = new CustomerFocusSkin();
            Metadata        = new Metadata.Metadata {
                SiteName     = "East Sussex County Council",
                TitlePattern = "{0} – East Sussex County Council",
                LicenceUri   = new Uri("http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/")
            };
            Metadata.PageImage.ImageUrl        = new Uri("https://www.eastsussex.gov.uk/img/logo-for-facebook.png");
            Metadata.PageImage.AlternativeText = "East Sussex County Council";
            Metadata.Facebook.OpenGraphType    = "article";
            Metadata.Facebook.FacebookAppId    = "169406409819518";
            Metadata.Twitter.TwitterAccount    = "@eastsussexcc";
            BreadcrumbProvider = breadcrumbProvider;
        }
 internal PropertyCreator(string name, Metadata.Metadata returnType, PropertyAttributes propertyAttributes)
 {
     Name                    = name;
     this.returnType         = returnType;
     this.propertyAttributes = propertyAttributes;
 }
Beispiel #15
0
 internal EventCreator(string name, EventAttributes eventAttributes, Metadata.Metadata eventType)
 {
     Name = name;
     this.eventAttributes = eventAttributes;
     this.eventType       = eventType;
 }