Esempio n. 1
0
		public void Ctor0_Deny_Unrestricted ()
		{
			Triplet t = new Triplet ();
			Assert.IsNull (t.First, "First");
			Assert.IsNull (t.Second, "Second");
			Assert.IsNull (t.Third, "Third");
		}
Esempio n. 2
0
		public void Ctor3_Deny_Unrestricted ()
		{
			Triplet t = new Triplet (String.Empty, String.Empty, String.Empty);
			Assert.IsNotNull (t.First, "First");
			Assert.IsNotNull (t.Second, "Second");
			Assert.IsNotNull (t.Third, "Third");
		}
Esempio n. 3
0
		protected override object SaveViewState ()
		{
			if (tabData != null) {
				Triplet t = new Triplet (tabData, localValues, titles);
				return new Pair (base.SaveViewState (), t);
			}
			return null;
		}
        /// <devdoc>
        ///     To be supplied.
        /// </devdoc>
        public override void Save()
        {
            bool   requiresControlStateInSession = false;
            object clientData = null;

            Triplet vsTrip = ViewState as Triplet;

            // no session view state to store.
            if ((ControlState != null) ||
                ((vsTrip == null || vsTrip.Second != null || vsTrip.Third != null) && ViewState != null))
            {
                HttpSessionState session = Page.Session;

                string sessionViewStateID = Convert.ToString(DateTime.Now.Ticks, 16);

                object state = null;
                requiresControlStateInSession = Page.Request.Browser.RequiresControlStateInSession;
                if (requiresControlStateInSession)
                {
                    // ClientState will just be sessionID
                    state      = new Pair(ViewState, ControlState);
                    clientData = sessionViewStateID;
                }
                else
                {
                    // ClientState will be a <sessionID, ControlState>
                    state      = ViewState;
                    clientData = new Pair(sessionViewStateID, ControlState);
                }

                string sessionKey = _viewStateSessionKey + sessionViewStateID;
                session[sessionKey] = state;

                Queue queue = session[_viewStateQueueKey] as Queue;

                if (queue == null)
                {
                    queue = new Queue();
                    session[_viewStateQueueKey] = queue;
                }
                queue.Enqueue(sessionKey);

                SessionPageStateSection cfg = RuntimeConfig.GetConfig(Page.Request.Context).SessionPageState;
                int queueCount = queue.Count;

                if (cfg != null && queueCount > cfg.HistorySize ||
                    cfg == null && queueCount > SessionPageStateSection.DefaultHistorySize)
                {
                    string oldSessionKey = (string)queue.Dequeue();
                    session.Remove(oldSessionKey);
                }
            }

            if (clientData != null)
            {
                Page.ClientState = Util.SerializeWithAssert(StateFormatter2, new Pair(requiresControlStateInSession, clientData), Purpose.WebForms_SessionPageStatePersister_ClientState);
            }
        }
Esempio n. 5
0
            protected override object Read(byte token, BinaryReader r, ReaderContext ctx)
            {
                Triplet t = new Triplet();

                t.First  = ReadObject(r, ctx);
                t.Second = ReadObject(r, ctx);
                t.Third  = ReadObject(r, ctx);
                return(t);
            }
Esempio n. 6
0
            protected override void Write(BinaryWriter w, object o, WriterContext ctx)
            {
                Triplet t = (Triplet)o;

                w.Write(PrimaryId);
                WriteObject(w, t.First, ctx);
                WriteObject(w, t.Second, ctx);
                WriteObject(w, t.Third, ctx);
            }
        public virtual string Serialize(AntiForgeryData token) {
            if (token == null) {
                throw new ArgumentNullException("token");
            }

            Triplet objToSerialize = new Triplet() {
                First = token.Salt,
                Second = token.Value,
                Third = token.CreationDate
            };

            string serializedValue = Formatter.Serialize(objToSerialize);
            return serializedValue;
        }
Esempio n. 8
0
        public override void Save()
        {
            bool    x         = false;
            object  y         = null;
            Triplet viewState = base.ViewState as Triplet;

            if ((base.ControlState != null) || ((((viewState == null) || (viewState.Second != null)) || (viewState.Third != null)) && (base.ViewState != null)))
            {
                HttpSessionState session = base.Page.Session;
                string           str     = Convert.ToString(DateTime.Now.Ticks, 0x10);
                object           obj3    = null;
                x = base.Page.Request.Browser.RequiresControlStateInSession;
                if (x)
                {
                    obj3 = new Pair(base.ViewState, base.ControlState);
                    y    = str;
                }
                else
                {
                    obj3 = base.ViewState;
                    y    = new Pair(str, base.ControlState);
                }
                string str2 = "__SESSIONVIEWSTATE" + str;
                session[str2] = obj3;
                Queue queue = session["__VIEWSTATEQUEUE"] as Queue;
                if (queue == null)
                {
                    queue = new Queue();
                    session["__VIEWSTATEQUEUE"] = queue;
                }
                queue.Enqueue(str2);
                SessionPageStateSection sessionPageState = RuntimeConfig.GetConfig(base.Page.Request.Context).SessionPageState;
                int count = queue.Count;
                if (((sessionPageState != null) && (count > sessionPageState.HistorySize)) || ((sessionPageState == null) && (count > 9)))
                {
                    string name = (string)queue.Dequeue();
                    session.Remove(name);
                }
            }
            if (y != null)
            {
                base.Page.ClientState = Util.SerializeWithAssert(base.StateFormatter, new Pair(x, y));
            }
        }
Esempio n. 9
0
        /// <devdoc>
        ///     Recursively serializes value into the writer.
        /// </devdoc>
        private void SerializeValue(TextWriter output, object value)
        {
            if (value == null)
            {
                return;
            }

            // First determine the type... either typeless (string), array,
            // typed array, hashtable, pair, triplet, knowntype, typetable reference, or
            // type...
            //

            // serialize string...
            //
            if (value is string)
            {
                WriteEscapedString(output, (string)value);
            }

            // serialize Int32...
            //
            else if (value is Int32)
            {
                output.Write('i');
                output.Write(leftAngleBracketChar);
                output.Write(((Int32)value).ToString(NumberFormat));
                output.Write(rightAngleBracketChar);
            }
            else if (value is Boolean)
            {
                output.Write('o');
                output.Write(leftAngleBracketChar);
                output.Write(((bool)value) ? 't' : 'f');
                output.Write(rightAngleBracketChar);
            }

            // serialize arraylist...
            //
            else if (value is ArrayList)
            {
                output.Write('l');
                output.Write(leftAngleBracketChar);

                ArrayList ar = (ArrayList)value;
                int       c  = ar.Count;
                for (int i = 0; i < c; i++)
                {
                    SerializeValue(output, ar[i]);
                    output.Write(valueDelimiterChar);
                }
                output.Write(rightAngleBracketChar);
            }

            // serialize hashtable...
            //
            else if (value is Hashtable)
            {
                output.Write('h');
                output.Write(leftAngleBracketChar);

                Hashtable table = (Hashtable)value;

                IDictionaryEnumerator e = table.GetEnumerator();
                while (e.MoveNext())
                {
                    SerializeValue(output, e.Key);
                    output.Write(valueDelimiterChar);

                    SerializeValue(output, e.Value);
                    output.Write(valueDelimiterChar);
                }
                output.Write(rightAngleBracketChar);
            }

            else
            {
                // we'll need the Type object for the last two possibilities
                Type valueType = value.GetType();
                Type strtype   = typeof(string);

                // serialize Pair
                if (valueType == typeof(Pair))
                {
                    Pair p = (Pair)value;
                    output.Write('p');
                    output.Write(leftAngleBracketChar);

                    SerializeValue(output, p.First);
                    output.Write(valueDelimiterChar);
                    SerializeValue(output, p.Second);
                    output.Write(rightAngleBracketChar);
                }

                // serialize Triplet
                //
                else if (valueType == typeof(Triplet))
                {
                    Triplet t = (Triplet)value;
                    output.Write('t');
                    output.Write(leftAngleBracketChar);

                    SerializeValue(output, t.First);
                    output.Write(valueDelimiterChar);
                    SerializeValue(output, t.Second);
                    output.Write(valueDelimiterChar);
                    SerializeValue(output, t.Third);
                    output.Write(rightAngleBracketChar);
                }

                // serialize array...
                //
                else if (valueType.IsArray)
                {
                    Type underlyingValueType;
                    underlyingValueType = valueType.GetElementType();

                    output.Write('@');

                    if (underlyingValueType != strtype)
                    {
                        // write type of array before elements
                        int typeId = GetTypeId(underlyingValueType);
                        WriteTypeId(output, typeId, underlyingValueType);

                        output.Write(leftAngleBracketChar);
                        Array ar = (Array)value;
                        for (int i = 0; i < ar.Length; i++)
                        {
                            SerializeValue(output, ar.GetValue(i));
                            output.Write(valueDelimiterChar);
                        }
                    }
                    else
                    {
                        // optimization: since we know the underlying values are strings,
                        // we can skip the recursive call to SerializeValue
                        output.Write(leftAngleBracketChar);
                        string[] ar = (string[])value;
                        for (int i = 0; i < ar.Length; i++)
                        {
                            WriteEscapedString(output, ar[i]);
                            output.Write(valueDelimiterChar);
                        }
                    }
                    output.Write(rightAngleBracketChar);
                }

                // serialize other value...
                //
                else
                {
                    int typeId = GetTypeId(valueType);

                    // get the type converter
                    TypeConverter tc = TypeDescriptor.GetConverter(valueType);

                    bool toString;
                    bool fromString;
                    if (tc == null || tc is ReferenceConverter)
                    {
                        toString   = false;
                        fromString = false;
                    }
                    else
                    {
                        toString   = tc.CanConvertTo(strtype);
                        fromString = tc.CanConvertFrom(strtype);
                    }

                    if (toString && fromString)
                    {
                        //we can convert to and from a string
                        WriteTypeId(output, typeId, valueType);

                        output.Write(leftAngleBracketChar);
                        WriteEscapedString(output, tc.ConvertToInvariantString(null, value));
                    }
                    else
                    {
                        // the typeconverter failed us, so we are resorting to binary serialization
                        MemoryStream ms = new MemoryStream();
                        System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        try {
                            formatter.Serialize(ms, value);
                        }
                        catch (SerializationException) {
                            throw new HttpException(SR.GetString(SR.NonSerializableType, value.GetType().FullName));
                        }

                        output.Write('b');
                        output.Write(leftAngleBracketChar);

                        // Since base64 doesn't have any chars that we escape, we can
                        // skip WriteEscapedString
                        output.Write(Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length));
                    }
                    output.Write(rightAngleBracketChar);
                }
            }
        }
Esempio n. 10
0
        /// <devdoc>
        ///     Deserializes a value from tokens, starting at current. When this
        ///     function returns, current will be left at the next token.
        ///
        ///     This function is recursive.
        /// </devdoc>
        private object DeserializeValueInternal()
        {
            // Determine the data type... possible combinations are:
            //
            //   @<...>     == array of strings
            //   @T<...>    == array of (typeref T)
            //   b<...>     == base64 encoded value
            //   h<...>     == hashtable
            //   l<...>     == arraylist
            //   p<...>     == pair
            //   t<...>     == triplet
            //   i<...>     == int
            //   o<t/f>     == boolean true/false
            //   T<...>     == (typeref T)
            //   ...        == string
            //

            object value = null;

            string token = ConsumeOneToken();

            if (_current >= _deserializationData.Length || _deserializationData[_current] != leftAngleBracketChar)
            {
                // just a string - next token is not a left angle bracket
                // we can shortcut here and just return the string
                //_current++; //consume right angle bracket or delimiter
                return(token);
            }

            _current++; // consume left angle bracket

            // otherwise, we have typeref followed by value
            if (token.Length == 1)
            {
                // simple type we recognize
                char ch = token[0];
                if (ch == 'p')
                {
                    Pair p = new Pair();

                    if (_deserializationData[_current] != valueDelimiterChar)
                    {
                        p.First = DeserializeValueInternal();
                    }
                    _current++; // consume delimeter
                    if (_deserializationData[_current] != rightAngleBracketChar)
                    {
                        p.Second = DeserializeValueInternal();
                    }
                    value = p;
                }
                else if (ch == 't')
                {
                    Triplet t = new Triplet();

                    if (_deserializationData[_current] != valueDelimiterChar)
                    {
                        t.First = DeserializeValueInternal();
                    }
                    _current++; // consume delimeter
                    if (_deserializationData[_current] != valueDelimiterChar)
                    {
                        t.Second = DeserializeValueInternal();
                    }
                    _current++; // consume delimeter
                    if (_deserializationData[_current] != rightAngleBracketChar)
                    {
                        t.Third = DeserializeValueInternal();
                    }
                    value = t;
                }

                // Parse int32...
                else if (ch == 'i')
                {
                    value = Int32.Parse(ConsumeOneToken(), NumberFormat);
                }

                else if (ch == 'o')
                {
                    value = _deserializationData[_current] == 't';
                    _current++;  // consume t or f
                }

                // Parse arrayList...
                //
                else if (ch == 'l')
                {
                    ArrayList data = new ArrayList();

                    while (_deserializationData[_current] != rightAngleBracketChar)
                    {
                        object itemValue = null;
                        if (_deserializationData[_current] != valueDelimiterChar)
                        {
                            itemValue = DeserializeValueInternal();
                        }
                        data.Add(itemValue);
                        _current++; //consume the delimiter
                    }

                    value = data;
                }
                else if (ch == '@')
                {
                    // if we're here, length == 1 so this is a string array
                    value = ConsumeStringArray();
                }

                // Parse hashtable...
                //
                else if (ch == 'h')
                {
                    Hashtable data = new Hashtable();

                    while (_deserializationData[_current] != rightAngleBracketChar)
                    {
                        object key;
                        key = DeserializeValueInternal(); // hashtable key cannot be null

                        _current++;                       // consume delimiter
                        if (_deserializationData[_current] != valueDelimiterChar)
                        {
                            data[key] = DeserializeValueInternal();
                        }
                        else
                        {
                            data[key] = null;
                        }

                        _current++; // consume delimiter
                    }

                    value = data;
                }

                // base64 encoded...
                //
                else if (ch == 'b')
                {
                    string text = ConsumeOneToken();
                    byte[] serializedData;
                    serializedData = Convert.FromBase64String(text);

                    if (!String.IsNullOrEmpty(serializedData))
                    {
                        System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        value = formatter.Deserialize(new MemoryStream(serializedData));
                    }
                }

                // Parse typeconverter value ...
                //
                else
                {
                    // we have a typeref which is only one character long
                    value = ConsumeTypeConverterValue(token);
                }
            }
            else
            {
                // length > 1

                // Parse array...
                //
                if (token[0] == '@')
                {
                    // if we're here, length > 1 so we must have a type ref after the @
                    Type creatableType = TypeFromTypeRef(token.Substring(1));
                    value = ConsumeArray(creatableType);
                }

                // Parse typeconverter value ...
                //
                else
                {
                    // we have a typeref which is more than one character long
                    value = ConsumeTypeConverterValue(token);
                }
            }

            _current++; //consume right angle bracket
            return(value);
        }
Esempio n. 11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="nsAccount"></param>
        /// <param name="nsEmail"></param>
        /// <param name="nsPassword"></param>
        /// <returns></returns>
        public Triplet getDataCenterUrls(String nsAccount, String nsEmail, String nsPassword)
        {
            try
            { 
                // Preset Values
                string sysURL = "https://rest.netsuite.com/rest/roles";
                Triplet urls = new Triplet();

                HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(sysURL);

                // 'nlauth_account' should NOT be specified for this type of request otherwise an error is returned.
                // Issue 238527
                httpWebRequest.Headers.Add("Authorization",
                                           "NLAuth nlauth_email=" + nsEmail + "," +
                                           "nlauth_signature=" + nsPassword);

                // set content type
                httpWebRequest.ContentType = "application/json";

                // execute http GET
                WebResponse webResponse = httpWebRequest.GetResponse();
                Stream httpBody = webResponse.GetResponseStream();

                string jsonContent = "";
                int i = 0;

                StreamReader streamReader = new StreamReader(httpBody);

                while (jsonContent != null)
                {
                    i++;
                    jsonContent = streamReader.ReadLine();
                    Stream mainContent = streamReader.BaseStream;

                    if (jsonContent != null)
                    {

                        // convert json content to bytes
                        byte[] bytesJsonContent = Encoding.Unicode.GetBytes(jsonContent);

                        // convert the json to an xml format so that xpath can be used to locate specific
                        // nodes & attributes
                        XmlDictionaryReader xmlReader = JsonReaderWriterFactory.CreateJsonReader(bytesJsonContent, new XmlDictionaryReaderQuotas());

                        // this returns the top-level element of the xml document;
                        // all of the following xpath statements are executed off of this element
                        XElement root = XElement.Load(xmlReader);

                        //Linq Query
                        IEnumerable<XElement> restDomains =
                        from c in root.Elements("item")
                        where (string)c.Element("account").Element("internalId").Value == nsAccount
                        select c;


                        // Outputs Data Center URLs for the specified account
                        if (restDomains != null)
                        {
                            foreach (XElement elementFromLinq in restDomains)
                            {
                                string accountIntId = elementFromLinq.Element("account").Element("internalId").Value;
                                string accountName = elementFromLinq.Element("account").Element("name").Value;
                                //Console.WriteLine("Data Center URLs for " + accountIntId + " " + accountName);
                                //Console.WriteLine("-----------------------");
                                //Console.WriteLine("Role: " + elementFromLinq.Element("role").Element("name").Value);
                                //Console.WriteLine("Rest Domain: " + elementFromLinq.Element("dataCenterURLs").Element("restDomain").Value);
                                //Console.WriteLine("System Domain: " + elementFromLinq.Element("dataCenterURLs").Element("systemDomain").Value);
                                //Console.WriteLine("Web Services Domain: " + elementFromLinq.Element("dataCenterURLs").Element("webservicesDomain").Value);
                                //Console.WriteLine(" ");
                                urls.First = elementFromLinq.Element("dataCenterURLs").Element("webservicesDomain").Value;   //webservicesDomain
                                urls.Second = elementFromLinq.Element("dataCenterURLs").Element("systemDomain").Value;  //systemDomain
                                urls.Third = elementFromLinq.Element("dataCenterURLs").Element("restDomain").Value;  //restDomain
                                break;
                            }
                        }

                        //Console.Write("Number of Roles for this Account: " + restDomains.Count());
                        //if (restDomains != null)
                        //{
                        //    Console.WriteLine("Roles");
                        //    Console.WriteLine("-----------------------");
                        //    foreach (XElement elementFromLinq in restDomains)
                        //    {
                        //        Console.WriteLine(elementFromLinq.Element("role").Element("name").Value);
                        //    }
                        //}
                    }
                }
                return urls;
            }
            catch(Exception ex)
            {
                return null;
            }
        }
Esempio n. 12
0
        protected static object buildObjectElement(XmlElement xmlElement)
        {
            String type = xmlElement.Name;
            if (type == "System.Web.UI.Pair")
            {
                Pair pair = new Pair();
                pair.First = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(0));
                pair.Second = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(1));
                return pair;
            }
            else if (type == "System.Web.UI.Triplet")
            {
                Triplet triplet = new Triplet();
                triplet.First = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(0));
                triplet.Second = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(1));
                triplet.Third = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(2));
                return triplet;
            }
            else if (type == "System.Collections.ArrayList")
            {
                ArrayList arrayList = new ArrayList();
                foreach (XmlElement innerXmlElement in xmlElement)
                {
                    arrayList.Add(buildObjectElement(innerXmlElement));
                }
                return arrayList;
            }
            else if (type == "System.Array")
            {
                object[] array = new object[xmlElement.ChildNodes.Count];
                for (int i = 0; i < xmlElement.ChildNodes.Count; i++)
                {
                    array[i] = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(i));
                }
                return array;
            }
            else if (type == "System.Collections.Hashtable")
            {
                Hashtable hashTable = new Hashtable();
                return hashTable; // this needs to be fixed...I don't know what the child elements are

            }
            else if (type == "System.Collections.Specialized.HybridDictionary")
            {
                HybridDictionary hybridDictionary = new HybridDictionary();
                foreach (XmlElement innerXmlElement in xmlElement)
                {
                    DictionaryEntry dictionaryEntry = (DictionaryEntry)buildObjectElement((XmlElement)innerXmlElement);
                    hybridDictionary.Add(dictionaryEntry.Key, dictionaryEntry.Value);
                }
                return hybridDictionary;
            }
            /*else if (type == "System.Collections.IDictionary")
            {
                IDictionary iDictionary = new IDictionary();
                return iDictionary; // hmmm...not quite sure if we will ever see an IDicionary itself since it is an interface
            }*/

            else if (type == "System.Collections.DictionaryEntry")
            {
                DictionaryEntry dictionaryEnry = new DictionaryEntry();
                dictionaryEnry.Key = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(0));
                dictionaryEnry.Value = buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(1));
                return dictionaryEnry;
            }
            else if (type == "System.String")
            {
                return xmlElement.InnerText;
            }
            else if (type == "System.Web.UI.IndexedString")
            {
                return new IndexedString(xmlElement.InnerText);
            }
            else if (type == "System.Int32")
            {
                return Int32.Parse(xmlElement.InnerText);
            }
            else if (type == "System.Int16")
            {
                return Int16.Parse(xmlElement.InnerText);
            }
            else if (type == "System.Boolean")
            {
                if (xmlElement.InnerText == "True")
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else if (type == "System.Drawing.Color")
            {
                int a = (Int32)buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(0));
                int r = (Int32)buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(1));
                int g = (Int32)buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(2));
                int b = (Int32)buildObjectElement((XmlElement)xmlElement.ChildNodes.Item(3));
                Color color = Color.FromArgb(a, r, g, b);
                return color;
            }
            else if (type == "Null" && xmlElement.InnerText == "True")
            {
                return null;
            }
            else
            {
                //there are likely other objects we might see in practice, but I haven't seen how they are serialized...this section will have to be update as new types are identified.
                return null;
            }
        }
Esempio n. 13
0
        /// <devdoc>
        ///     Deserializes a value from tokens, starting at current. When this
        ///     function returns, current will be left at the next token.
        ///
        ///     This function is recursive.
        /// </devdoc>
        private object DeserializeValueInternal() {
            // Determine the data type... possible combinations are:
            //
            //   @<...>     == array of strings
            //   @T<...>    == array of (typeref T)
            //   b<...>     == base64 encoded value
            //   h<...>     == hashtable
            //   l<...>     == arraylist
            //   p<...>     == pair
            //   t<...>     == triplet
            //   i<...>     == int
            //   o<t/f>     == boolean true/false
            //   T<...>     == (typeref T)
            //   ...        == string 
            //

            object value = null;

            string token = ConsumeOneToken();

            if (_current >= _deserializationData.Length || _deserializationData[_current] != leftAngleBracketChar) {
                // just a string - next token is not a left angle bracket
                // we can shortcut here and just return the string
                //_current++; //consume right angle bracket or delimiter
                return token;
            }

            _current++; // consume left angle bracket

            // otherwise, we have typeref followed by value
            if (token.Length == 1) {
                // simple type we recognize
                char ch = token[0];
                if (ch == 'p') {
                    Pair p = new Pair();

                    if (_deserializationData[_current] != valueDelimiterChar) {
                        p.First = DeserializeValueInternal();
                    }
                    _current++; // consume delimeter
                    if (_deserializationData[_current] != rightAngleBracketChar) {
                        p.Second = DeserializeValueInternal();
                    }
                    value = p;
                }
                else if (ch == 't') {
                    Triplet t = new Triplet();

                    if (_deserializationData[_current] != valueDelimiterChar) {
                        t.First = DeserializeValueInternal();
                    }
                    _current++; // consume delimeter
                    if (_deserializationData[_current] != valueDelimiterChar) {
                        t.Second = DeserializeValueInternal();
                    }
                    _current++; // consume delimeter
                    if (_deserializationData[_current] != rightAngleBracketChar) {
                        t.Third = DeserializeValueInternal();
                    }
                    value = t;
                }
                    
                // Parse int32...
                else if (ch == 'i') {
                    value = Int32.Parse(ConsumeOneToken(), NumberFormat);
                }

                else if (ch == 'o') {
                    value = _deserializationData[_current] == 't'; 
                    _current++;  // consume t or f
                }

                // Parse arrayList...
                //
                else if (ch == 'l') {
                    ArrayList data = new ArrayList();

                    while (_deserializationData[_current] != rightAngleBracketChar) {
                        object itemValue = null;
                        if (_deserializationData[_current] != valueDelimiterChar) {
                            itemValue = DeserializeValueInternal();
                        }
                        data.Add(itemValue);
                        _current++; //consume the delimiter
                    }

                    value = data;
                }
                else if (ch == '@') {
                    // if we're here, length == 1 so this is a string array
                    value = ConsumeStringArray();
                }

                // Parse hashtable...
                //
                else if (ch == 'h') {
                    Hashtable data = new Hashtable();

                    while (_deserializationData[_current] != rightAngleBracketChar) {
                        object key;
                        key = DeserializeValueInternal();   // hashtable key cannot be null

                        _current++; // consume delimiter
                        if (_deserializationData[_current] != valueDelimiterChar) {
                            data[key] = DeserializeValueInternal();
                        }
                        else {
                            data[key] = null;
                        }

                        _current++; // consume delimiter
                    }

                    value = data;
                }

                // base64 encoded...
                //
                else if (ch == 'b') {
                    string text = ConsumeOneToken();
                    byte[] serializedData;
                    serializedData = Convert.FromBase64String(text);

                    if (!String.IsNullOrEmpty(serializedData)) {
                        System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        value = formatter.Deserialize(new MemoryStream(serializedData));
                    }
                }

                // Parse typeconverter value ...
                //
                else {
                    // we have a typeref which is only one character long
                    value = ConsumeTypeConverterValue(token);
                }

                
            }
            else {
                // length > 1

                // Parse array...
                //
                if (token[0] == '@') {
                    // if we're here, length > 1 so we must have a type ref after the @
                    Type creatableType = TypeFromTypeRef(token.Substring(1));
                    value = ConsumeArray(creatableType);
                }

                // Parse typeconverter value ...
                //
                else {
                    // we have a typeref which is more than one character long
                    value = ConsumeTypeConverterValue(token);
                }
            }

            _current++; //consume right angle bracket
            return value;
        }
		object IStateManager.SaveViewState ()
		{
			object[] state = null;
			bool hasData = false;
			Type[] knownTypes = GetKnownTypes ();
			
			if (saveEverything) {
				state = new object [items.Count + 1];
				state [0] = true;
				for (int n=0; n<items.Count; n++)
				{
					IStateManager item = (IStateManager) items [n];
					int oi = Array.IndexOf (originalItems, item);
					object ns = item.SaveViewState ();
					if (ns != null) hasData = true;
					
					if (oi == -1) {
						Type t = item.GetType ();
						int idx = knownTypes == null ? -1 : Array.IndexOf (knownTypes, t);
						if (idx != -1)
							state [n + 1] = new Triplet (oi, ns, idx);
						else
							state [n + 1] = new Triplet (oi, ns, t);
					}
					else
						state [n + 1] = new Pair (oi, ns);
				}
			} else {
				ArrayList list = new ArrayList ();
				for (int n=0; n<items.Count; n++) {
					IStateManager item = (IStateManager) items [n];
					object ns = item.SaveViewState ();
					if (ns != null) {
						hasData = true;
						list.Add (new Pair (n, ns));
					}
				}
				if (hasData) {
					list.Insert (0, false);
					state = list.ToArray ();
				}
			}
			
			if (hasData)
				return state;
			else
				return null;
		}
 /// <summary>
 /// Saves the current view state of the <see cref="ImageLayer" /> object.
 /// </summary>
 /// <param name="saveAll"><c>true</c> if all values should be saved regardless
 /// of whether they are dirty; otherwise <c>false</c>.</param>
 /// <returns>An object that represents the saved state. The default is <c>null</c>.</returns>
 protected override object SaveViewState(bool saveAll)
 {
     Triplet triplet = new Triplet();
     triplet.First = base.SaveViewState(saveAll);
     if (_source != null)
         triplet.Second = ((IStateManagedObject)_source).SaveViewState(saveAll);
     if (_camera != null)
         triplet.Third = ((IStateManagedObject)_camera).SaveViewState(saveAll);
     return (triplet.First == null && triplet.Second == null && triplet.Third == null) ? null : triplet;
 }
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            Stream manifestResourceStream = null;
            try
            {
                string str = context.Request.QueryString["d"];
                if (string.IsNullOrEmpty(str))
                {
                    throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_InvalidRequest"));
                }
                string str2 = Page.DecryptString(str);
                int index = str2.IndexOf('|');
                string str3 = str2.Substring(0, index);
                if (string.IsNullOrEmpty(str3))
                {
                    throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_AssemblyNotFound", new object[] { str3 }));
                }
                string webResource = str2.Substring(index + 1);
                if (string.IsNullOrEmpty(webResource))
                {
                    throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_ResourceNotFound", new object[] { webResource }));
                }
                char ch = str3[0];
                str3 = str3.Substring(1);
                Assembly assembly = null;
                switch (ch)
                {
                    case 's':
                        assembly = typeof(AssemblyResourceLoader).Assembly;
                        break;

                    case 'p':
                        assembly = Assembly.Load(str3);
                        break;

                    case 'f':
                    {
                        string[] strArray = str3.Split(new char[] { ',' });
                        if (strArray.Length != 4)
                        {
                            throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_InvalidRequest"));
                        }
                        AssemblyName assemblyRef = new AssemblyName {
                            Name = strArray[0],
                            Version = new Version(strArray[1])
                        };
                        string name = strArray[2];
                        if (name.Length > 0)
                        {
                            assemblyRef.CultureInfo = new CultureInfo(name);
                        }
                        else
                        {
                            assemblyRef.CultureInfo = CultureInfo.InvariantCulture;
                        }
                        string str6 = strArray[3];
                        byte[] publicKeyToken = new byte[str6.Length / 2];
                        for (int i = 0; i < publicKeyToken.Length; i++)
                        {
                            publicKeyToken[i] = byte.Parse(str6.Substring(i * 2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                        }
                        assemblyRef.SetPublicKeyToken(publicKeyToken);
                        assembly = Assembly.Load(assemblyRef);
                        break;
                    }
                    default:
                        throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_InvalidRequest"));
                }
                if (assembly == null)
                {
                    throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_InvalidRequest"));
                }
                bool third = false;
                bool first = false;
                string second = string.Empty;
                int num3 = HashCodeCombiner.CombineHashCodes(assembly.GetHashCode(), webResource.GetHashCode());
                Triplet triplet = (Triplet) _webResourceCache[num3];
                if (triplet != null)
                {
                    first = (bool) triplet.First;
                    second = (string) triplet.Second;
                    third = (bool) triplet.Third;
                }
                else
                {
                    WebResourceAttribute attribute = FindWebResourceAttribute(assembly, webResource);
                    if (attribute != null)
                    {
                        webResource = attribute.WebResource;
                        first = true;
                        second = attribute.ContentType;
                        third = attribute.PerformSubstitution;
                    }
                    try
                    {
                        if (first)
                        {
                            first = false;
                            manifestResourceStream = assembly.GetManifestResourceStream(webResource);
                            first = manifestResourceStream != null;
                        }
                    }
                    finally
                    {
                        Triplet triplet2 = new Triplet {
                            First = first,
                            Second = second,
                            Third = third
                        };
                        _webResourceCache[num3] = triplet2;
                    }
                }
                if (first)
                {
                    HttpCachePolicy cache = context.Response.Cache;
                    cache.SetCacheability(HttpCacheability.Public);
                    cache.VaryByParams["d"] = true;
                    cache.SetOmitVaryStar(true);
                    cache.SetExpires(DateTime.Now + TimeSpan.FromDays(365.0));
                    cache.SetValidUntilExpires(true);
                    Pair assemblyInfo = GetAssemblyInfo(assembly);
                    cache.SetLastModified(new DateTime((long) assemblyInfo.Second));
                    StreamReader reader = null;
                    try
                    {
                        if (manifestResourceStream == null)
                        {
                            manifestResourceStream = assembly.GetManifestResourceStream(webResource);
                        }
                        if (manifestResourceStream != null)
                        {
                            context.Response.ContentType = second;
                            if (third)
                            {
                                reader = new StreamReader(manifestResourceStream, true);
                                string input = reader.ReadToEnd();
                                MatchCollection matchs = webResourceRegex.Matches(input);
                                int startIndex = 0;
                                StringBuilder builder = new StringBuilder();
                                foreach (Match match in matchs)
                                {
                                    builder.Append(input.Substring(startIndex, match.Index - startIndex));
                                    Group group = match.Groups["resourceName"];
                                    if (group != null)
                                    {
                                        string a = group.ToString();
                                        if (a.Length > 0)
                                        {
                                            if (string.Equals(a, webResource, StringComparison.Ordinal))
                                            {
                                                throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_NoCircularReferences", new object[] { webResource }));
                                            }
                                            builder.Append(GetWebResourceUrlInternal(assembly, a, false, true, null));
                                        }
                                    }
                                    startIndex = match.Index + match.Length;
                                }
                                builder.Append(input.Substring(startIndex, input.Length - startIndex));
                                StreamWriter writer = new StreamWriter(context.Response.OutputStream, reader.CurrentEncoding);
                                writer.Write(builder.ToString());
                                writer.Flush();
                            }
                            else
                            {
                                byte[] buffer = new byte[0x400];
                                Stream outputStream = context.Response.OutputStream;
                                int count = 1;
                                while (count > 0)
                                {
                                    count = manifestResourceStream.Read(buffer, 0, 0x400);
                                    outputStream.Write(buffer, 0, count);
                                }
                                outputStream.Flush();
                            }
                        }
                    }
                    finally
                    {
                        if (reader != null)
                        {
                            reader.Close();
                        }
                        if (manifestResourceStream != null)
                        {
                            manifestResourceStream.Close();
                        }
                    }
                }
            }
            catch
            {
                manifestResourceStream = null;
            }
            if (manifestResourceStream == null)
            {
                throw new HttpException(0x194, System.Web.SR.GetString("AssemblyResourceLoader_InvalidRequest"));
            }
            context.Response.IgnoreFurtherWrites();
        }
Esempio n. 17
0
        /// <devdoc>
        ///     Saves the view state for the control.
        /// </devdoc>
        protected override object SaveViewState() {
            object baseState = base.SaveViewState();
            object inputState = null;
            object labelState = null;
            object myState = null;

            if (_inputAttributesState != null) {
                inputState = _inputAttributesState.SaveViewState();
            }
            if (_labelAttributesState != null) {
                labelState = _labelAttributesState.SaveViewState();
            }
            if (baseState != null || inputState != null || labelState != null) {
                myState = new Triplet(baseState, inputState, labelState);
            }
            return myState;
        }
 public static void Serialize(SerializationWriter writer, Triplet triplet)
 {
     writer.WriteObject(triplet.First);
     writer.WriteObject(triplet.Second);
     writer.WriteObject(triplet.Third);
 }
Esempio n. 19
0
        private void SerializeValue(SerializerBinaryWriter writer, object value)
        {
            try
            {
                Stack stack = new Stack();
                stack.Push(value);
Label_000D:
                value = stack.Pop();
                if (value == null)
                {
                    writer.Write((byte)100);
                }
                else if (value is string)
                {
                    string str = (string)value;
                    if (str.Length == 0)
                    {
                        writer.Write((byte)0x65);
                    }
                    else
                    {
                        writer.Write((byte)5);
                        writer.Write(str);
                    }
                }
                else if (value is int)
                {
                    int num = (int)value;
                    if (num == 0)
                    {
                        writer.Write((byte)0x66);
                    }
                    else
                    {
                        writer.Write((byte)2);
                        writer.WriteEncoded(num);
                    }
                }
                else if (value is Pair)
                {
                    writer.Write((byte)15);
                    Pair pair = (Pair)value;
                    stack.Push(pair.Second);
                    stack.Push(pair.First);
                }
                else if (value is Triplet)
                {
                    writer.Write((byte)0x10);
                    Triplet triplet = (Triplet)value;
                    stack.Push(triplet.Third);
                    stack.Push(triplet.Second);
                    stack.Push(triplet.First);
                }
                else if (value is IndexedString)
                {
                    this.SerializeIndexedString(writer, ((IndexedString)value).Value);
                }
                else if (value.GetType() == typeof(ArrayList))
                {
                    writer.Write((byte)0x16);
                    ArrayList list = (ArrayList)value;
                    writer.WriteEncoded(list.Count);
                    for (int i = list.Count - 1; i >= 0; i--)
                    {
                        stack.Push(list[i]);
                    }
                }
                else if (value is bool)
                {
                    if ((bool)value)
                    {
                        writer.Write((byte)0x67);
                    }
                    else
                    {
                        writer.Write((byte)0x68);
                    }
                }
                else if (value is byte)
                {
                    writer.Write((byte)3);
                    writer.Write((byte)value);
                }
                else if (value is char)
                {
                    writer.Write((byte)4);
                    writer.Write((char)value);
                }
                else if (value is DateTime)
                {
                    writer.Write((byte)6);
                    writer.Write(((DateTime)value).ToBinary());
                }
                else if (value is double)
                {
                    writer.Write((byte)7);
                    writer.Write((double)value);
                }
                else if (value is short)
                {
                    writer.Write((byte)1);
                    writer.Write((short)value);
                }
                else if (value is float)
                {
                    writer.Write((byte)8);
                    writer.Write((float)value);
                }
                else
                {
                    if (value is IDictionary)
                    {
                        bool flag = false;
                        if (value.GetType() == typeof(Hashtable))
                        {
                            writer.Write((byte)0x17);
                            flag = true;
                        }
                        else if (value.GetType() == typeof(HybridDictionary))
                        {
                            writer.Write((byte)0x18);
                            flag = true;
                        }
                        if (flag)
                        {
                            IDictionary dictionary = (IDictionary)value;
                            writer.WriteEncoded(dictionary.Count);
                            if (dictionary.Count != 0)
                            {
                                foreach (DictionaryEntry entry in dictionary)
                                {
                                    stack.Push(entry.Value);
                                    stack.Push(entry.Key);
                                }
                            }
                            goto Label_06C3;
                        }
                    }
                    if (value is Type)
                    {
                        writer.Write((byte)0x19);
                        this.SerializeType(writer, (Type)value);
                    }
                    else
                    {
                        Type enumType = value.GetType();
                        if (value is Array)
                        {
                            if (((Array)value).Rank <= 1)
                            {
                                Type elementType = enumType.GetElementType();
                                if (elementType == typeof(string))
                                {
                                    string[] strArray = (string[])value;
                                    bool     flag2    = false;
                                    for (int k = 0; k < strArray.Length; k++)
                                    {
                                        if (strArray[k] == null)
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                    }
                                    if (!flag2)
                                    {
                                        writer.Write((byte)0x15);
                                        writer.WriteEncoded(strArray.Length);
                                        for (int m = 0; m < strArray.Length; m++)
                                        {
                                            writer.Write(strArray[m]);
                                        }
                                        goto Label_06C3;
                                    }
                                }
                                Array array = (Array)value;
                                if (array.Length > 3)
                                {
                                    int        capacity = (array.Length / 4) + 1;
                                    int        num6     = 0;
                                    List <int> list2    = new List <int>(capacity);
                                    for (int n = 0; n < array.Length; n++)
                                    {
                                        if (array.GetValue(n) != null)
                                        {
                                            num6++;
                                            if (num6 >= capacity)
                                            {
                                                break;
                                            }
                                            list2.Add(n);
                                        }
                                    }
                                    if (num6 < capacity)
                                    {
                                        writer.Write((byte)60);
                                        this.SerializeType(writer, elementType);
                                        writer.WriteEncoded(array.Length);
                                        writer.WriteEncoded(num6);
                                        foreach (int num8 in list2)
                                        {
                                            writer.WriteEncoded(num8);
                                            this.SerializeValue(writer, array.GetValue(num8));
                                        }
                                        goto Label_06C3;
                                    }
                                }
                                writer.Write((byte)20);
                                this.SerializeType(writer, elementType);
                                writer.WriteEncoded(array.Length);
                                for (int j = array.Length - 1; j >= 0; j--)
                                {
                                    stack.Push(array.GetValue(j));
                                }
                            }
                        }
                        else if (enumType.IsEnum && (Enum.GetUnderlyingType(enumType) == typeof(int)))
                        {
                            writer.Write((byte)11);
                            this.SerializeType(writer, enumType);
                            writer.WriteEncoded((int)value);
                        }
                        else if (enumType == typeof(Color))
                        {
                            Color color = (Color)value;
                            if (color.IsEmpty)
                            {
                                writer.Write((byte)12);
                            }
                            else if (!color.IsNamedColor)
                            {
                                writer.Write((byte)9);
                                writer.Write(color.ToArgb());
                            }
                            else
                            {
                                writer.Write((byte)10);
                                writer.WriteEncoded((int)color.ToKnownColor());
                            }
                        }
                        else if (value is Unit)
                        {
                            Unit unit = (Unit)value;
                            if (unit.IsEmpty)
                            {
                                writer.Write((byte)0x1c);
                            }
                            else
                            {
                                writer.Write((byte)0x1b);
                                writer.Write(unit.Value);
                                writer.Write((int)unit.Type);
                            }
                        }
                        else
                        {
                            TypeConverter converter = TypeDescriptor.GetConverter(enumType);
                            if (Util.CanConvertToFrom(converter, typeof(string)))
                            {
                                writer.Write((byte)40);
                                this.SerializeType(writer, enumType);
                                writer.Write(converter.ConvertToInvariantString(null, value));
                            }
                            else
                            {
                                IFormatter   formatter           = new BinaryFormatter();
                                MemoryStream serializationStream = new MemoryStream(0x100);
                                formatter.Serialize(serializationStream, value);
                                byte[] buffer = serializationStream.GetBuffer();
                                int    length = (int)serializationStream.Length;
                                writer.Write((byte)50);
                                writer.WriteEncoded(length);
                                if (buffer.Length != 0)
                                {
                                    writer.Write(buffer, 0, length);
                                }
                            }
                        }
                    }
                }
Label_06C3:
                if (stack.Count > 0)
                {
                    goto Label_000D;
                }
            }
            catch (Exception exception)
            {
                throw new ArgumentException(System.Web.SR.GetString("ErrorSerializingValue", new object[] { value.ToString(), value.GetType().FullName }), exception);
            }
        }
Esempio n. 20
0
        /// <devdoc>
        /// Loads only changed items from view state.
        /// </devdoc>
        private void LoadChangedItemsFromViewState(object savedState)
        {
            Debug.Assert(savedState != null);
            Debug.Assert(savedState is Triplet);

            Triplet t = (Triplet)savedState;

            if (t.Third is Pair)
            {
                // save some mode; some new objects are typed
                Pair p = (Pair)t.Third;

                ArrayList indices              = (ArrayList)t.First;
                ArrayList states               = (ArrayList)t.Second;
                ArrayList typeIndices          = (ArrayList)p.First;
                ArrayList typedObjectTypeNames = (ArrayList)p.Second;

                for (int i = 0; i < indices.Count; i++)
                {
                    int index = (int)indices[i];

                    if (index < Count)
                    {
                        ((IStateManager)((IList)this)[index]).LoadViewState(states[i]);
                    }
                    else
                    {
                        object o;

                        // If there is only one known type, we don't need type indices
                        if (typeIndices == null)
                        {
                            // Create known type
                            o = CreateKnownType(0);
                        }
                        else
                        {
                            int typeIndex = (int)typeIndices[i];

                            if (typeIndex < GetKnownTypeCount())
                            {
                                // Create known type
                                o = CreateKnownType(typeIndex);
                            }
                            else
                            {
                                string typeName = (string)typedObjectTypeNames[typeIndex - GetKnownTypeCount()];
                                Type   type     = Type.GetType(typeName);

                                o = Activator.CreateInstance(type);
                            }
                        }

                        ((IStateManager)o).TrackViewState();
                        ((IStateManager)o).LoadViewState(states[i]);

                        ((IList)this).Add(o);
                    }
                }
            }
            else
            {
                // save some mode; all new objects are instances of known types
                ArrayList indices     = (ArrayList)t.First;
                ArrayList states      = (ArrayList)t.Second;
                ArrayList typeIndices = (ArrayList)t.Third;

                for (int i = 0; i < indices.Count; i++)
                {
                    int index = (int)indices[i];

                    if (index < Count)
                    {
                        ((IStateManager)((IList)this)[index]).LoadViewState(states[i]);
                    }
                    else
                    {
                        // Create known type
                        int typeIndex = 0;
                        if (typeIndices != null)
                        {
                            typeIndex = (int)typeIndices[i];
                        }
                        object o = CreateKnownType(typeIndex);

                        ((IStateManager)o).TrackViewState();
                        ((IStateManager)o).LoadViewState(states[i]);

                        ((IList)this).Add(o);
                    }
                }
            }
        }
Esempio n. 21
0
 /// <summary>
 /// Saves the current view state of the <see cref="Layer" /> object.
 /// </summary>
 /// <param name="saveAll"><c>true</c> if all values should be saved regardless
 /// of whether they are dirty; otherwise <c>false</c>.</param>
 /// <returns>An object that represents the saved state. The default is <c>null</c>.</returns>
 protected override object SaveViewState(bool saveAll)
 {
     Triplet triplet = new Triplet();
     triplet.First = base.SaveViewState(saveAll);
     if (_padding != null)
         triplet.Second = ((IStateManagedObject) _padding).SaveViewState(saveAll);
     if (_filters != null)
         triplet.Third = ((IStateManagedObject) _filters).SaveViewState(saveAll);
     return (triplet.First == null && triplet.Second == null && triplet.Third == null) ? null : triplet;
 }
Esempio n. 22
0
        private void LoadChangedItemsFromViewState(object savedState)
        {
            Triplet triplet = (Triplet)savedState;

            if (triplet.Third is Pair)
            {
                Pair      third  = (Pair)triplet.Third;
                ArrayList first  = (ArrayList)triplet.First;
                ArrayList second = (ArrayList)triplet.Second;
                ArrayList list3  = (ArrayList)third.First;
                ArrayList list4  = (ArrayList)third.Second;
                for (int i = 0; i < first.Count; i++)
                {
                    int num2 = (int)first[i];
                    if (num2 < this.Count)
                    {
                        ((IStateManager)((IList)this)[num2]).LoadViewState(second[i]);
                    }
                    else
                    {
                        object obj2;
                        if (list3 == null)
                        {
                            obj2 = this.CreateKnownType(0);
                        }
                        else
                        {
                            int index = (int)list3[i];
                            if (index < this.GetKnownTypeCount())
                            {
                                obj2 = this.CreateKnownType(index);
                            }
                            else
                            {
                                string typeName = (string)list4[index - this.GetKnownTypeCount()];
                                obj2 = Activator.CreateInstance(Type.GetType(typeName));
                            }
                        }
                        ((IStateManager)obj2).TrackViewState();
                        ((IStateManager)obj2).LoadViewState(second[i]);
                        ((IList)this).Add(obj2);
                    }
                }
            }
            else
            {
                ArrayList list5 = (ArrayList)triplet.First;
                ArrayList list6 = (ArrayList)triplet.Second;
                ArrayList list7 = (ArrayList)triplet.Third;
                for (int j = 0; j < list5.Count; j++)
                {
                    int num5 = (int)list5[j];
                    if (num5 < this.Count)
                    {
                        ((IStateManager)((IList)this)[num5]).LoadViewState(list6[j]);
                    }
                    else
                    {
                        int num6 = 0;
                        if (list7 != null)
                        {
                            num6 = (int)list7[j];
                        }
                        object obj3 = this.CreateKnownType(num6);
                        ((IStateManager)obj3).TrackViewState();
                        ((IStateManager)obj3).LoadViewState(list6[j]);
                        ((IList)this).Add(obj3);
                    }
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Overrides <see cref="Control.SaveViewState"/>
        /// </summary>
        protected override object SaveViewState()
        {
            Triplet vstate = new Triplet();
            vstate.First = base.SaveViewState();
            if ( this.dialogArguments == null || this.dialogArguments.Count == 0 ) {
                vstate.Second = null;
                vstate.Third = null;
            } else {
                String[] keys = this.dialogArguments.AllKeys;
                vstate.Second = keys;

                String[] values = new String[keys.Length];
                for(Int32 i = 0; i < keys.Length; i++ ) {
                    values[i] = this.dialogArguments[i];
                }
                vstate.Third = values;
            }
            return vstate;
        }
Esempio n. 24
0
	internal void SavePageViewState ()
	{
		if (!handleViewState)
			return;

#if NET_2_0
		object controlState = SavePageControlState ();
#endif

		object viewState = SaveViewStateRecursive ();
		object reqPostback = (_requiresPostBack != null && _requiresPostBack.Count > 0) ? _requiresPostBack : null;

#if NET_2_0
		Triplet triplet = new Triplet ();
		triplet.First = viewState;
		triplet.Second = reqPostback;
		triplet.Third = controlState;

		if (triplet.First == null && triplet.Second == null && triplet.Third == null)
			triplet = null;
			
		SavePageStateToPersistenceMedium (triplet);
#else
		Pair pair = new Pair ();
		pair.First = viewState;
		pair.Second = reqPostback;

		if (pair.First == null && pair.Second == null)
			pair = null;
			
		SavePageStateToPersistenceMedium (pair);
#endif
	}
 protected override void PopulateBrowserElements(IDictionary dictionary)
 {
     base.PopulateBrowserElements(dictionary);
     dictionary["Default"] = new Triplet(null, string.Empty, 0);
     dictionary["BlackBerry"] = new Triplet("Default", string.Empty, 1);
     dictionary["Opera"] = new Triplet("Default", string.Empty, 1);
     dictionary["Opera8to9"] = new Triplet("Opera", string.Empty, 2);
     dictionary["Opera10"] = new Triplet("Opera", string.Empty, 2);
     dictionary["GenericDownlevel"] = new Triplet("Default", string.Empty, 1);
     dictionary["Mozilla"] = new Triplet("Default", string.Empty, 1);
     dictionary["IE"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["IE6to9"] = new Triplet("Ie", string.Empty, 3);
     dictionary["IE7"] = new Triplet("Ie6to9", string.Empty, 4);
     dictionary["IE8"] = new Triplet("Ie6to9", string.Empty, 4);
     dictionary["Chrome"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Firefox"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Firefox3"] = new Triplet("Firefox", string.Empty, 3);
     dictionary["Firefox35"] = new Triplet("Firefox3", string.Empty, 4);
     dictionary["IEMobile"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Safari"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Safari3to4"] = new Triplet("Safari", string.Empty, 3);
     dictionary["Safari4"] = new Triplet("Safari3to4", string.Empty, 4);
 }
 /// <summary>
 /// Saves the current view state of the <see cref="ImageLayer" /> object.
 /// </summary>
 /// <param name="saveAll"><c>true</c> if all values should be saved regardless
 /// of whether they are dirty; otherwise <c>false</c>.</param>
 /// <returns>An object that represents the saved state. The default is <c>null</c>.</returns>
 protected override object SaveViewState(bool saveAll)
 {
     Triplet triplet = new Triplet();
     triplet.First = base.SaveViewState(saveAll);
     if (_positions != null || _normals != null)
         triplet.Second = new Pair();
     if (_positions != null)
         ((Pair) triplet.Second).First = ((IStateManagedObject)_positions).SaveViewState(saveAll);
     if (_normals != null)
         ((Pair)triplet.Second).Second = ((IStateManagedObject)_normals).SaveViewState(saveAll);
     if (_indices != null || _material != null || _textureCoordinates != null)
         triplet.Third = new Triplet();
     if (_indices != null)
         ((Triplet)triplet.Third).First = ((IStateManagedObject)_indices).SaveViewState(saveAll);
     if (_material != null)
         ((Triplet)triplet.Third).Second = ((IStateManagedObject)_material).SaveViewState(saveAll);
     if (_textureCoordinates != null)
         ((Triplet)triplet.Third).Third = ((IStateManagedObject)_textureCoordinates).SaveViewState(saveAll);
     return (triplet.First == null && triplet.Second == null && triplet.Third == null) ? null : triplet;
 }
Esempio n. 27
0
 /// <summary>
 /// A protected method. Saves any state that has been modified after the 
 /// <see cref="TrackViewState()" /> method was invoked.
 /// </summary>
 /// <param name="saveAll"><c>true</c> if all values should be saved regardless
 /// of whether they are dirty; otherwise <c>false</c>.</param>
 /// <returns>An object that represents the saved state. The default is <c>null</c>.</returns>
 protected virtual object SaveViewState(bool saveAll)
 {
     if (_viewState != null)
         if (saveAll)
         {
             Triplet triplet = new Triplet();
             triplet.First = "Type";
             triplet.Second = this.GetType().FullName;
             triplet.Third = _viewState.SaveAllViewState();
             return triplet;
         }
         else
         {
             return ((IStateManager) _viewState).SaveViewState();
         }
     return null;
 }
Esempio n. 28
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				Triplet t = new Triplet ();
				t.First = ReadObject (r, ctx);
				t.Second = ReadObject (r, ctx);
				t.Third = ReadObject (r, ctx);
				return t;
			}
 private object cc(object tipo)
 {
     if (tipo == null)
     {
         return(null);
     }
     if (esConocido(tipo))
     {
         return(tipo);
     }
     else if (tipo is System.Web.UI.Triplet)
     {
         System.Web.UI.Triplet triple = (System.Web.UI.Triplet)tipo;
         return(new seriable3(cc(triple.First), cc(triple.Second), cc(triple.Third)));
     }
     else if (tipo is System.Web.UI.Pair)
     {
         System.Web.UI.Pair par = (System.Web.UI.Pair)tipo;
         return(new seriable2(cc(par.First), cc(par.Second)));
     }
     else if (tipo is ArrayList)
     {
         ArrayList trans  = (ArrayList)tipo;
         ArrayList salida = new ArrayList(trans.Count);
         foreach (object x in trans)
         {
             salida.Add(cc(x));
         }
         return(salida);
     }
     else if (tipo is Array)
     {
         Array trans  = (Array)tipo;
         Array salida = Array.CreateInstance(tipo.GetType().GetElementType(), trans.Length);
         for (int x = 0; x < trans.Length; x++)
         {
             salida.SetValue(cc(trans.GetValue(x)), x);
         }
         return(salida);
     }
     else if (tipo is Hashtable)
     {
         IDictionaryEnumerator enumerator = ((Hashtable)tipo).GetEnumerator();
         Hashtable             salida     = new Hashtable();
         while (enumerator.MoveNext())
         {
             salida.Add(cc(enumerator.Key), cc(enumerator.Value));
         }
         return(salida);
     }
     else
     {
         Type valueType       = tipo.GetType();
         Type destinationType = typeof(string);
         bool flag;
         bool flag2;
         System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(valueType);
         if (((converter == null) || converter is System.ComponentModel.ReferenceConverter))
         {
             flag  = false;
             flag2 = false;
         }
         else
         {
             flag  = converter.CanConvertTo(destinationType);
             flag2 = converter.CanConvertFrom(destinationType);
         }
         if ((flag && flag2))
         {
             return(new generalCnv(valueType, converter.ConvertToInvariantString(tipo)));
         }
         else
         {
             return(tipo);
             //Salida General
         }
     }
 }
        /// <internalonly/>
        void IHttpHandler.ProcessRequest(HttpContext context) {
            // Make sure we don't get any extra content in this handler (like Application.BeginRequest stuff);
            context.Response.Clear();

            Stream resourceStream = null;
            string decryptedData = null;
            bool resourceIdentifierPresent = false;

            Exception exception = null;
            try {
                NameValueCollection queryString = context.Request.QueryString;

                string encryptedData = queryString["d"];
                if (String.IsNullOrEmpty(encryptedData)) {
                    throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_InvalidRequest));
                }
                resourceIdentifierPresent = true;

                decryptedData = Page.DecryptString(encryptedData, Purpose.AssemblyResourceLoader_WebResourceUrl);

                int separatorIndex = decryptedData.IndexOf('|');
                Debug.Assert(separatorIndex != -1, "The decrypted data must contain a separator.");

                string assemblyName = decryptedData.Substring(0, separatorIndex);
                if (String.IsNullOrEmpty(assemblyName)) {
                    throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_AssemblyNotFound, assemblyName));
                }

                string resourceName = decryptedData.Substring(separatorIndex + 1);
                if (String.IsNullOrEmpty(resourceName)) {
                    throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_ResourceNotFound, resourceName));
                }

                char nameType = assemblyName[0];
                assemblyName = assemblyName.Substring(1);

                Assembly assembly = null;

                // If it was a full name, create an AssemblyName and load from that
                if (nameType == 'f') {
                    string[] parts = assemblyName.Split(',');

                    if (parts.Length != 4) {
                        throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_InvalidRequest));
                    }

                    AssemblyName realName = new AssemblyName();
                    realName.Name = parts[0];
                    realName.Version = new Version(parts[1]);
                    string cultureString = parts[2];

                    // Try to determine the culture, using the invariant culture if there wasn't one (doesn't work without it)
                    if (cultureString.Length > 0) {
                        realName.CultureInfo = new CultureInfo(cultureString);
                    }
                    else {
                        realName.CultureInfo = CultureInfo.InvariantCulture;
                    }

                    // Parse up the public key token which is represented as hex bytes in a string
                    string token = parts[3];
                    byte[] tokenBytes = new byte[token.Length / 2];
                    for (int i = 0; i < tokenBytes.Length; i++) {
                        tokenBytes[i] = Byte.Parse(token.Substring(i * 2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                    }
                    realName.SetPublicKeyToken(tokenBytes);

                    assembly = Assembly.Load(realName);
                }
                // System.Web special case
                else if (nameType == 's') {
                    assembly = typeof(AssemblyResourceLoader).Assembly;
                }
                // If was a partial name, just try to load it
                else if (nameType == 'p') {
                    assembly = Assembly.Load(assemblyName);
                }
                else {
                    throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_InvalidRequest));
                }

                // Dev10 Bugs 602949: Throw 404 if resource not found rather than do nothing.
                // This is done before creating the cache entry, since it could be that the assembly is loaded
                // later on without the app restarting.
                if (assembly == null) {
                    throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_InvalidRequest));
                }

                bool performSubstitution = false;
                bool validResource = false;
                string contentType = String.Empty;

                // Check the validation cache to see if the resource has already been validated
                int cacheKey = HashCodeCombiner.CombineHashCodes(assembly.GetHashCode(), resourceName.GetHashCode());
                Triplet resourceTriplet = (Triplet)_webResourceCache[cacheKey];
                if (resourceTriplet != null) {
                    validResource = (bool)resourceTriplet.First;
                    contentType = (string)resourceTriplet.Second;
                    performSubstitution = (bool)resourceTriplet.Third;
                }
                else {
                    // Validation cache is empty, find out if it's valid and add it to the cache
                    WebResourceAttribute wra = FindWebResourceAttribute(assembly, resourceName);
                    if (wra != null) {
                        resourceName = wra.WebResource;
                        validResource = true;
                        contentType = wra.ContentType;
                        performSubstitution = wra.PerformSubstitution;
                    }

                    // Cache the result so we don't have to do this again
                    try {
                        if (validResource) {
                            // a WebResourceAttribute was found, but does the resource really exist?
                            validResource = false;
                            resourceStream = assembly.GetManifestResourceStream(resourceName);
                            validResource = (resourceStream != null);
                        }
                    }
                    finally {
                        // Cache the results, even if there was an exception getting the stream,
                        // so we don't have to do this again
                        Triplet triplet = new Triplet();
                        triplet.First = validResource;
                        triplet.Second = contentType;
                        triplet.Third = performSubstitution;
                        _webResourceCache[cacheKey] = triplet;
                    }
                }

                if (validResource) {
                    // Cache the resource so we don't keep processing the same requests
                    HttpCachePolicy cachePolicy = context.Response.Cache;
                    cachePolicy.SetCacheability(HttpCacheability.Public);
                    cachePolicy.VaryByParams["d"] = true;
                    cachePolicy.SetOmitVaryStar(true);
                    cachePolicy.SetExpires(DateTime.Now + TimeSpan.FromDays(365));
                    cachePolicy.SetValidUntilExpires(true);
                    Pair assemblyInfo = GetAssemblyInfo(assembly);
                    cachePolicy.SetLastModified(new DateTime((long)assemblyInfo.Second));

                    StreamReader reader = null;
                    try {
                        if (resourceStream == null) {
                            // null in the case that _webResourceCache had the item
                            resourceStream = assembly.GetManifestResourceStream(resourceName);
                        }
                        if (resourceStream != null) {
                            context.Response.ContentType = contentType;

                            if (performSubstitution) {
                                // 
                                reader = new StreamReader(resourceStream, true);
                            
                                string content = reader.ReadToEnd();
                            
                                // Looking for something of the form: WebResource("resourcename")
                                MatchCollection matches = webResourceRegex.Matches(content);
                                int startIndex = 0;
                                StringBuilder newContent = new StringBuilder();
                                foreach (Match match in matches) {
                                    newContent.Append(content.Substring(startIndex, match.Index - startIndex));
                                
                                    Group group = match.Groups["resourceName"];
                                    if (group != null) {
                                        string embeddedResourceName = group.ToString();
                                        if (embeddedResourceName.Length > 0) {
                                            // 
                                            if (String.Equals(embeddedResourceName, resourceName, StringComparison.Ordinal)) {
                                                throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_NoCircularReferences, resourceName));
                                            }
                                            newContent.Append(GetWebResourceUrlInternal(assembly, embeddedResourceName, htmlEncoded: false, forSubstitution: true, scriptManager: null));
                                        }
                                    }
                                
                                    startIndex = match.Index + match.Length;
                                }

                                newContent.Append(content.Substring(startIndex, content.Length - startIndex));
                            
                                StreamWriter writer = new StreamWriter(context.Response.OutputStream, reader.CurrentEncoding);
                                writer.Write(newContent.ToString());
                                writer.Flush();
                            }
                            else {
                                byte[] buffer = new byte[1024];
                                Stream outputStream = context.Response.OutputStream;
                                int count = 1;
                                while (count > 0) {
                                    count = resourceStream.Read(buffer, 0, 1024);
                                    outputStream.Write(buffer, 0, count);
                                }
                                outputStream.Flush();
                            }
                        }
                    }
                    finally {
                        if (reader != null)
                            reader.Close();
                        if (resourceStream != null)
                            resourceStream.Close();
                    }
                }
            }
            catch(Exception e) {
                exception = e;
                // MSRC 10405: ---- all errors in the event of failure. In particular, we don't want to
                // bubble the inner exceptions up in the YSOD, as they might contain sensitive cryptographic
                // information. Setting 'resourceStream' to null will cause an appropriate exception to
                // be thrown.
                resourceStream = null;
            }

            // Dev10 Bugs 602949: 404 if the assembly is not found or if the resource does not exist
            if (resourceStream == null) {
                if (resourceIdentifierPresent) {
                    LogWebResourceFailure(decryptedData, exception);
                }
                throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_InvalidRequest));
            }

            context.Response.IgnoreFurtherWrites();
        }
Esempio n. 31
0
 /// <summary>
 /// Saves the current view state of the <see cref="Composition" /> object.
 /// </summary>
 /// <param name="saveAll"><c>true</c> if all values should be saved regardless
 /// of whether they are dirty; otherwise <c>false</c>.</param>
 /// <returns>An object that represents the saved state. The default is <c>null</c>.</returns>
 protected override object SaveViewState(bool saveAll)
 {
     Triplet triplet = new Triplet();
     triplet.First = base.SaveViewState(saveAll);
     if (_layers != null)
         triplet.Second = ((IStateManagedObject) _layers).SaveViewState(saveAll);
     if (_fill != null || _filters != null)
         triplet.Third = new Pair();
     if (_fill != null)
         ((Pair) triplet.Third).First = ((IStateManagedObject)_fill).SaveViewState(saveAll);
     if (_filters != null)
         ((Pair)triplet.Third).Second = ((IStateManagedObject)_filters).SaveViewState(saveAll);
     return (triplet.First == null && triplet.Second == null && triplet.Third == null) ? null : triplet;
 }
        void IStateManager.LoadViewState(object savedState)
        {
            if (savedState == null)
            {
                foreach (IStateManager i in items)
                {
                    i.LoadViewState(null);
                }
                return;
            }

            Triplet state = savedState as Triplet;

            if (state == null)
            {
                throw new InvalidOperationException("Internal error.");
            }

            List <int>    indices = state.First as List <int>;
            List <object> states  = state.Second as List <object>;
            List <object> types   = state.Third as List <object>;
            IList         list    = this as IList;
            IStateManager item;
            object        t;

            saveEverything = indices == null;
            if (saveEverything)
            {
                Clear();

                for (int i = 0; i < states.Count; i++)
                {
                    t = types [i];
                    if (t is Type)
                    {
                        item = (IStateManager)Activator.CreateInstance((Type)t);
                    }
                    else if (t is int)
                    {
                        item = (IStateManager)CreateKnownType((int)t);
                    }
                    else
                    {
                        continue;
                    }

                    item.TrackViewState();
                    item.LoadViewState(states [i]);
                    list.Add(item);
                }
                return;
            }

            int idx;

            for (int i = 0; i < indices.Count; i++)
            {
                idx = indices [i];

                if (idx < Count)
                {
                    item = list [idx] as IStateManager;
                    item.TrackViewState();
                    item.LoadViewState(states [i]);
                    continue;
                }

                t = types [i];

                if (t is Type)
                {
                    item = (IStateManager)Activator.CreateInstance((Type)t);
                }
                else if (t is int)
                {
                    item = (IStateManager)CreateKnownType((int)t);
                }
                else
                {
                    continue;
                }

                item.TrackViewState();
                item.LoadViewState(states [i]);
                list.Add(item);
            }
        }
 protected override void PopulateBrowserElements(IDictionary dictionary)
 {
     base.PopulateBrowserElements(dictionary);
     dictionary["Default"] = new Triplet(null, string.Empty, 0);
     dictionary["Mozilla"] = new Triplet("Default", string.Empty, 1);
     dictionary["IE"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["IE5to9"] = new Triplet("Ie", string.Empty, 3);
     dictionary["IE6to9"] = new Triplet("Ie5to9", string.Empty, 4);
     dictionary["Treo600"] = new Triplet("Ie6to9", string.Empty, 5);
     dictionary["IE5"] = new Triplet("Ie5to9", string.Empty, 4);
     dictionary["IE50"] = new Triplet("Ie5", string.Empty, 5);
     dictionary["IE55"] = new Triplet("Ie5", string.Empty, 5);
     dictionary["IE5to9Mac"] = new Triplet("Ie5to9", string.Empty, 4);
     dictionary["IE4"] = new Triplet("Ie", string.Empty, 3);
     dictionary["IE3"] = new Triplet("Ie", string.Empty, 3);
     dictionary["IE3win16"] = new Triplet("Ie3", string.Empty, 4);
     dictionary["IE3win16a"] = new Triplet("Ie3win16", string.Empty, 5);
     dictionary["IE3Mac"] = new Triplet("Ie3", string.Empty, 4);
     dictionary["IE2"] = new Triplet("Ie", string.Empty, 3);
     dictionary["WebTV"] = new Triplet("Ie2", string.Empty, 4);
     dictionary["WebTV2"] = new Triplet("Webtv", string.Empty, 5);
     dictionary["IE1minor5"] = new Triplet("Ie", string.Empty, 3);
     dictionary["PowerBrowser"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Gecko"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["MozillaRV"] = new Triplet("Gecko", string.Empty, 3);
     dictionary["MozillaFirebird"] = new Triplet("Mozillarv", string.Empty, 4);
     dictionary["MozillaFirefox"] = new Triplet("Mozillarv", string.Empty, 4);
     dictionary["Safari"] = new Triplet("Gecko", string.Empty, 3);
     dictionary["Safari60"] = new Triplet("Safari", string.Empty, 4);
     dictionary["Safari85"] = new Triplet("Safari", string.Empty, 4);
     dictionary["Safari1Plus"] = new Triplet("Safari", string.Empty, 4);
     dictionary["Netscape5"] = new Triplet("Gecko", string.Empty, 3);
     dictionary["Netscape6to9"] = new Triplet("Netscape5", string.Empty, 4);
     dictionary["Netscape6to9Beta"] = new Triplet("Netscape6to9", string.Empty, 5);
     dictionary["NetscapeBeta"] = new Triplet("Netscape5", string.Empty, 4);
     dictionary["AvantGo"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["TMobileSidekick"] = new Triplet("Avantgo", string.Empty, 3);
     dictionary["GoAmerica"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["GoAmericaWinCE"] = new Triplet("Goamerica", string.Empty, 3);
     dictionary["GoAmericaPalm"] = new Triplet("Goamerica", string.Empty, 3);
     dictionary["GoAmericaRIM"] = new Triplet("Goamerica", string.Empty, 3);
     dictionary["GoAmericaRIM950"] = new Triplet("Goamericarim", string.Empty, 4);
     dictionary["GoAmericaRIM850"] = new Triplet("Goamericarim", string.Empty, 4);
     dictionary["GoAmericaRIM957"] = new Triplet("Goamericarim", string.Empty, 4);
     dictionary["GoAmericaRIM957major6minor2"] = new Triplet("Goamericarim957", string.Empty, 5);
     dictionary["GoAmericaRIM857"] = new Triplet("Goamericarim", string.Empty, 4);
     dictionary["GoAmericaRIM857major6"] = new Triplet("Goamericarim857", string.Empty, 5);
     dictionary["GoAmericaRIM857major6minor2to9"] = new Triplet("Goamericarim857major6", string.Empty, 6);
     dictionary["GoAmerica7to9"] = new Triplet("Goamericarim857", string.Empty, 5);
     dictionary["Netscape3"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Netscape4"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["Casiopeia"] = new Triplet("Netscape4", string.Empty, 3);
     dictionary["PalmWebPro"] = new Triplet("Netscape4", string.Empty, 3);
     dictionary["PalmWebPro3"] = new Triplet("Palmwebpro", string.Empty, 4);
     dictionary["NetFront"] = new Triplet("Netscape4", string.Empty, 3);
     dictionary["SLB500"] = new Triplet("Netfront", string.Empty, 4);
     dictionary["VRNA"] = new Triplet("Netfront", string.Empty, 4);
     dictionary["Mypalm"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["MyPalm1"] = new Triplet("Mypalm", string.Empty, 3);
     dictionary["Eudoraweb"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["PdQbrowser"] = new Triplet("Eudoraweb", string.Empty, 3);
     dictionary["Eudoraweb21Plus"] = new Triplet("Eudoraweb", string.Empty, 3);
     dictionary["WinCE"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["PIE"] = new Triplet("Wince", string.Empty, 3);
     dictionary["PIEPPC"] = new Triplet("Pie", string.Empty, 4);
     dictionary["PIEnoDeviceID"] = new Triplet("Pie", string.Empty, 4);
     dictionary["PIESmartphone"] = new Triplet("Pie", string.Empty, 4);
     dictionary["PIE4"] = new Triplet("Wince", string.Empty, 3);
     dictionary["PIE4PPC"] = new Triplet("Pie4", string.Empty, 4);
     dictionary["PIE5Plus"] = new Triplet("Wince", string.Empty, 3);
     dictionary["sigmarion3"] = new Triplet("Pie5plus", string.Empty, 4);
     dictionary["MSPIE"] = new Triplet("Mozilla", string.Empty, 2);
     dictionary["MSPIE2"] = new Triplet("Mspie", string.Empty, 3);
     dictionary["Docomo"] = new Triplet("Default", string.Empty, 1);
     dictionary["DocomoSH251i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSH251iS"] = new Triplet("Docomosh251i", string.Empty, 3);
     dictionary["DocomoN251i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN251iS"] = new Triplet("Docomon251i", string.Empty, 3);
     dictionary["DocomoP211i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF212i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD501i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF501i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN501i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP501i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD502i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF502i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN502i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP502i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoNm502i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSo502i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF502it"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN502it"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSo502iwm"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF504i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN504i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP504i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN821i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP821i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoEr209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoKo209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP209is"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoR209i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoR691i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF503i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF503is"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD503i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD503is"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD210i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF210i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN210i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN2001"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD211i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN211i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP210i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoKo210i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP2101v"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP2102v"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF211i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoF671i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN503is"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN503i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSo503i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP503is"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP503i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSo210i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSo503is"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSh821i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN2002"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoSo505i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoP505i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoN505i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoD505i"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["DocomoISIM60"] = new Triplet("Docomo", string.Empty, 2);
     dictionary["EricssonR380"] = new Triplet("Default", string.Empty, 1);
     dictionary["Ericsson"] = new Triplet("Default", string.Empty, 1);
     dictionary["EricssonR320"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonT20"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonT65"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonT68"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["Ericsson301A"] = new Triplet("Ericssont68", string.Empty, 3);
     dictionary["EricssonT68R1A"] = new Triplet("Ericssont68", string.Empty, 3);
     dictionary["EricssonT68R101"] = new Triplet("Ericssont68", string.Empty, 3);
     dictionary["EricssonT68R201A"] = new Triplet("Ericssont68", string.Empty, 3);
     dictionary["EricssonT300"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonP800"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonP800R101"] = new Triplet("Ericssonp800", string.Empty, 3);
     dictionary["EricssonT61"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonT31"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonR520"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonA2628"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EricssonT39"] = new Triplet("Ericsson", string.Empty, 2);
     dictionary["EzWAP"] = new Triplet("Default", string.Empty, 1);
     dictionary["GenericDownlevel"] = new Triplet("Default", string.Empty, 1);
     dictionary["Jataayu"] = new Triplet("Default", string.Empty, 1);
     dictionary["JataayuPPC"] = new Triplet("Jataayu", string.Empty, 2);
     dictionary["Jphone"] = new Triplet("Default", string.Empty, 1);
     dictionary["JphoneMitsubishi"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneDenso"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneKenwood"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneNec"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneNecN51"] = new Triplet("Jphonenec", string.Empty, 3);
     dictionary["JphonePanasonic"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphonePioneer"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneSanyo"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneSA51"] = new Triplet("Jphonesanyo", string.Empty, 3);
     dictionary["JphoneSharp"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneSharpSh53"] = new Triplet("Jphonesharp", string.Empty, 3);
     dictionary["JphoneSharpSh07"] = new Triplet("Jphonesharp", string.Empty, 3);
     dictionary["JphoneSharpSh08"] = new Triplet("Jphonesharp", string.Empty, 3);
     dictionary["JphoneSharpSh51"] = new Triplet("Jphonesharp", string.Empty, 3);
     dictionary["JphoneSharpSh52"] = new Triplet("Jphonesharp", string.Empty, 3);
     dictionary["JphoneToshiba"] = new Triplet("Jphone", string.Empty, 2);
     dictionary["JphoneToshibaT06a"] = new Triplet("Jphonetoshiba", string.Empty, 3);
     dictionary["JphoneToshibaT08"] = new Triplet("Jphonetoshiba", string.Empty, 3);
     dictionary["JphoneToshibaT51"] = new Triplet("Jphonetoshiba", string.Empty, 3);
     dictionary["Legend"] = new Triplet("Default", string.Empty, 1);
     dictionary["LGG5200"] = new Triplet("Legend", string.Empty, 2);
     dictionary["MME"] = new Triplet("Default", string.Empty, 1);
     dictionary["MMEF20"] = new Triplet("Mme", string.Empty, 2);
     dictionary["MMECellphone"] = new Triplet("Mmef20", string.Empty, 3);
     dictionary["MMEBenefonQ"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMESonyCMDZ5"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMESonyCMDZ5Pj020e"] = new Triplet("Mmesonycmdz5", string.Empty, 5);
     dictionary["MMESonyCMDJ5"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMESonyCMDJ7"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMEGenericSmall"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMEGenericLarge"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMEGenericFlip"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMEGeneric3D"] = new Triplet("Mmecellphone", string.Empty, 4);
     dictionary["MMEMobileExplorer"] = new Triplet("Mme", string.Empty, 2);
     dictionary["Nokia"] = new Triplet("Default", string.Empty, 1);
     dictionary["NokiaBlueprint"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["NokiaWapSimulator"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["NokiaMobileBrowser"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia7110"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6220"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6250"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6310"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6510"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia8310"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia9110i"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia9110"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia3330"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia9210"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia9210HTML"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia3590"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia3590V1"] = new Triplet("Nokia3590", string.Empty, 3);
     dictionary["Nokia3595"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia3560"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia3650"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia3650P12Plus"] = new Triplet("Nokia3650", string.Empty, 3);
     dictionary["Nokia5100"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6200"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6590"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia6800"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["Nokia7650"] = new Triplet("Nokia", string.Empty, 2);
     dictionary["NokiaMobileBrowserRainbow"] = new Triplet("Default", string.Empty, 1);
     dictionary["NokiaEpoc32wtl"] = new Triplet("Default", string.Empty, 1);
     dictionary["NokiaEpoc32wtl20"] = new Triplet("Nokiaepoc32wtl", string.Empty, 2);
     dictionary["Up"] = new Triplet("Default", string.Empty, 1);
     dictionary["AuMic"] = new Triplet("Up", string.Empty, 2);
     dictionary["AuMicV2"] = new Triplet("Aumic", string.Empty, 3);
     dictionary["a500"] = new Triplet("Aumic", string.Empty, 3);
     dictionary["n400"] = new Triplet("Aumic", string.Empty, 3);
     dictionary["AlcatelBe4"] = new Triplet("Up", string.Empty, 2);
     dictionary["AlcatelBe5"] = new Triplet("Up", string.Empty, 2);
     dictionary["AlcatelBe5v2"] = new Triplet("Alcatelbe5", string.Empty, 3);
     dictionary["AlcatelBe3"] = new Triplet("Up", string.Empty, 2);
     dictionary["AlcatelBf3"] = new Triplet("Up", string.Empty, 2);
     dictionary["AlcatelBf4"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotCb"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotF5"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotD8"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotCf"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotF6"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotBc"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotDc"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotPanC"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotC4"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mcca"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mot2000"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotP2kC"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotAf"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotAf418"] = new Triplet("Motaf", string.Empty, 3);
     dictionary["MotC2"] = new Triplet("Up", string.Empty, 2);
     dictionary["Xenium"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sagem959"] = new Triplet("Up", string.Empty, 2);
     dictionary["SghA300"] = new Triplet("Up", string.Empty, 2);
     dictionary["SghN100"] = new Triplet("Up", string.Empty, 2);
     dictionary["C304sa"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy11"] = new Triplet("Up", string.Empty, 2);
     dictionary["St12"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy14"] = new Triplet("Up", string.Empty, 2);
     dictionary["SieS40"] = new Triplet("Up", string.Empty, 2);
     dictionary["SieSl45"] = new Triplet("Up", string.Empty, 2);
     dictionary["SieS35"] = new Triplet("Up", string.Empty, 2);
     dictionary["SieMe45"] = new Triplet("Up", string.Empty, 2);
     dictionary["SieS45"] = new Triplet("Up", string.Empty, 2);
     dictionary["Gm832"] = new Triplet("Up", string.Empty, 2);
     dictionary["Gm910i"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mot32"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mot28"] = new Triplet("Up", string.Empty, 2);
     dictionary["D2"] = new Triplet("Up", string.Empty, 2);
     dictionary["PPat"] = new Triplet("Up", string.Empty, 2);
     dictionary["Alaz"] = new Triplet("Up", string.Empty, 2);
     dictionary["Cdm9100"] = new Triplet("Up", string.Empty, 2);
     dictionary["Cdm135"] = new Triplet("Up", string.Empty, 2);
     dictionary["Cdm9000"] = new Triplet("Up", string.Empty, 2);
     dictionary["C303ca"] = new Triplet("Up", string.Empty, 2);
     dictionary["C311ca"] = new Triplet("Up", string.Empty, 2);
     dictionary["C202de"] = new Triplet("Up", string.Empty, 2);
     dictionary["C409ca"] = new Triplet("Up", string.Empty, 2);
     dictionary["C402de"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ds15"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tp2200"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tp120"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ds10"] = new Triplet("Up", string.Empty, 2);
     dictionary["R280"] = new Triplet("Up", string.Empty, 2);
     dictionary["C201h"] = new Triplet("Up", string.Empty, 2);
     dictionary["S71"] = new Triplet("Up", string.Empty, 2);
     dictionary["C302h"] = new Triplet("Up", string.Empty, 2);
     dictionary["C309h"] = new Triplet("Up", string.Empty, 2);
     dictionary["C407h"] = new Triplet("Up", string.Empty, 2);
     dictionary["C451h"] = new Triplet("Up", string.Empty, 2);
     dictionary["R201"] = new Triplet("Up", string.Empty, 2);
     dictionary["P21"] = new Triplet("Up", string.Empty, 2);
     dictionary["Kyocera702g"] = new Triplet("Up", string.Empty, 2);
     dictionary["Kyocera703g"] = new Triplet("Up", string.Empty, 2);
     dictionary["KyoceraC307k"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tk01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tk02"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tk03"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tk04"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tk05"] = new Triplet("Up", string.Empty, 2);
     dictionary["D303k"] = new Triplet("Up", string.Empty, 2);
     dictionary["D304k"] = new Triplet("Up", string.Empty, 2);
     dictionary["Qcp2035"] = new Triplet("Up", string.Empty, 2);
     dictionary["Qcp3035"] = new Triplet("Up", string.Empty, 2);
     dictionary["D512"] = new Triplet("Up", string.Empty, 2);
     dictionary["Dm110"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tm510"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lg13"] = new Triplet("Up", string.Empty, 2);
     dictionary["P100"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lgc875f"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lgp680f"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lgp7800f"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lgc840f"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lgi2100"] = new Triplet("Up", string.Empty, 2);
     dictionary["Lgp7300f"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sd500"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tp1100"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tp3000"] = new Triplet("Up", string.Empty, 2);
     dictionary["T250"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mo01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mo02"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mc01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mccc"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mcc9"] = new Triplet("Up", string.Empty, 2);
     dictionary["Nk00"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mai12"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ma112"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ma13"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mac1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mat1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc03"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc02"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc04"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sg08"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc13"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc11"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sec01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sc10"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy12"] = new Triplet("Up", string.Empty, 2);
     dictionary["St11"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy13"] = new Triplet("Up", string.Empty, 2);
     dictionary["Syc1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Syt1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sty2"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy02"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy03"] = new Triplet("Up", string.Empty, 2);
     dictionary["Si01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sni1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sn11"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sn12"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sn134"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sn156"] = new Triplet("Up", string.Empty, 2);
     dictionary["Snc1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tsc1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tsi1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ts11"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ts12"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ts13"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tst1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tst2"] = new Triplet("Up", string.Empty, 2);
     dictionary["Tst3"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ig01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ig02"] = new Triplet("Up", string.Empty, 2);
     dictionary["Ig03"] = new Triplet("Up", string.Empty, 2);
     dictionary["Qc31"] = new Triplet("Up", string.Empty, 2);
     dictionary["Qc12"] = new Triplet("Up", string.Empty, 2);
     dictionary["Qc32"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sp01"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sh"] = new Triplet("Up", string.Empty, 2);
     dictionary["Upg1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Opwv1"] = new Triplet("Up", string.Empty, 2);
     dictionary["Alav"] = new Triplet("Up", string.Empty, 2);
     dictionary["Im1k"] = new Triplet("Up", string.Empty, 2);
     dictionary["Nt95"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mot2001"] = new Triplet("Up", string.Empty, 2);
     dictionary["Motv200"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mot72"] = new Triplet("Up", string.Empty, 2);
     dictionary["Mot76"] = new Triplet("Up", string.Empty, 2);
     dictionary["Scp6000"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotD5"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotF0"] = new Triplet("Up", string.Empty, 2);
     dictionary["SghA400"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sec03"] = new Triplet("Up", string.Empty, 2);
     dictionary["SieC3i"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sn17"] = new Triplet("Up", string.Empty, 2);
     dictionary["Scp4700"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sec02"] = new Triplet("Up", string.Empty, 2);
     dictionary["Sy15"] = new Triplet("Up", string.Empty, 2);
     dictionary["Db520"] = new Triplet("Up", string.Empty, 2);
     dictionary["L430V03J02"] = new Triplet("Up", string.Empty, 2);
     dictionary["OPWVSDK"] = new Triplet("Up", string.Empty, 2);
     dictionary["OPWVSDK6"] = new Triplet("Opwvsdk", string.Empty, 3);
     dictionary["OPWVSDK6Plus"] = new Triplet("Opwvsdk", string.Empty, 3);
     dictionary["KDDICA21"] = new Triplet("Up", string.Empty, 2);
     dictionary["KDDITS21"] = new Triplet("Up", string.Empty, 2);
     dictionary["KDDISA21"] = new Triplet("Up", string.Empty, 2);
     dictionary["KM100"] = new Triplet("Up", string.Empty, 2);
     dictionary["LGELX5350"] = new Triplet("Up", string.Empty, 2);
     dictionary["HitachiP300"] = new Triplet("Up", string.Empty, 2);
     dictionary["SIES46"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotorolaV60G"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotorolaV708"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotorolaV708A"] = new Triplet("Up", string.Empty, 2);
     dictionary["MotorolaE360"] = new Triplet("Up", string.Empty, 2);
     dictionary["SonyericssonA1101S"] = new Triplet("Up", string.Empty, 2);
     dictionary["PhilipsFisio820"] = new Triplet("Up", string.Empty, 2);
     dictionary["CasioA5302"] = new Triplet("Up", string.Empty, 2);
     dictionary["TCLL668"] = new Triplet("Up", string.Empty, 2);
     dictionary["KDDITS24"] = new Triplet("Up", string.Empty, 2);
     dictionary["SIES55"] = new Triplet("Up", string.Empty, 2);
     dictionary["SHARPGx10"] = new Triplet("Up", string.Empty, 2);
     dictionary["BenQAthena"] = new Triplet("Up", string.Empty, 2);
     dictionary["Opera"] = new Triplet("Default", string.Empty, 1);
     dictionary["Opera1to3beta"] = new Triplet("Opera", string.Empty, 2);
     dictionary["Opera4"] = new Triplet("Opera", string.Empty, 2);
     dictionary["Opera4beta"] = new Triplet("Opera4", string.Empty, 3);
     dictionary["Opera5to9"] = new Triplet("Opera", string.Empty, 2);
     dictionary["Opera6to9"] = new Triplet("Opera5to9", string.Empty, 3);
     dictionary["Opera7to9"] = new Triplet("Opera6to9", string.Empty, 4);
     dictionary["Opera8to9"] = new Triplet("Opera7to9", string.Empty, 5);
     dictionary["OperaPsion"] = new Triplet("Opera", string.Empty, 2);
     dictionary["Palmscape"] = new Triplet("Default", string.Empty, 1);
     dictionary["PalmscapeVersion"] = new Triplet("Palmscape", string.Empty, 2);
     dictionary["AusPalm"] = new Triplet("Default", string.Empty, 1);
     dictionary["SharpPda"] = new Triplet("Default", string.Empty, 1);
     dictionary["ZaurusMiE1"] = new Triplet("Sharppda", string.Empty, 2);
     dictionary["ZaurusMiE21"] = new Triplet("Sharppda", string.Empty, 2);
     dictionary["ZaurusMiE25"] = new Triplet("Sharppda", string.Empty, 2);
     dictionary["Panasonic"] = new Triplet("Default", string.Empty, 1);
     dictionary["PanasonicGAD95"] = new Triplet("Panasonic", string.Empty, 2);
     dictionary["PanasonicGAD87"] = new Triplet("Panasonic", string.Empty, 2);
     dictionary["PanasonicGAD87A39"] = new Triplet("Panasonicgad87", string.Empty, 3);
     dictionary["PanasonicGAD87A38"] = new Triplet("Panasonicgad87", string.Empty, 3);
     dictionary["MSPIE06"] = new Triplet("Default", string.Empty, 1);
     dictionary["SKTDevices"] = new Triplet("Default", string.Empty, 1);
     dictionary["SKTDevicesHyundai"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["PSE200"] = new Triplet("Sktdeviceshyundai", string.Empty, 3);
     dictionary["SKTDevicesHanhwa"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["SKTDevicesJTEL"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["JTEL01"] = new Triplet("Sktdevicesjtel", string.Empty, 3);
     dictionary["JTELNate"] = new Triplet("Jtel01", string.Empty, 4);
     dictionary["SKTDevicesLG"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["SKTDevicesMotorola"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["SKTDevicesV730"] = new Triplet("Sktdevicesmotorola", string.Empty, 3);
     dictionary["SKTDevicesNokia"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["SKTDevicesSKTT"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["SKTDevicesSamSung"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["SCHE150"] = new Triplet("Sktdevicessamsung", string.Empty, 3);
     dictionary["SKTDevicesEricsson"] = new Triplet("Sktdevices", string.Empty, 2);
     dictionary["WinWap"] = new Triplet("Default", string.Empty, 1);
     dictionary["Xiino"] = new Triplet("Default", string.Empty, 1);
     dictionary["XiinoV2"] = new Triplet("Xiino", string.Empty, 2);
 }