DecompilerCore.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Installers Generators » WiX 
WiX » Microsoft » Tools » WindowsInstallerXml » DecompilerCore.cs
//-------------------------------------------------------------------------------------------------
// <copyright file="DecompilerCore.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//    
//    The use and distribution terms for this software are covered by the
//    Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
//    which can be found in the file CPL.TXT at the root of this distribution.
//    By using this software in any fashion, you are agreeing to be bound by
//    the terms of this license.
//    
//    You must not remove this notice, or any other, from this software.
// </copyright>
// 
// <summary>
// The base of the decompiler. Holds some variables used by the decompiler and extensions,
// as well as some utility methods.
// </summary>
//-------------------------------------------------------------------------------------------------

namespace Microsoft.Tools.WindowsInstallerXml{
    using System;
    using System.Collections;

    using Microsoft.Tools.WindowsInstallerXml.Serialize;

    /// <summary>
    /// The base of the decompiler. Holds some variables used by the decompiler and extensions,
    /// as well as some utility methods.
    /// </summary>
    public class DecompilerCore : IMessageHandler
    {
        public const char PrimaryKeyDelimiter = '/';
        public const string PrimaryKeyDelimiterString = "/";

        private Hashtable elements;
        private bool encounteredError;
        private IParentElement rootElement;
        private bool showPedanticMessages;
        private UI uiElement;

        /// <summary>
        /// Instantiate a new decompiler core.
        /// </summary>
        /// <param name="rootElement">The root element of the decompiled database.</param>
        /// <param name="messageHandler">The message handler.</param>
        internal DecompilerCore(IParentElement rootElement, MessageEventHandler messageHandler)
        {
            this.elements = new Hashtable();
            this.MessageHandler = messageHandler;
            this.rootElement = rootElement;
        }

        /// <summary>
        /// Event for messages.
        /// </summary>
        private event MessageEventHandler MessageHandler;

        /// <summary>
        /// Gets whether the decompiler core encoutered an error while processing.
        /// </summary>
        /// <value>Flag if core encountered and error during processing.</value>
        public bool EncounteredError
        {
            get { return this.encounteredError; }
        }

        /// <summary>
        /// Gets the root element of the decompiled output.
        /// </summary>
        /// <value>The root element of the decompiled output.</value>
        public IParentElement RootElement
        {
            get { return this.rootElement; }
        }

        /// <summary>
        /// Gets or sets the option to show pedantic messages.
        /// </summary>
        /// <value>The option to show pedantic messages.</value>
        public bool ShowPedanticMessages
        {
            get { return this.showPedanticMessages; }
            set { this.showPedanticMessages = value; }
        }

        /// <summary>
        /// Gets the UI element.
        /// </summary>
        /// <value>The UI element.</value>
        public UI UIElement
        {
            get
            {
                if (null == this.uiElement)
                {
                    this.uiElement = new UI();
                    this.rootElement.AddChild(this.uiElement);
                }

                return this.uiElement;
            }
        }

        /// <summary>
        /// Convert an Int32 into a DateTime.
        /// </summary>
        /// <param name="value">The Int32 value.</param>
        /// <returns>The DateTime.</returns>
        public static DateTime ConvertIntegerToDateTime(int value)
        {
            int date = value / 65536;
            int time = value % 65536;

            return new DateTime(1980 + (date / 512), (date % 512) / 32, date % 32, time / 2048, (time % 2048) / 32, (time % 32) * 2);
        }

        /// <summary>
        /// Gets the element corresponding to the row it came from.
        /// </summary>
        /// <param name="row">The row corresponding to the element.</param>
        /// <returns>The indexed element.</returns>
        public ISchemaElement GetIndexedElement(Row row)
        {
            return this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(PrimaryKeyDelimiter));
        }

        /// <summary>
        /// Gets the element corresponding to the primary key of the given table.
        /// </summary>
        /// <param name="table">The table corresponding to the element.</param>
        /// <param name="primaryKey">The primary key corresponding to the element.</param>
        /// <returns>The indexed element.</returns>
        public ISchemaElement GetIndexedElement(string table, params string[] primaryKey)
        {
            return (ISchemaElement)this.elements[String.Concat(table, ':', String.Join(PrimaryKeyDelimiterString, primaryKey))];
        }

        /// <summary>
        /// Index an element by its corresponding row.
        /// </summary>
        /// <param name="row">The row corresponding to the element.</param>
        /// <param name="element">The element to index.</param>
        public void IndexElement(Row row, ISchemaElement element)
        {
            this.elements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(PrimaryKeyDelimiter)), element);
        }

        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        public void OnMessage(MessageEventArgs e)
        {
            WixErrorEventArgs errorEventArgs = e as WixErrorEventArgs;

            if (null != errorEventArgs)
            {
                this.encounteredError = true;
            }

            if (null != this.MessageHandler)
            {
                this.MessageHandler(this, e);
                if (MessageLevel.Error == e.Level)
                {
                    this.encounteredError = true;
                }
            }
            else if (null != errorEventArgs)
            {
                throw new WixException(errorEventArgs);
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.