//SERIALIZACAO: A classe XMLSerializer irá usar este metodo para pegar um item para serializar no xml.
        public DictionaryEntry this[int index]
        {
            get
            {
                if (_enumerator == null)  // lazy
                    _enumerator = _hashTable.GetEnumerator();

                // Acessar um item cuja a posicao seja anterior a ultima recebida é anormal,
                // pois o XMLSerializaer irá chamar este metodo varias vezes, passando o indice
                // de forma crescente.
                // Mas, caso isso aconteça, então é necessario chamar o Reset() do enumerator
                // pois ele trabalha 'forward-only'.
                if (index < _position)
                {
                    _enumerator.Reset();
                    _position = -1;
                }

                while (_position < index)
                {
                    _enumerator.MoveNext();
                    _position++;
                }
                return _enumerator.Entry;
            }
        }
Ejemplo n.º 2
0
        public override void SendMessageToUser(IDictionaryEnumerator pp, string sMes, string sTitle)
        {
            Console.WriteLine("SendMessageToUser " + pp.Value.ToString());
            string attach_post_key = "";
            string auth_key = "";
            m_Client.Referer = ForumPath + "/index.php?act=Msg&CODE=4&MID=" + pp.Key.ToString();
            m_Response = m_Client.DownloadString(m_sForumPath + "/index.php?act=Msg&CODE=4&MID=" + pp.Key.ToString());
            Match mc1 = Regex.Match(m_Response, "attach_post_key\" value\\=\"(.*)\"\\s*\\/\\>");
            if (mc1.Success)
            {
                attach_post_key = mc1.Groups[1].Value;
            }

            mc1 = Regex.Match(m_Response, "auth_key\" value\\=\"(.*)\"\\s*\\/\\>");
            if (mc1.Success)
            {
                auth_key = mc1.Groups[1].Value;
            }

            string POSTDATA =
                "removeattachid=0" +
                "&OID=0" +
                "&act=Msg" +
                "&CODE=04" +
                "&MODE=01" +
                "&attach_post_key=" + attach_post_key +
                "&auth_key=" + auth_key +
                "&entered_name=" + pp.Value.ToString() +
                "&carbon_copy=" +
                "&msg_title=" + sTitle +
                "&ed-0_wysiwyg_used=0" +
                "&editor_ids%5B%5D=ed-0" +
                "&Post=" + sMes;
            m_Response = m_Client.UploadString(m_sForumPath + "/index.php?act=msg", POSTDATA);
        }
 internal override IDictionaryEnumerator CreateEnumerator()
 {
     IDictionaryEnumerator[] enumerators = new IDictionaryEnumerator[this._caches.Length];
     int index = 0;
     int length = this._caches.Length;
     while (index < length)
     {
         enumerators[index] = this._caches[index].CreateEnumerator();
         index++;
     }
     return new AggregateEnumerator(enumerators);
 }
 public MessageDictionaryEnumerator(MessageDictionary md, IDictionary hashtable)
 {
     this._md = md;
     if (hashtable != null)
     {
         this._enumHash = hashtable.GetEnumerator();
     }
     else
     {
         this._enumHash = null;
     }
 }
Ejemplo n.º 5
0
        internal static void PackageKeys(IDictionaryEnumerator dicEnu, out string keyPackage, out int keyCount)
        {
            StringBuilder keys = new StringBuilder(1024);
            keyCount = 0;

            while (dicEnu.MoveNext())
            {
                keys.Append(dicEnu.Key + "\"");
                keyCount++;
            }

            keyPackage = keys.ToString();
        }
        // Serialization: XmlSerializer uses this one to get one item at the time
        public DictionaryEntry this[int index]
        {
            get
            {
                if (_enumerator == null)  // lazy initialization
                    _enumerator = _hashTable.GetEnumerator();

                // Accessing an item that is before the current position is something that
                // shouldn't normally happen because XmlSerializer calls indexer with a constantly
                // increasing index that starts from zero.
                // Trying to go backward requires the reset of the enumerator, followed by appropriate
                // number of increments. (Enumerator acts as a forward-only iterator.)
                if (index < _position)
                {
                    _enumerator.Reset();
                    _position = -1;
                }

                while (_position < index)
                {
                    _enumerator.MoveNext();
                    _position++;
                }
                //Checking if the object contained in Hashtable is also a Hashtable, then_
                // convert same object into HashtableSerializationProxy object.
                //e.g: objectH in Hashtable[Key, ObjectH] is also a Hashtable..,
                // then objectH must converted into HashtableSerializationProxy, i.e. Hahtable[Key, new HashtableSerializationProxy(objectH)]
                try
                {
                    if (_enumerator.Entry.Value.GetType() == typeof(Hashtable))
                    {
                        HashtableSerializationProxy _InnerHashTableProxy = new HashtableSerializationProxy((Hashtable)_enumerator.Entry.Value);
                        _InnerDictionaryEntry = new DictionaryEntry(_enumerator.Entry.Key, _InnerHashTableProxy);

                        return _InnerDictionaryEntry;
                    }
                    else
                    {
                        return _enumerator.Entry;
                    }
                }
                catch(Exception ex)
                {
                    return _InnerDictionaryEntry = new DictionaryEntry(_enumerator.Entry.Key, "");
                }
            }
        }
        /// <summary>
        /// Constructs a new instance of <see cref="MinifierResourceStrings"/>.
        /// </summary>
        /// <param name="enumerator">The dictionary to enumerate for values.</param>
        public MinifierResourceStrings(IDictionaryEnumerator enumerator)
        {
            this.NameValuePairs = new Dictionary<string, string>();

            if (enumerator != null)
            {
                // use the IDictionaryEnumerator to add properties to the collection
                while (enumerator.MoveNext())
                {
                    // get the property name
                    string propertyName = enumerator.Key.ToString();

                    // set the name/value in the resource object
                    this.NameValuePairs[propertyName] = enumerator.Value.ToString();
                }
            }
        }
Ejemplo n.º 8
0
		private void SetEnumerator(int i)
		{
			if (_enumerator == null)
			{
				_enumerator = _dictionary.GetEnumerator();
				_enumerator.MoveNext();
			}

			if (_currentIndex > i)
			{
				_currentIndex = 0;
				_enumerator.Reset();
				_enumerator.MoveNext();
			}

			for (; _currentIndex < i; _currentIndex++)
				_enumerator.MoveNext();
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Populates the trees' right list with objects contained in the enumerator.
 /// </summary>
 /// <param name="e"></param>
 public void Populate(IDictionaryEnumerator e) 
 {
     if (e != null)
     {
         if (_rightList == null) _rightList = new ArrayList();
         if (e is RedBlackEnumerator)
         {
             while (e.MoveNext())
             {
                 HashVector tbl = e.Value as HashVector;
                 
                 _rightList.AddRange(tbl.Keys);
             }
         }
         else
         {
             while (e.MoveNext())
             {
                 _rightList.Add(e.Key);
             }
         }
     }
 }
Ejemplo n.º 10
0
    public static void Main(string[] args)
    {
        Storage db = StorageFactory.Instance.CreateStorage();

        db.SetProperty("perst.concurrent.iterator", true);
        string path = Directory.Exists("tst") ? "./" : "../../";

        db.Open("@" + path + "tst/TestAlloc/testalloc.mfd", 128 * 1024);
        byte[] buf = new byte[1024];
        int    rc;

        string[] files = Directory.GetFiles(path + "src/impl", "*.cs");
#if USE_GENERICS
        Index <string, Blob> root = (Index <string, Blob>)db.Root;
#else
        Index root = (Index)db.Root;
#endif
        if (root == null || root.Count == 0)
        {
            if (root == null)
            {
#if USE_GENERICS
                root = db.CreateIndex <string, Blob>(true);
#else
                root = db.CreateIndex(typeof(string), true);
#endif
                db.Root = root;
                db.RegisterCustomAllocator(typeof(Blob), db.CreateBitmapAllocator(1024, 0x1000000000000000L, 0x100000, long.MaxValue));
            }
            foreach (string file in files)
            {
                FileStream fin  = new FileStream(file, FileMode.Open, FileAccess.Read);
                Blob       blob = db.CreateBlob();
                Stream     bout = blob.GetStream();
                while ((rc = fin.Read(buf, 0, buf.Length)) > 0)
                {
                    bout.Write(buf, 0, rc);
                }
                root[file] = blob;
                fin.Close();
                bout.Close();
            }
            Console.WriteLine("Database is initialized");
        }
        else
        {
            foreach (string file in files)
            {
                byte[] buf2 = new byte[1024];
#if USE_GENERICS
                Blob blob = root[file];
#else
                Blob blob = (Blob)root[file];
#endif
                if (blob == null)
                {
                    Console.WriteLine("File " + file + " not found in database");
                    continue;
                }
                Stream     bin = blob.GetStream();
                FileStream fin = new FileStream(file, FileMode.Open, FileAccess.Read);
                while ((rc = fin.Read(buf, 0, buf.Length)) > 0)
                {
                    int rc2 = bin.Read(buf2, 0, buf2.Length);
                    if (rc != rc2)
                    {
                        Console.WriteLine("Different file size: " + rc + " .vs. " + rc2);
                        break;
                    }
                    while (--rc >= 0 && buf[rc] == buf2[rc])
                    {
                        ;
                    }
                    if (rc >= 0)
                    {
                        Console.WriteLine("Content of the files is different: " + buf[rc] + " .vs. " + buf2[rc]);
                        break;
                    }
                }
                fin.Close();
                bin.Close();
            }
            Console.WriteLine("Verification completed");

            IDictionaryEnumerator e = root.GetDictionaryEnumerator();
            while (e.MoveNext())
            {
                Blob file = (Blob)e.Value;
                root.Remove((string)e.Key, file);
                file.Deallocate();
            }
            //root.Put("dummy", db.CreateBlob());
            Console.WriteLine("Cleanup completed");
        }
        db.Close();
    }
Ejemplo n.º 11
0
        private void SerializeDictionary(JsonWriter writer, IDictionary values, JsonDictionaryContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            object underlyingDictionary = values is IWrappedDictionary wrappedDictionary ? wrappedDictionary.UnderlyingDictionary : values;

            OnSerializing(writer, contract, underlyingDictionary);
            _serializeStack.Add(underlyingDictionary);

            WriteObjectStart(writer, underlyingDictionary, contract, member, collectionContract, containerProperty);

            if (contract.ItemContract == null)
            {
                contract.ItemContract = Serializer._contractResolver.ResolveContract(contract.DictionaryValueType ?? typeof(object));
            }

            if (contract.KeyContract == null)
            {
                contract.KeyContract = Serializer._contractResolver.ResolveContract(contract.DictionaryKeyType ?? typeof(object));
            }

            int initialDepth = writer.Top;

            // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations.
            IDictionaryEnumerator e = values.GetEnumerator();

            try
            {
                while (e.MoveNext())
                {
                    DictionaryEntry entry = e.Entry;

                    string propertyName = GetPropertyName(writer, entry.Key, contract.KeyContract, out bool escape);

                    propertyName = (contract.DictionaryKeyResolver != null)
                        ? contract.DictionaryKeyResolver(propertyName)
                        : propertyName;

                    try
                    {
                        object       value         = entry.Value;
                        JsonContract valueContract = contract.FinalItemContract ?? GetContractSafe(value);

                        if (ShouldWriteReference(value, null, valueContract, contract, member))
                        {
                            writer.WritePropertyName(propertyName, escape);
                            WriteReference(writer, value);
                        }
                        else
                        {
                            if (!CheckForCircularReference(writer, value, null, valueContract, contract, member))
                            {
                                continue;
                            }

                            writer.WritePropertyName(propertyName, escape);

                            SerializeValue(writer, value, valueContract, null, contract, member);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (IsErrorHandled(underlyingDictionary, contract, propertyName, null, writer.ContainerPath, ex))
                        {
                            HandleError(writer, initialDepth);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
            finally
            {
                (e as IDisposable)?.Dispose();
            }

            writer.WriteEndObject();

            _serializeStack.RemoveAt(_serializeStack.Count - 1);

            OnSerialized(writer, contract, underlyingDictionary);
        }
        public string CreateClassFromResourceSet(ResourceSet resourceSet, string nameSpace, string classname, string fileName)
        {
            IsVb = IsFileVb(fileName);

            StringBuilder sbClass = new StringBuilder();

            CreateClassHeader(classname, nameSpace, IsVb, sbClass);

            string indent = "\t\t";

            // Any resource set that contains a '.' is considered a Local Resource
            bool IsGlobalResource = !classname.Contains(".");

            // We'll enumerate through the Recordset to get all the resources
            IDictionaryEnumerator Enumerator = resourceSet.GetEnumerator();

            // We have to turn into a concrete Dictionary
            while (Enumerator.MoveNext())
            {
                DictionaryEntry item = (DictionaryEntry)Enumerator.Current;
                if (item.Value == null)
                {
                    item.Value = string.Empty;
                }

                string typeName = item.Value.GetType().FullName;
                string key      = item.Key as string;
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }

                string varName = SafeVarName(key);

                // It's a string
                if (!IsVb)
                {
                    sbClass.Append(indent + "public static " + typeName + " " + varName + "\r\n" + indent + "{\r\n");
                    sbClass.AppendFormat(indent + "\tget\r\n" +
                                         indent + "\t{{\r\n" +
                                         indent +
                                         (string.IsNullOrEmpty(typeName) || typeName == "System.String"
                                         ? "\t\t" + @"return GeneratedResourceHelper.GetResourceString(""{0}"",""{1}"",ResourceManager,GeneratedResourceSettings.ResourceAccessMode);" + "\r\n"
                                         : "\t\t" + @"return ({2}) GeneratedResourceHelper.GetResourceObject(""{0}"",""{1}"",ResourceManager,GeneratedResourceSettings.ResourceAccessMode);" + "\r\n")
                                         +
                                         indent + "\t}}\r\n",
                                         classname, key, typeName);
                    sbClass.Append(indent + "}\r\n\r\n");
                }
                else
                {
                    sbClass.Append(indent + "Public Shared Property " + varName + "() as " + typeName + "\r\n");
                    sbClass.AppendFormat(indent + "\tGet\r\n" + indent + "\t\treturn CType( HttpContext.GetGlobalResourceObject(\"{0}\",\"{1}\"), {2})\r\n",
                                         classname, key, typeName);
                    sbClass.Append(indent + "\tEnd Get\r\n");
                    sbClass.Append(indent + "End Property\r\n\r\n");
                }
            }

            if (!IsVb)
            {
                sbClass.Append("\t}\r\n\r\n");
            }
            else
            {
                sbClass.Append("End Class\r\n\r\n");
            }

            string Output = CreateNameSpaceWrapper(nameSpace, IsVb, sbClass.ToString());

            if (!string.IsNullOrEmpty(fileName))
            {
                File.WriteAllText(fileName, Output);
                return(Output);
            }

            return(sbClass.ToString());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Compare a dictionary
        /// </summary>
        /// <param name="object1"></param>
        /// <param name="object2"></param>
        /// <param name="breadCrumb"></param>
        void CompareIDictionary(object object1, object object2, string breadCrumb)
        {
            IDictionary iDict1 = object1 as IDictionary;
            IDictionary iDict2 = object2 as IDictionary;

            if (iDict1 == null) //This should never happen, null check happens one level up
            {
                throw new ArgumentNullException("object1");
            }

            if (iDict2 == null) //This should never happen, null check happens one level up
            {
                throw new ArgumentNullException("object2");
            }

            try
            {
                _parents.Add(object1);
                _parents.Add(object2);

                //Objects must be the same length
                if (iDict1.Count != iDict2.Count)
                {
                    Differences.Add(string.Format("object1{0}.Count != object2{0}.Count ({1},{2})", breadCrumb,
                                                  iDict1.Count, iDict2.Count));

                    if (Differences.Count >= MaxDifferences)
                    {
                        return;
                    }
                }

                IDictionaryEnumerator enumerator1 = iDict1.GetEnumerator();
                IDictionaryEnumerator enumerator2 = iDict2.GetEnumerator();

                while (enumerator1.MoveNext() && enumerator2.MoveNext())
                {
                    string currentBreadCrumb = AddBreadCrumb(breadCrumb, "Key", string.Empty, -1);

                    Compare(enumerator1.Key, enumerator2.Key, currentBreadCrumb);

                    if (Differences.Count >= MaxDifferences)
                    {
                        return;
                    }

                    currentBreadCrumb = AddBreadCrumb(breadCrumb, "Value", string.Empty, -1);

                    Compare(enumerator1.Value, enumerator2.Value, currentBreadCrumb);

                    if (Differences.Count >= MaxDifferences)
                    {
                        return;
                    }
                }
            }
            finally
            {
                _parents.Remove(object1);
                _parents.Remove(object2);
            }
        }
Ejemplo n.º 14
0
 internal StringIntegerHashtableEnumerator(StringIntegerHashtable enumerable)
 {
     innerEnumerator = enumerable.InnerHash.GetEnumerator();
 }
Ejemplo n.º 15
0
 public XPathCollectionEnumerator(Hashtable xpathes) {
     hashEnum = xpathes.GetEnumerator();
 }
Ejemplo n.º 16
0
 internal FrameworkInfoDictionaryEnumerator(FrameworkInfoDictionary enumerable)
 {
     _innerEnumerator = enumerable.InnerHash.GetEnumerator();
 }
Ejemplo n.º 17
0
        public override fsResult TrySerialize(object instance_, out fsData serialized, Type storageType)
        {
            serialized = fsData.Null;

            var result = fsResult.Success;

            var instance = (IDictionary)instance_;

            Type keyStorageType, valueStorageType;

            GetKeyValueTypes(instance.GetType(), out keyStorageType, out valueStorageType);

            // No other way to iterate dictionaries and still have access to the key/value info
            IDictionaryEnumerator enumerator = instance.GetEnumerator();

            bool allStringKeys    = true;
            var  serializedKeys   = new List <fsData>(instance.Count);
            var  serializedValues = new List <fsData>(instance.Count);

            while (enumerator.MoveNext())
            {
                fsData keyData, valueData;
                if ((result += Serializer.TrySerialize(keyStorageType, enumerator.Key, out keyData)).Failed)
                {
                    return(result);
                }
                if ((result += Serializer.TrySerialize(valueStorageType, enumerator.Value, out valueData)).Failed)
                {
                    return(result);
                }

                serializedKeys.Add(keyData);
                serializedValues.Add(valueData);

                allStringKeys &= keyData.IsString;
            }

            if (allStringKeys)
            {
                serialized = fsData.CreateDictionary();
                var serializedDictionary = serialized.AsDictionary;

                for (int i = 0; i < serializedKeys.Count; ++i)
                {
                    fsData key   = serializedKeys[i];
                    fsData value = serializedValues[i];
                    serializedDictionary[key.AsString] = value;
                }
            }
            else
            {
                serialized = fsData.CreateList(serializedKeys.Count);
                var serializedList = serialized.AsList;

                for (int i = 0; i < serializedKeys.Count; ++i)
                {
                    fsData key   = serializedKeys[i];
                    fsData value = serializedValues[i];

                    var container = new Dictionary <string, fsData>();
                    container["Key"]   = key;
                    container["Value"] = value;
                    serializedList.Add(new fsData(container));
                }
            }

            return(result);
        }
Ejemplo n.º 18
0
 private void InitUniqueMonsterConfig(NPCLevelMetaData npcLevelMetaData)
 {
     if (this.uniqueMonsterID != 0)
     {
         UniqueMonsterMetaData uniqueMonsterMetaData = MonsterData.GetUniqueMonsterMetaData(this.uniqueMonsterID);
         base.baseMaxHP = base.maxHP = base.HP = (this.metaConfig.HP * uniqueMonsterMetaData.HPRatio) * npcLevelMetaData.HPRatio;
         base.defense   = (this.metaConfig.defense * uniqueMonsterMetaData.defenseRatio) * npcLevelMetaData.DEFRatio;
         base.attack    = (this.metaConfig.attack * uniqueMonsterMetaData.attackRatio) * npcLevelMetaData.ATKRatio;
         if (uniqueMonsterMetaData.abilities.Length > 0)
         {
             LuaState state = new LuaState();
             IDictionaryEnumerator enumerator = ((LuaTable)state.DoString(uniqueMonsterMetaData.abilities)[0]).GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     ConfigAbility   abilityConfig;
                     DictionaryEntry current     = (DictionaryEntry)enumerator.Current;
                     string          key         = (string)current.Key;
                     LuaTable        table2      = (LuaTable)current.Value;
                     string          monsterName = uniqueMonsterMetaData.monsterName;
                     if (monsterName == null)
                     {
                         abilityConfig = AbilityData.GetAbilityConfig(key);
                     }
                     else
                     {
                         abilityConfig = AbilityData.GetAbilityConfig(key, monsterName);
                     }
                     Dictionary <string, object> dictionary  = new Dictionary <string, object>();
                     IDictionaryEnumerator       enumerator2 = table2.GetEnumerator();
                     try
                     {
                         while (enumerator2.MoveNext())
                         {
                             DictionaryEntry entry2 = (DictionaryEntry)enumerator2.Current;
                             string          str3   = (string)entry2.Key;
                             if (entry2.Value is double)
                             {
                                 dictionary.Add(str3, (float)((double)entry2.Value));
                             }
                             else if (entry2.Value is string)
                             {
                                 dictionary.Add(str3, (string)entry2.Value);
                             }
                         }
                     }
                     finally
                     {
                         IDisposable disposable = enumerator2 as IDisposable;
                         if (disposable == null)
                         {
                         }
                         disposable.Dispose();
                     }
                     base.appliedAbilities.Add(Tuple.Create <ConfigAbility, Dictionary <string, object> >(abilityConfig, dictionary));
                 }
             }
             finally
             {
                 IDisposable disposable2 = enumerator as IDisposable;
                 if (disposable2 == null)
                 {
                 }
                 disposable2.Dispose();
             }
         }
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Get the first ReportParameter from the report.
 /// </summary>
 /// <returns>The first ReportParameter.</returns>
 public ReportParameter GetFirst()
 {
     _ParamTableEnum = _ParamTable.GetEnumerator();
     return((ReportParameter)_ParamTableEnum.Current);
 }
Ejemplo n.º 20
0
        private void onRewardItemLoaded(string path, GameObject prefab)
        {
            List <DReward> list = new List <DReward>();

            foreach (IRewardable item in chestReward)
            {
                if (item.IsEmpty() || !Enum.IsDefined(typeof(RewardCategory), item.RewardType))
                {
                    continue;
                }
                RewardCategory category = (RewardCategory)Enum.Parse(typeof(RewardCategory), item.RewardType);
                Type           type     = item.Reward.GetType();
                if (item is EquipmentInstanceReward)
                {
                    EquipmentInstanceReward equipmentInstanceReward = (EquipmentInstanceReward)item;
                    for (int i = 0; i < equipmentInstanceReward.EquipmentInstances.Count; i++)
                    {
                        DReward dReward = new DReward();
                        dReward.Category         = RewardCategory.equipmentInstances;
                        dReward.EquipmentRequest = equipmentInstanceReward.EquipmentInstances[i];
                        list.Add(dReward);
                    }
                }
                else if (typeof(IList).IsAssignableFrom(type))
                {
                    IList list2 = item.Reward as IList;
                    if (list2 != null && list2.Count > 0)
                    {
                        for (int j = 0; j < list2.Count; j++)
                        {
                            DReward dReward2 = new DReward();
                            dReward2.UnlockID = list2[j];
                            dReward2.Category = category;
                            list.Add(dReward2);
                        }
                    }
                }
                else
                {
                    if (!typeof(IDictionary).IsAssignableFrom(type))
                    {
                        continue;
                    }
                    IDictionary dictionary = item.Reward as IDictionary;
                    if (dictionary != null && dictionary.Count > 0)
                    {
                        IDictionaryEnumerator enumerator2 = dictionary.GetEnumerator();
                        while (enumerator2.MoveNext())
                        {
                            DReward dReward2 = new DReward();
                            dReward2.UnlockID = enumerator2.Key;
                            dReward2.Data     = enumerator2.Value;
                            dReward2.Category = category;
                            list.Add(dReward2);
                        }
                    }
                }
            }
            for (int j = 0; j < list.Count; j++)
            {
                createRewardItem(list[j], prefab);
            }
            float num = ((list.Count > 2) ? ExtraItemCellSize : defaultCellSize);

            RewardContainer.GetComponent <GridLayoutGroup>().cellSize = new Vector2(num, num);
            logRewardBI(list);
        }
Ejemplo n.º 21
0
            public override void LoadChildNodes()
            {
                //Load child nodes of this node (data)
                Hashtable             oDict = null;
                IDictionaryEnumerator oEnum = null;

                //Clear nodes and populate
                base.Nodes.Clear();
                #region Read terminals from config file (key=terminal name/value=database connection)
                try {
                    oDict            = (Hashtable)ConfigurationManager.GetSection(KEY_TERMINALS);
                    oEnum            = oDict.GetEnumerator();
                    base.mChildNodes = new TreeNode[oDict.Count];
                    for (int i = 0; i < base.mChildNodes.Length; i++)
                    {
                        //Create a terminal store for each entry; wrap in a custom treenode
                        oEnum.MoveNext();
                        DictionaryEntry oEntry   = (DictionaryEntry)oEnum.Current;
                        LabelStoreNode  treeNode = null;
                        try {
                            LabelStore oStore = new TerminalLabelStore(oEntry.Value.ToString());
                            treeNode = new LabelStoreNode(oEntry.Key.ToString(), App.ICON_CLOSED, App.ICON_CLOSED, oStore);
                            treeNode.Refresh();
                        }
                        catch (ApplicationException ex) { throw ex; }
                        catch (Exception ex) { throw new ApplicationException("Unexpected error loading enterprise child nodes.", ex); }
                        base.mChildNodes[i] = treeNode;
                        base.Nodes.Add(treeNode);
                        treeNode.LoadChildNodes();
                    }
                }
                catch (Exception ex) { throw new ApplicationException("Failed to load all terminal label store nodes for enterprise node " + base.Text + ".", ex); }
                #endregion
                #region Read directory label stores from config file
                try {
                    oDict            = (Hashtable)ConfigurationManager.GetSection(KEY_TEMPLATES);
                    oEnum            = oDict.GetEnumerator();
                    base.mChildNodes = new TreeNode[oDict.Count];
                    for (int i = 0; i < base.mChildNodes.Length; i++)
                    {
                        //Create a terminal store for each entry; wrap in a custom treenode
                        oEnum.MoveNext();
                        DictionaryEntry oEntry   = (DictionaryEntry)oEnum.Current;
                        LabelStoreNode  treeNode = null;
                        try {
                            LabelStore oStore = new DirectoryLabelStore(oEntry.Value.ToString());
                            treeNode = new LabelStoreNode(oEntry.Key.ToString(), App.ICON_CLOSED, App.ICON_CLOSED, oStore);
                            treeNode.Refresh();
                        }
                        catch (Exception) { }
                        base.mChildNodes[i] = treeNode;
                        base.Nodes.Add(treeNode);
                        treeNode.LoadChildNodes();
                    }
                }
                catch (Exception ex) { throw new ApplicationException("Failed to load all directory label store nodes for enterprise node " + base.Text + ".", ex); }
                #endregion
                #region Read file label stores from config file
                try {
                    oDict            = (Hashtable)ConfigurationManager.GetSection(KEY_BACKUPS);
                    oEnum            = oDict.GetEnumerator();
                    base.mChildNodes = new TreeNode[oDict.Count];
                    for (int i = 0; i < base.mChildNodes.Length; i++)
                    {
                        //Create a terminal store for each entry; wrap in a custom treenode
                        oEnum.MoveNext();
                        DictionaryEntry oEntry   = (DictionaryEntry)oEnum.Current;
                        LabelStoreNode  treeNode = null;
                        try {
                            LabelStore oStore = new FileLabelStore(oEntry.Value.ToString());
                            treeNode = new LabelStoreNode(oEntry.Key.ToString(), App.ICON_CLOSED, App.ICON_CLOSED, oStore);
                            treeNode.Refresh();
                        }
                        catch (Exception) { }
                        base.mChildNodes[i] = treeNode;
                        base.Nodes.Add(treeNode);
                        treeNode.LoadChildNodes();
                    }
                }
                catch (Exception ex) { throw new ApplicationException("Failed to load all file label store nodes for enterprise node " + base.Text + ".", ex); }
                #endregion
            }
Ejemplo n.º 22
0
			public ImportFileEnumerator(FdoCache cache, ScrSfFileList fileList, Hashtable sourceTable)
			{
				if (sourceTable == null)
				{
					m_fileEnumerator = fileList.GetEnumerator();
					m_sourceEnumerator = null;
				}
				else
				{
					m_fileEnumerator = null;
					m_sourceEnumerator = sourceTable.GetEnumerator();
				}
				Reset();
			}
Ejemplo n.º 23
0
        internal override IDictionaryEnumerator CreateEnumerator() {
            IDictionaryEnumerator[] enumerators = new IDictionaryEnumerator[_caches.Length];
            for (int i = 0, c = _caches.Length; i < c; i++) {
                enumerators[i] = _caches[i].CreateEnumerator();
            }

            return new AggregateEnumerator(enumerators);
        }
Ejemplo n.º 24
0
        public string[] CallPrc(string _ProcName, string[] _OutputResults, Hashtable ht, out string str)
        {
            str = null;
            if (_ProcName == null || _ProcName == "")
            {
                return(null);
            }
            try
            {
                Conn = OracleConnManager.GetCon();
            }
            catch (Exception ex)
            {
                str = "bbb" + ex.Message;
            }
            OracleCommand cmd = Conn.CreateCommand();

            try {
                cmd.CommandType = CommandType.StoredProcedure;//设置调用的类型为存储过程
                cmd.CommandText = _ProcName;

                OracleParameter _Parme;
                if (_OutputResults != null)
                {
                    for (int i = 0; i < _OutputResults.Length; i++)
                    {
                        _Parme           = cmd.Parameters.Add(_OutputResults[i], OracleType.NVarChar, 1000);
                        _Parme.Direction = ParameterDirection.Output;
                    }
                }

                if (ht == null || ht.Count <= 0)
                {
                }
                else
                {
                    IDictionaryEnumerator ide = ht.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        _Parme           = cmd.Parameters.Add(ide.Key.ToString(), OracleType.NVarChar);
                        _Parme.Direction = ParameterDirection.Input;
                        _Parme.Value     = ide.Value;
                    }
                }

                cmd.ExecuteNonQuery();

                if (_OutputResults != null)
                {
                    for (int i = 0; i < _OutputResults.Length; i++)
                    {
                        _OutputResults[i] = cmd.Parameters[_OutputResults[i]].Value.ToString();
                    }
                }

                return(_OutputResults);
            } catch (Exception ex) {
                throw ex;
            } finally {
                cmd.Dispose();
                CloseConnection();
            }
        }
Ejemplo n.º 25
0
 internal ConfigurationMapEnumerator(ConfigurationMap enumerable) {
     _innerEnumerator = enumerable.InnerHash.GetEnumerator();
 }
Ejemplo n.º 26
0
        private void SetOptionsInternal(SetPSReadLineOption options)
        {
            if (options.ContinuationPrompt != null)
            {
                Options.ContinuationPrompt = options.ContinuationPrompt;
            }
            if (options._historyNoDuplicates.HasValue)
            {
                Options.HistoryNoDuplicates = options.HistoryNoDuplicates;
            }
            if (options._historySearchCursorMovesToEnd.HasValue)
            {
                Options.HistorySearchCursorMovesToEnd = options.HistorySearchCursorMovesToEnd;
            }
            if (options._addToHistoryHandlerSpecified)
            {
                Options.AddToHistoryHandler = options.AddToHistoryHandler;
            }
            if (options._commandValidationHandlerSpecified)
            {
                Options.CommandValidationHandler = options.CommandValidationHandler;
            }
            if (options._maximumHistoryCount.HasValue)
            {
                Options.MaximumHistoryCount = options.MaximumHistoryCount;
                if (_history != null)
                {
                    var newHistory = new HistoryQueue <HistoryItem>(Options.MaximumHistoryCount);
                    while (_history.Count > Options.MaximumHistoryCount)
                    {
                        _history.Dequeue();
                    }
                    while (_history.Count > 0)
                    {
                        newHistory.Enqueue(_history.Dequeue());
                    }
                    _history             = newHistory;
                    _currentHistoryIndex = _history.Count;
                }
            }
            if (options._maximumKillRingCount.HasValue)
            {
                Options.MaximumKillRingCount = options.MaximumKillRingCount;
                // TODO - make _killRing smaller
            }
            if (options._editMode.HasValue)
            {
                Options.EditMode = options.EditMode;

                // Switching/resetting modes - clear out chord dispatch table
                _chordDispatchTable.Clear();

                SetDefaultBindings(Options.EditMode);
            }
            if (options._showToolTips.HasValue)
            {
                Options.ShowToolTips = options.ShowToolTips;
            }
            if (options._extraPromptLineCount.HasValue)
            {
                Options.ExtraPromptLineCount = options.ExtraPromptLineCount;
            }
            if (options._dingTone.HasValue)
            {
                Options.DingTone = options.DingTone;
            }
            if (options._dingDuration.HasValue)
            {
                Options.DingDuration = options.DingDuration;
            }
            if (options._bellStyle.HasValue)
            {
                Options.BellStyle = options.BellStyle;
            }
            if (options._completionQueryItems.HasValue)
            {
                Options.CompletionQueryItems = options.CompletionQueryItems;
            }
            if (options.WordDelimiters != null)
            {
                Options.WordDelimiters = options.WordDelimiters;
            }
            if (options._historySearchCaseSensitive.HasValue)
            {
                Options.HistorySearchCaseSensitive = options.HistorySearchCaseSensitive;
            }
            if (options._historySaveStyle.HasValue)
            {
                Options.HistorySaveStyle = options.HistorySaveStyle;
            }
            if (options._viModeIndicator.HasValue)
            {
                Options.ViModeIndicator = options.ViModeIndicator;
            }
            if (options.ViModeChangeHandler != null)
            {
                if (Options.ViModeIndicator != ViModeStyle.Script)
                {
                    throw new ParameterBindingException("ViModeChangeHandler option requires ViModeStyle.Script");
                }
                Options.ViModeChangeHandler = options.ViModeChangeHandler;
            }
            if (options.HistorySavePath != null)
            {
                Options.HistorySavePath = options.HistorySavePath;
                _historyFileMutex?.Dispose();
                _historyFileMutex         = new Mutex(false, GetHistorySaveFileMutexName());
                _historyFileLastSavedSize = 0;
            }
            if (options._ansiEscapeTimeout.HasValue)
            {
                Options.AnsiEscapeTimeout = options.AnsiEscapeTimeout;
            }
            if (options.PromptText != null)
            {
                Options.PromptText = options.PromptText;
            }
            if (options._predictionSource.HasValue)
            {
                if (_console is PlatformWindows.LegacyWin32Console && options.PredictionSource != PredictionSource.None)
                {
                    throw new ArgumentException(PSReadLineResources.PredictiveSuggestionNotSupported);
                }

                bool notTest = ReferenceEquals(_mockableMethods, this);
                if ((options.PredictionSource & PredictionSource.Plugin) != 0 && Environment.Version.Major < 6 && notTest)
                {
                    throw new ArgumentException(PSReadLineResources.PredictionPluginNotSupported);
                }

                Options.PredictionSource = options.PredictionSource;
            }
            if (options._predictionViewStyle.HasValue)
            {
                WarnWhenWindowSizeTooSmallForView(options.PredictionViewStyle, options);
                Options.PredictionViewStyle = options.PredictionViewStyle;
                _prediction.SetViewStyle(options.PredictionViewStyle);
            }
            if (options.Colors != null)
            {
                IDictionaryEnumerator e = options.Colors.GetEnumerator();
                while (e.MoveNext())
                {
                    if (e.Key is string property)
                    {
                        Options.SetColor(property, e.Value);
                    }
                }
            }
        }
Ejemplo n.º 27
0
        public EnumerableIteratorEntry(IPhpEnumerable/*!*/obj)
        {
            Debug.Assert(obj != null);

            this.isValid = false;
            this.enumerator = null;
            this.currentKey = this.currentValue = null;
            
            this.obj = obj;
        }
Ejemplo n.º 28
0
        private void PopulateValues(IDictionary from, System.Collections.Generic.List <KeyValue> to)
        {
            IDictionaryEnumerator ide           = from.GetEnumerator();
            ValueWithType         valueWithType = null;
            KeyValue keyValue = null;

            while (ide.MoveNext())
            {
                keyValue     = new KeyValue();
                keyValue.key = ide.Key.ToString();

                if (ide.Value is ArrayList)
                {
                    ArrayList list = (ArrayList)ide.Value;
                    foreach (object value in list)
                    {
                        if (value == null)
                        {
                            throw new ArgumentNullException("NCache query does not support null values. ",
                                                            (System.Exception)null);
                        }
                        Type type  = value.GetType();
                        bool isTag = CommandHelper.IsTag(type);
                        if (!(CommandHelper.IsIndexable(type) || isTag))
                        {
                            throw new ArgumentException("The provided type is not indexable. ", type.Name);
                        }
                        valueWithType       = new ValueWithType();
                        valueWithType.value = GetValueString(value);
                        if (isTag)
                        {
                            valueWithType.type = typeof(string).FullName;
                        }
                        else
                        {
                            valueWithType.type = value.GetType().FullName;
                        }

                        keyValue.value.Add(valueWithType);
                    }
                }
                else
                {
                    if (ide.Value == null)
                    {
                        throw new ArgumentNullException("NCache query does not support null values. ",
                                                        (System.Exception)null);
                    }
                    Type type  = ide.Value.GetType();
                    bool isTag = CommandHelper.IsTag(type);
                    if (!(CommandHelper.IsIndexable(type) || isTag))
                    {
                        throw new ArgumentException("The provided type is not indexable. ", type.Name);
                    }
                    valueWithType       = new ValueWithType();
                    valueWithType.value = GetValueString(ide.Value);
                    if (isTag)
                    {
                        valueWithType.type = typeof(string).FullName;
                    }
                    else
                    {
                        valueWithType.type = ide.Value.GetType().FullName;
                    }

                    keyValue.value.Add(valueWithType);
                }

                to.Add(keyValue);
            }
        }
        /// <summary>
        /// Creates a strongly typed resource from a ResourceSet object. The ResourceSet passed should always
        /// be the invariant resourceset that contains all the ResourceIds.
        ///
        /// Creates strongly typed keys for each of the keys/values.
        /// </summary>
        /// <param name="resourceSet"></param>
        /// <param name="Namespace">Namespace of the generated class. Pass Null or string.Empty to not generate a namespace</param>
        /// <param name="classname">Name of the class to generate. Pass null to use the ResourceSet name</param>
        /// <param name="fileName">Output filename for the CSharp class. If null no file is generated and only the class is returned</param>
        /// <returns></returns>
        public string CreateResxDesignerClassFromResourceSet(string resourceSetName, string nameSpace, string classname, string fileName)
        {
            // Use the custom ResourceManage to retrieve a ResourceSet
            var man         = new DbResourceManager(resourceSetName);
            var resourceSet = man.GetResourceSet(CultureInfo.InvariantCulture, false, false);

            IsVb = IsFileVb(fileName);

            StringBuilder sbClass = new StringBuilder();

            CreateResxDesignerClassHeader(classname, nameSpace, IsVb, sbClass);

            string indent = "\t\t";

            // Any resource set that contains a '.' is considered a Local Resource
            bool IsGlobalResource = !classname.Contains(".");

            // We'll enumerate through the Recordset to get all the resources
            IDictionaryEnumerator Enumerator = resourceSet.GetEnumerator();

            // We have to turn into a concrete Dictionary
            while (Enumerator.MoveNext())
            {
                DictionaryEntry item = (DictionaryEntry)Enumerator.Current;
                if (item.Value == null)
                {
                    item.Value = string.Empty;
                }

                string typeName = item.Value.GetType().FullName;
                string key      = item.Key as string;
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }

                string varName = SafeVarName(key);

                // It's a string
                if (!IsVb)
                {
                    sbClass.AppendLine(indent + "public static " + typeName + " " + varName + "\r\n" + indent + "{");
                    sbClass.AppendFormat(indent + "\tget\r\n" +
                                         indent + "\t{{\r\n" +
                                         indent + "\t\t" +
                                         (string.IsNullOrEmpty(typeName) || typeName == "System.String"
                                          ? "return ResourceManager.GetString(\"{0}\", resourceCulture);\r\n"
                                          : "return ({1})ResourceManager.GetObject(\"{0}\", resourceCulture);\r\n") +
                                         indent + "\t}}\r\n",
                                         key, typeName);
                    sbClass.AppendLine(indent + "}\r\n");
                }
                else
                {
                    sbClass.Append(indent + "Public Shared Property " + varName + "() as " + typeName + "\r\n");
                    sbClass.AppendFormat(indent + "\tGet\r\n" + indent + "\t\treturn CType( ResourceManager.GetObject(\"{1}\",resourceCulture)\r\n",
                                         classname, key, typeName);
                    sbClass.Append(indent + "\tEnd Get\r\n");
                    sbClass.Append(indent + "End Property\r\n\r\n");
                }
            }

            if (!IsVb)
            {
                sbClass.Append("\t}\r\n\r\n");
            }
            else
            {
                sbClass.Append("End Class\r\n\r\n");
            }

            string Output = CreateNameSpaceWrapper(nameSpace, IsVb, sbClass.ToString());

            if (!string.IsNullOrEmpty(fileName))
            {
                File.WriteAllText(fileName, Output);
                return(Output);
            }

            return(sbClass.ToString());
        }
Ejemplo n.º 30
0
		public bool MoveNext ()
		{
			if (pos >= dictionaries.Length) return false;

			if (!currente.MoveNext()) 
			{
				pos++;
				if (pos >= dictionaries.Length) return false;
				currente = dictionaries [pos].GetEnumerator ();
				return MoveNext ();
			}
			
			return true;
		}
        } // GetMachineAddress

        //
        // Core Serialization and Deserialization support
        //
        internal static Header[] GetMessagePropertiesAsSoapHeader(IMessage reqMsg)
        {
            IDictionary d = reqMsg.Properties;

            if (d == null)
            {
                return(null);
            }

            int count = d.Count;

            if (count == 0)
            {
                return(null);
            }

            IDictionaryEnumerator e = (IDictionaryEnumerator)d.GetEnumerator();

            // cycle through the headers to get a length
            bool[]         map = new bool[count];
            int            len = 0, i = 0;
            IMethodMessage msg = (IMethodMessage)reqMsg;

            while (e.MoveNext())
            {
                String key = (String)e.Key;
                if ((key.Length >= 2) &&
                    (String.CompareOrdinal(key, 0, "__", 0, 2) == 0)
                    &&
                    (
                        key.Equals("__Args")
                        ||
                        key.Equals("__OutArgs")
                        ||
                        key.Equals("__Return")
                        ||
                        key.Equals("__Uri")
                        ||
                        key.Equals("__MethodName")
                        ||
                        (key.Equals("__MethodSignature") &&
                         (!RemotingServices.IsMethodOverloaded(msg)) &&
                         (!msg.HasVarArgs))
                        ||
                        key.Equals("__TypeName")
                        ||
                        key.Equals("__Fault")
                        ||
                        (key.Equals("__CallContext") &&
                         ((e.Value != null) ? (((LogicalCallContext)e.Value).HasInfo == false) : true))
                    )
                    )
                {
                    i++;
                    continue;
                }
                map[i] = true;
                i++;
                len++;
            }
            if (len == 0)
            {
                return(null);
            }


            Header[] ret = new Header[len];
            e.Reset();
            int k = 0;

            i = 0;
            while (e.MoveNext())
            {
                Object key = e.Key;
                if (!map[k])
                {
                    k++;
                    continue;
                }

                Header h = e.Value as Header;

                // If the property is not a header, then make a header out of it.
                if (h == null)
                {
                    h =
                        new Header(
                            (String)key, e.Value, false,
                            "http://schemas.microsoft.com/clr/soap/messageProperties");
                }

                // <
                if (i == ret.Length)
                {
                    InternalRemotingServices.RemotingTrace("HTTPChannel::GetHeaders creating a new array of length " + (i + 1) + "\n");
                    Header[] newret = new Header[i + 1];
                    Array.Copy(ret, newret, i);
                    ret = newret;
                }
                ret[i] = h;
                i++;
                k++;
            }

            return(ret);
        } // GetMessagePropertiesAsSoapHeader
Ejemplo n.º 32
0
 internal DataTypeBaseDictionaryEnumerator(DataTypeBaseDictionary enumerable)
 {
     _innerEnumerator = enumerable.InnerHash.GetEnumerator();
 }
Ejemplo n.º 33
0
 internal ExifExtractorEnumerator(Dictionary <string, string> exif)
 {
     this.exifTable = exif;
     this.Reset();
     index = exif.GetEnumerator();
 }
Ejemplo n.º 34
0
 internal ConfigurationDictionaryEnumerator(ConfigurationDictionary enumerable)
 {
     _innerEnumerator = enumerable.InnerHash.GetEnumerator();
 }
 internal LocalValueEnumerator(Dictionary<DependencyProperty,object> properties)
 {
     this.count = properties.Count;
     this.properties = properties;
     this.propertyEnumerator = properties.GetEnumerator();
 }
Ejemplo n.º 36
0
 public void Reset()
 {
     this.index = null;
 }
Ejemplo n.º 37
0
		public void Reset ()
		{
			pos = 0;
			if (dictionaries.Length > 0)
				currente = dictionaries [0].GetEnumerator ();
		}
Ejemplo n.º 38
0
        public TinyMCE(IData Data, string Configuration)
        {
            _data = Data;
            try
            {
                string[] configSettings = Configuration.Split("|".ToCharArray());

                if (configSettings.Length > 0)
                {
                    _editorButtons = configSettings[0];

                    if (configSettings.Length > 1)
                    {
                        if (configSettings[1] == "1")
                        {
                            _enableContextMenu = true;
                        }
                    }

                    if (configSettings.Length > 2)
                    {
                        _advancedUsers = configSettings[2];
                    }

                    if (configSettings.Length > 3)
                    {
                        if (configSettings[3] == "1")
                        {
                            _fullWidth = true;
                        }
                        else if (configSettings[4].Split(',').Length > 1)
                        {
                            _width  = int.Parse(configSettings[4].Split(',')[0]);
                            _height = int.Parse(configSettings[4].Split(',')[1]);
                        }
                    }

                    // default width/height
                    if (_width < 1)
                    {
                        _width = 500;
                    }
                    if (_height < 1)
                    {
                        _height = 400;
                    }

                    // add stylesheets
                    if (configSettings.Length > 4)
                    {
                        foreach (string s in configSettings[5].Split(",".ToCharArray()))
                        {
                            _stylesheets.Add(s);
                        }
                    }

                    if (configSettings.Length > 6 && configSettings[6] != "")
                    {
                        _showLabel = bool.Parse(configSettings[6]);
                    }

                    if (configSettings.Length > 7 && configSettings[7] != "")
                    {
                        m_maxImageWidth = int.Parse(configSettings[7]);
                    }

                    // sizing
                    if (!_fullWidth)
                    {
                        config.Add("width", _width.ToString());
                        config.Add("height", _height.ToString());
                    }

                    if (_enableContextMenu)
                    {
                        _plugins += ",contextmenu";
                    }


                    // If the editor is used in umbraco, use umbraco's own toolbar
                    bool onFront = false;
                    if (GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current))
                    {
                        config.Add("theme_umbraco_toolbar_location", "external");
                        config.Add("skin", "umbraco");
                        config.Add("inlinepopups_skin ", "umbraco");
                    }
                    else
                    {
                        onFront = true;
                        config.Add("theme_umbraco_toolbar_location", "top");
                    }

                    // load plugins
                    IDictionaryEnumerator pluginEnum = tinyMCEConfiguration.Plugins.GetEnumerator();
                    while (pluginEnum.MoveNext())
                    {
                        var plugin = (tinyMCEPlugin)pluginEnum.Value;
                        if (plugin.UseOnFrontend || (!onFront && !plugin.UseOnFrontend))
                        {
                            _plugins += "," + plugin.Name;
                        }
                    }

                    // add the umbraco overrides to the end
                    // NB: It is !!REALLY IMPORTANT!! that these plugins are added at the end
                    // as they make runtime modifications to default plugins, so require
                    // those plugins to be loaded first.
                    _plugins += ",umbracopaste,umbracolink,umbracocontextmenu";

                    if (_plugins.StartsWith(","))
                    {
                        _plugins = _plugins.Substring(1, _plugins.Length - 1);
                    }
                    if (_plugins.EndsWith(","))
                    {
                        _plugins = _plugins.Substring(0, _plugins.Length - 1);
                    }

                    config.Add("plugins", _plugins);

                    // Check advanced settings
                    if (UmbracoEnsuredPage.CurrentUser != null && ("," + _advancedUsers + ",").IndexOf("," + UmbracoEnsuredPage.CurrentUser.UserType.Id + ",") >
                        -1)
                    {
                        config.Add("umbraco_advancedMode", "true");
                    }
                    else
                    {
                        config.Add("umbraco_advancedMode", "false");
                    }

                    // Check maximum image width
                    config.Add("umbraco_maximumDefaultImageWidth", m_maxImageWidth.ToString());

                    // Styles
                    string cssFiles = String.Empty;
                    string styles   = string.Empty;
                    foreach (string styleSheetId in _stylesheets)
                    {
                        if (styleSheetId.Trim() != "")
                        {
                            try
                            {
                                //TODO: Fix this, it will no longer work!
                                var s = StyleSheet.GetStyleSheet(int.Parse(styleSheetId), false, false);

                                if (s.nodeObjectType == StyleSheet.ModuleObjectType)
                                {
                                    cssFiles += IOHelper.ResolveUrl(SystemDirectories.Css + "/" + s.Text + ".css");

                                    foreach (StylesheetProperty p in s.Properties)
                                    {
                                        if (styles != string.Empty)
                                        {
                                            styles += ";";
                                        }
                                        if (p.Alias.StartsWith("."))
                                        {
                                            styles += p.Text + "=" + p.Alias;
                                        }
                                        else
                                        {
                                            styles += p.Text + "=" + p.Alias;
                                        }
                                    }

                                    cssFiles += ",";
                                }
                            }
                            catch (Exception ee)
                            {
                                LogHelper.Error <TinyMCE>("Error adding stylesheet to tinymce Id:" + styleSheetId, ee);
                            }
                        }
                    }
                    // remove any ending comma (,)
                    if (!string.IsNullOrEmpty(cssFiles))
                    {
                        cssFiles = cssFiles.TrimEnd(',');
                    }

                    // language
                    string userLang = (UmbracoEnsuredPage.CurrentUser != null) ?
                                      (User.GetCurrent().Language.Contains("-") ?
                                       User.GetCurrent().Language.Substring(0, User.GetCurrent().Language.IndexOf("-")) : User.GetCurrent().Language)
                        : "en";
                    config.Add("language", userLang);

                    config.Add("content_css", cssFiles);
                    config.Add("theme_umbraco_styles", styles);

                    // Add buttons
                    IDictionaryEnumerator ide = tinyMCEConfiguration.Commands.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        var cmd = (tinyMCECommand)ide.Value;
                        if (_editorButtons.IndexOf("," + cmd.Alias + ",") > -1)
                        {
                            _activateButtons += cmd.Alias + ",";
                        }
                        else
                        {
                            _disableButtons += cmd.Alias + ",";
                        }
                    }

                    if (_activateButtons.Length > 0)
                    {
                        _activateButtons = _activateButtons.Substring(0, _activateButtons.Length - 1);
                    }
                    if (_disableButtons.Length > 0)
                    {
                        _disableButtons = _disableButtons.Substring(0, _disableButtons.Length - 1);
                    }

                    // Add buttons
                    initButtons();
                    _activateButtons = "";

                    int separatorPriority = 0;
                    ide = _mceButtons.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        string mceCommand  = ide.Value.ToString();
                        var    curPriority = (int)ide.Key;

                        // Check priority
                        if (separatorPriority > 0 &&
                            Math.Floor(decimal.Parse(curPriority.ToString()) / 10) >
                            Math.Floor(decimal.Parse(separatorPriority.ToString()) / 10))
                        {
                            _activateButtons += "separator,";
                        }

                        _activateButtons += mceCommand + ",";

                        separatorPriority = curPriority;
                    }


                    config.Add("theme_umbraco_buttons1", _activateButtons);
                    config.Add("theme_umbraco_buttons2", "");
                    config.Add("theme_umbraco_buttons3", "");
                    config.Add("theme_umbraco_toolbar_align", "left");
                    config.Add("theme_umbraco_disable", _disableButtons);

                    config.Add("theme_umbraco_path ", "true");
                    config.Add("extended_valid_elements", "div[*]");
                    config.Add("document_base_url", "/");
                    config.Add("relative_urls", "false");
                    config.Add("remove_script_host", "true");
                    config.Add("event_elements", "div");
                    config.Add("paste_auto_cleanup_on_paste", "true");

                    config.Add("valid_elements",
                               tinyMCEConfiguration.ValidElements.Substring(1,
                                                                            tinyMCEConfiguration.ValidElements.Length -
                                                                            2));
                    config.Add("invalid_elements", tinyMCEConfiguration.InvalidElements);

                    // custom commands
                    if (tinyMCEConfiguration.ConfigOptions.Count > 0)
                    {
                        ide = tinyMCEConfiguration.ConfigOptions.GetEnumerator();
                        while (ide.MoveNext())
                        {
                            config.Add(ide.Key.ToString(), ide.Value.ToString());
                        }
                    }

                    //if (HttpContext.Current.Request.Path.IndexOf(Umbraco.Core.IO.SystemDirectories.Umbraco) > -1)
                    //    config.Add("language", User.GetUser(BasePage.GetUserId(BasePage.umbracoUserContextID)).Language);
                    //else
                    //    config.Add("language", System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);

                    if (_fullWidth)
                    {
                        config.Add("auto_resize", "true");
                        base.Columns = 30;
                        base.Rows    = 30;
                    }
                    else
                    {
                        base.Columns = 0;
                        base.Rows    = 0;
                    }
                    EnableViewState = false;
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Incorrect TinyMCE configuration.", "Configuration", ex);
            }
        }
Ejemplo n.º 39
0
 public WeakDictionaryEnumerator(IDictionaryEnumerator baseEnumerator)
 {
     this.baseEnumerator = baseEnumerator;
 }
Ejemplo n.º 40
0
        private void initButtons()
        {
            if (!_isInitialized)
            {
                _isInitialized = true;

                // Add icons for the editor control:
                // Html
                // Preview
                // Style picker, showstyles
                // Bold, italic, Text Gen
                // Align: left, center, right
                // Lists: Bullet, Ordered, indent, undo indent
                // Link, Anchor
                // Insert: Image, macro, table, formular

                foreach (string button in _activateButtons.Split(','))
                {
                    if (button.Trim() != "")
                    {
                        try
                        {
                            var cmd = (tinyMCECommand)tinyMCEConfiguration.Commands[button];

                            string appendValue = "";
                            if (cmd.Value != "")
                            {
                                appendValue = ", '" + cmd.Value + "'";
                            }
                            _mceButtons.Add(cmd.Priority, cmd.Command);
                            _buttons.Add(cmd.Priority,
                                         new editorButton(cmd.Alias, ui.Text("buttons", cmd.Alias), cmd.Icon,
                                                          "tinyMCE.execInstanceCommand('" + ClientID + "', '" +
                                                          cmd.Command + "', " + cmd.UserInterface + appendValue + ")"));
                        }
                        catch (Exception ee)
                        {
                            LogHelper.Error <TinyMCE>(string.Format("TinyMCE: Error initializing button '{0}'", button), ee);
                        }
                    }
                }

                // add save icon
                int separatorPriority     = 0;
                IDictionaryEnumerator ide = _buttons.GetEnumerator();
                while (ide.MoveNext())
                {
                    object buttonObj   = ide.Value;
                    var    curPriority = (int)ide.Key;

                    // Check priority
                    if (separatorPriority > 0 &&
                        Math.Floor(decimal.Parse(curPriority.ToString()) / 10) >
                        Math.Floor(decimal.Parse(separatorPriority.ToString()) / 10))
                    {
                        _menuIcons.Add("|");
                    }

                    try
                    {
                        var e = (editorButton)buttonObj;

                        MenuIconI menuItem = new MenuIconClass();

                        menuItem.OnClickCommand = e.onClickCommand;
                        menuItem.ImageURL       = e.imageUrl;
                        menuItem.AltText        = e.alttag;
                        menuItem.ID             = e.id;
                        _menuIcons.Add(menuItem);
                    }
                    catch
                    {
                    }

                    separatorPriority = curPriority;
                }
            }
        }
Ejemplo n.º 41
0
        public override Object GetObject(String key, bool ignoreCase)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (Reader == null)
            {
                throw new InvalidOperationException("ResourceSet is closed");
            }

            Object value = _table[key];

            if (value != null)
            {
                return(value);
            }

            lock (this) {
                if (Reader == null)
                {
                    throw new InvalidOperationException("ResourceSet is closed");
                }

                if (_defaultReader != null)
                {
                    BCLDebug.Log("RESMGRFILEFORMAT", "Going down fast path in RuntimeResourceSet::GetObject");

                    int pos = _defaultReader.FindPosForResource(key);
                    if (pos != -1)
                    {
                        value = _defaultReader.LoadObject(pos);
                        lock (_table) {
                            Object v2 = _table[key];
                            if (v2 == null)
                            {
                                _table[key] = value;
                            }
                            else
                            {
                                value = v2;
                            }
                        }
                        return(value);
                    }
                    else if (!ignoreCase)
                    {
                        return(null);
                    }
                }

                // At this point, we either don't have our default resource reader
                // or we haven't found the particular resource we're looking for
                // and may have to search for it in a case-insensitive way.
                if (!_haveReadFromReader)
                {
                    // If necessary, init our case insensitive hash table.
                    if (ignoreCase && _caseInsensitiveTable == null)
                    {
                        _caseInsensitiveTable = new Hashtable(new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture), new CaseInsensitiveComparer(CultureInfo.InvariantCulture));
                    }
#if _DEBUG
                    //Console.WriteLine("RuntimeResourceSet::GetObject loading up data.  ignoreCase: "+ignoreCase);
                    BCLDebug.Perf(!ignoreCase, "Using case-insensitive lookups is bad perf-wise.  Consider capitalizing " + key + " correctly in your source");
#endif
                    IDictionaryEnumerator en = Reader.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (_defaultReader == null)
                        {
                            _table.Add(en.Key, en.Value);
                        }
                        if (ignoreCase)
                        {
                            _caseInsensitiveTable.Add(en.Key, en.Value);
                        }
                    }
                    // If we are doing a case-insensitive lookup, we don't want to
                    // close our default reader since we may still use it for
                    // case-sensitive lookups later.
                    if (!ignoreCase)
                    {
                        Reader.Close();
                    }
                    _haveReadFromReader = true;
                }
                Object obj = null;
                if (_defaultReader != null)
                {
                    obj = _table[key];
                }
                if (obj == null && ignoreCase)
                {
                    obj = _caseInsensitiveTable[key];
                }
                return(obj);
            }
        }
        private string GenerateAnchorList(List <EmailTemplateModel> lstEmailTemplatemodel, HTMLParserService parser, string type, EmailTemplateViewModel item = null)
        {
            Hashtable links      = new Hashtable();
            string    dwBaseUrl  = ConfigurationManager.AppSettings["DWEmailUrl"];
            string    dwVideoUrl = ConfigurationManager.AppSettings["DWVideoUrl"];

            if (type == "DefaultDWLink")
            {
                EmailTemplateModel etm = lstEmailTemplatemodel.Take(1).FirstOrDefault();
                links.Add(etm.DWName + "~" + etm.QuoteID, dwBaseUrl + etm.QuoteID + "&type=Decision Wizard");
            }
            else if (type == "Link")
            {
                foreach (EmailTemplateModel etm in lstEmailTemplatemodel.Skip(1))
                {
                    links.Add(etm.DWName + "~" + etm.QuoteID, dwBaseUrl + etm.QuoteID + "&type=Decision Wizard");
                }
            }
            else if (type == "VideoLink")
            {
                links.Add("videolink", dwVideoUrl);
            }
            else
            {
                if (item != null)
                {
                    links.Add("repDetails", item.RepFirstName + "~" + item.FromAddress);
                }
            }
            //generate others DW's list
            StringBuilder         linksBlock   = new StringBuilder();
            IDictionaryEnumerator myEnumerator = links.GetEnumerator();

            while (myEnumerator.MoveNext())
            {
                Hashtable blockVars = new Hashtable();
                if (type != "VideoLink")
                {
                    if (item != null)
                    {
                        blockVars.Add("RepName", myEnumerator.Value.ToString().Split('~')[0]);
                        blockVars.Add("RepPhone", "");
                        blockVars.Add("RepEmailAddress", myEnumerator.Value.ToString().Split('~')[1]);
                    }
                    else
                    {
                        blockVars.Add("Url", myEnumerator.Value);
                        blockVars.Add("DWName", myEnumerator.Key.ToString().Split('~')[0]);
                    }
                }
                else
                {
                    blockVars.Add("VideoUrl", myEnumerator.Value);
                }
                string parsedHtml = parser.ParseBlock(type, blockVars);

                if (!string.IsNullOrEmpty(parsedHtml))
                {
                    linksBlock.Append(parsedHtml);
                }
            }

            return(linksBlock.ToString());
        }
 internal XmlSchemaCollectionEnumerator( Hashtable collection ) {
     enumerator = collection.GetEnumerator();            
 }
Ejemplo n.º 44
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string ci = "";

            CultureInfo[] temp = System.Globalization.CultureInfo.GetCultures(CultureTypes.AllCultures);

            foreach (CultureInfo cul in temp)
            {
                if ((cul.DisplayName + " " + cul.Name) == comboBox1.Text)
                {
                    Console.WriteLine(cul.Name);
                    ci = cul.Name;
                }
            }

            Assembly thisAssembly = null;

            try
            {
                string fn = Settings.GetRunningDirectory() + ci +
                            Path.DirectorySeparatorChar + "MissionPlanner.resources.dll";
                if (File.Exists(fn))
                {
                    thisAssembly = Assembly.LoadFile(fn);
                }
                else
                {
                    return;
                }
            }
            catch
            {
                return;
            }

            string[] test = thisAssembly.GetManifestResourceNames();

            Encoding unicode = Encoding.Unicode;

            foreach (string file in test)
            {
                Stream rgbxml = thisAssembly.GetManifestResourceStream(
                    file);
                try
                {
                    ResourceReader        res  = new ResourceReader(rgbxml);
                    IDictionaryEnumerator dict = res.GetEnumerator();
                    while (dict.MoveNext())
                    {
                        try
                        {
                            Console.WriteLine("   {0}: '{1}' (Type {2})",
                                              dict.Key, dict.Value, dict.Value.GetType().Name);

                            if (dict.Value is Size)
                            {
                                continue;
                            }

                            string thing = (string)dict.Value;

                            //                            dataGridView1.Rows[0].Cells[colOtherLang.Index].Value = dict.Value.ToString();
                            foreach (DataGridViewRow row in dataGridView1.Rows)
                            {
                                string t2 = file.Replace(ci + ".", "");

                                if (row.Cells[0].Value.ToString() == t2 &&
                                    row.Cells[1].Value.ToString() == dict.Key.ToString())
                                {
                                    row.Cells[3].Value = thing;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch
                {
                }
            }

            CustomMessageBox.Show("Loaded Existing");
        }
Ejemplo n.º 45
0
 internal AggregateEnumerator(IDictionaryEnumerator [] enumerators) {
     _enumerators = enumerators;
 }
Ejemplo n.º 46
0
        private void _ExecNonQueryTran_Complex(Hashtable[] sGroup, Hashtable[] mGroup, string conn)
        {
            SqlConnection dbConn = null;
            SqlCommand    dbComm = null;
            //Hashtable을 받아서 처리하는 객체..
            IDictionaryEnumerator ie = null;
            int i = 0;

            SqlTransaction trans = null;

            try
            {
                dbConn                = this._dbConn(dbConn, conn);
                dbComm                = new SqlCommand();
                dbComm.Connection     = dbConn;
                dbComm.CommandTimeout = 3000; //5분
                dbComm.CommandType    = CommandType.StoredProcedure;

                //DB OPEN..
                dbConn.Open();

                //
                //트랜잭션 시작..
                //
                trans = dbConn.BeginTransaction();
                dbComm.Transaction = trans;

                //
                //단일레코드등록..
                //
                Hashtable sht = new Hashtable();
                for (int s = 0; s < sGroup.Length; s++)
                {
                    if (sGroup[s] == null)
                    {
                        continue;
                    }

                    sht = sGroup[s];
                    ie  = sht.GetEnumerator();
                    Hashtable ht = null;
                    while (ie.MoveNext())
                    {
                        dbComm.CommandText = ie.Key.ToString(); //프로시저명..
                        ht = (Hashtable)ie.Value;
                        if (ht != null)                         //null이 아니면 등록프로세스 시행..
                        {
                            //파라메터 클리어..
                            dbComm.Parameters.Clear();
                            if (ht.Count > 0)
                            {
                                this._AddParam(ref dbComm, ref ht);
                            }
                            //실행..
                            dbComm.ExecuteNonQuery();
                        }
                    }
                }

                //
                //다중레코드  등록..
                //
                Hashtable mht = new Hashtable();
                for (int m = 0; m < mGroup.Length; m++)
                {
                    if (mGroup[m] == null)
                    {
                        continue;
                    }

                    mht = mGroup[m];
                    ie  = mht.GetEnumerator();
                    Hashtable[] valHt = null;
                    while (ie.MoveNext())
                    {
                        dbComm.CommandText = ie.Key.ToString();//프로시저명..
                        valHt = (Hashtable[])ie.Value;
                        if (valHt != null)
                        {
                            for (i = 0; i < valHt.Length; i++)
                            {
                                if (valHt[i] != null)
                                {
                                    //파라메터 클리어..
                                    dbComm.Parameters.Clear();
                                    //파라메터등록..
                                    if (valHt[i].Count > 0)
                                    {
                                        this._AddParam(ref dbComm, ref valHt[i]);
                                    }
                                    //실행..
                                    dbComm.ExecuteNonQuery();
                                }
                            }
                        }
                    }
                }
                //커밋..
                trans.Commit();

                dbConn.Close();
            }
            catch (Exception exp)
            {
                //롤백..
                trans.Rollback();
                throw exp;
            }
            finally
            {
                if (dbConn.State == ConnectionState.Open || dbConn.State == ConnectionState.Connecting)
                {
                    dbConn.Close();
                }
            }
        }
			public DictionaryEntryEnumeratorAdapter(IDictionaryEnumerator enumerator)
			{
				this.enumerator = enumerator;
			}
Ejemplo n.º 48
0
        /// <summary>
        /// </summary>
        /// <param name="iInstrType"></param>
        /// <param name="iInstrOPType"></param>
        /// <param name="hInputValues"></param>
        /// <param name="sErrMsg"></param>
        /// <param name="alErrorMsg"></param>
        /// <returns>Calculated result</returns>
        public static Double DoCalculate(int iInstrType, int iInstrOPType, Hashtable hInputValues, ref string sErrMsg, ref ArrayList alErrorMsg)
        {
            Double dResult = 0;

            try
            {
                // Validate input fields
                dResult = ValidateFields(hInputValues, iInstrType, iInstrOPType, ref sErrMsg, ref alErrorMsg);
                if (dResult > 0)
                {
                    if (iInstrType == cStr_IT_SavingsAccount || iInstrType == cStr_IT_CurrentAccount || iInstrType == cStr_IT_CashAtHand)
                    {
                        if (iInstrType == cStr_IT_CashAtHand)
                        {
                            dResult = Convert.ToDouble(hInputValues["DAMT"]);
                        }
                        else
                        {
                            dResult = Convert.ToDouble(hInputValues["AAB"]);
                        }
                        return(dResult);
                    }

                    // Set calculated field values.
                    setCalculatedFields(iInstrType, iInstrOPType, hInputValues);

                    string sFormula = null;
                    int    nCount   = dsFormula.Tables[0].Rows.Count;

                    DataTable dtFormula = dsFormula.Tables[0];

                    var resultFormula = from formula in dtFormula.AsEnumerable()
                                        where formula.Field <Int32>("OFM_InstrumentTypeId") == iInstrType &&
                                        formula.Field <Int32>("OFM_OutputId") == iInstrOPType
                                        select formula;

                    foreach (var formula in resultFormula)
                    {
                        // If interest calculation basis is simple use formula 9 or formula 2 for the instruments,
                        if ((iInstrType == cStr_IT_FixedDeposits || iInstrType == cStr_IT_CompanyFD || iInstrType == cStr_IT_GOIReliefBonds || iInstrType == cStr_IT_GOITaxSavingBonds || iInstrType == cStr_IT_TaxSavingBonds) && (iInstrOPType == cStr_IO_CurrentValue || iInstrOPType == cStr_IO_MaturityValue || iInstrOPType == cStr_IO_InterestAccumulatedEarnedTillDate || iInstrOPType == cStr_IO_InterestAccumulatedEarnedTillMaturity) && hInputValues["ICB"].Equals("Simple"))
                        {
                            if (formula["OFM_FormulaId"].ToString().Equals(cStr_Formula_SimpleInterestBasis) && formula.ItemArray[3].ToString().Equals(cStr_Formula_SimpleInterestBasis))
                            {
                                sFormula = formula["FM_Formula"].ToString();
                                break;
                            }
                            else if (formula["OFM_FormulaId"].ToString().Equals(cStr_Formula_InterestAccumulatedEarnedTillDate) && formula.ItemArray[3].ToString().Equals(cStr_Formula_InterestAccumulatedEarnedTillDate))
                            {
                                sFormula = formula["FM_Formula"].ToString();
                                break;
                            }
                        }
                        else if (iInstrType == cStr_IT_SeniorCitizensSavingsScheme || iInstrType == cStr_IT_PostOfficeSavingsBankAcc || iInstrType == cStr_IT_PostOfficeMIS)
                        {
                            sFormula = formula["FM_Formula"].ToString();
                            break;
                        }
                        else
                        {
                            if (formula["OFM_FormulaId"].ToString().Equals(cStr_Formula_SimpleInterestBasis) && formula.ItemArray[3].ToString().Equals(cStr_Formula_SimpleInterestBasis))
                            {
                                continue;
                            }
                            else if (formula["OFM_FormulaId"].ToString().Equals(cStr_Formula_InterestAccumulatedEarnedTillDate) && formula.ItemArray[3].ToString().Equals(cStr_Formula_InterestAccumulatedEarnedTillDate))
                            {
                                continue;
                            }
                            else if (formula["OFM_FormulaId"].ToString().Equals(cStr_Formula_CompoundInterestAccumulatedEarnedTillDate) && formula.ItemArray[3].ToString().Equals(cStr_Formula_CompoundInterestAccumulatedEarnedTillDate))
                            {
                                sFormula = formula["FM_Formula"].ToString();
                                break;
                            }
                            else if (formula["OFM_FormulaId"].ToString().Equals(cStr_Formula_CurrentValueOrMaturityValue) && formula.ItemArray[3].ToString().Equals(cStr_Formula_CurrentValueOrMaturityValue))
                            {
                                sFormula = formula["FM_Formula"].ToString();
                                break;
                            }
                            else
                            {
                                sFormula = formula["FM_Formula"].ToString();
                                break;
                            }
                        }
                    }
                    // Months will be rounded of to the nearest year if the covered under Gratuity Act otherwise no rounded off
                    if (iInstrType == cStr_IT_Gratuity)
                    {
                        int nNoOfMonthComp = Convert.ToInt32(hInputValues["NOMC"]);
                        int nNoOfYearsComp = Convert.ToInt32(hInputValues["CYOS"]);
                        if (iInstrOPType == cStr_IO_GratuityAmountWhenCoveredUnderGratuityAct)
                        {
                            if (nNoOfMonthComp > 5)
                            {
                                nNoOfYearsComp += 1;
                            }
                            hInputValues["CYOS"] = nNoOfYearsComp;
                        }
                        else
                        {
                            hInputValues["CYOS"] = nNoOfYearsComp;
                        }
                    }
                    IDictionaryEnumerator en = hInputValues.GetEnumerator();
                    while (en.MoveNext())
                    {
                        string str = en.Key.ToString();
                        if (sFormula.Contains(str))
                        {
                            sFormula = sFormula.Replace(str, en.Value.ToString());
                        }
                    }

                    FunctionParser fn = new FunctionParser();
                    fn.Parse(sFormula);
                    fn.Infix2Postfix();
                    fn.EvaluatePostfix();
                    dResult = Math.Round(fn.Result, 2);
                }
                return(dResult);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                object[] objects = new object[4];
                objects[0] = iInstrType;
                objects[1] = iInstrOPType;
                objects[2] = hInputValues;
                objects[3] = sErrMsg;
                objects[4] = alErrorMsg;
                FunctionInfo.Add("Method", "CalculatorBo.cs:DoCalculate()");
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Ejemplo n.º 49
0
		/// <summary>
		/// Write an dictionary to a <see cref="TextWriter"/>
		/// </summary>
		/// <param name="writer">the writer to write to</param>
		/// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
		/// <param name="value">the value to write to the writer</param>
		/// <remarks>
		/// <para>
		/// Writes the <see cref="IDictionaryEnumerator"/> to a writer in the form:
		/// </para>
		/// <code>
		/// {key1=value1, key2=value2, key3=value3}
		/// </code>
		/// <para>
		/// If the <see cref="ILoggerRepository"/> specified
		/// is not null then it is used to render the key and value to text, otherwise
		/// the object's ToString method is called.
		/// </para>
		/// </remarks>
		protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionaryEnumerator value) {
			writer.Write("{");

			bool first = true;

			// Write out all the dictionary key value pairs
			while (value.MoveNext()) {
				if (first) {
					first = false;
				} else {
					writer.Write(", ");
				}
				WriteObject(writer, repository, value.Key);
				writer.Write("=");
				WriteObject(writer, repository, value.Value);
			}

			writer.Write("}");
		}
Ejemplo n.º 50
0
        /// <summary>
        /// </summary>
        /// <param name="hInputValues"></param>
        /// <param name="iInstrType"></param>
        /// <param name="iInstrOPType"></param>
        /// <param name="sErrorMsg"></param>
        /// <param name="alErrorMsg"></param>
        /// <returns>Validation result</returns>
        private static double ValidateFields(Hashtable hInputValues, int iInstrType, int iInstrOPType, ref string sErrorMsg, ref ArrayList alErrorMsg)
        {
            IDictionaryEnumerator en = hInputValues.GetEnumerator();
            double returnVal         = 1;

            try
            {
                while (en.MoveNext())
                {
                    string    strAbb    = en.Key.ToString();
                    string    sType     = null;
                    string    sValue    = null;
                    string    sInstType = null;
                    DataTable dtInput   = dsInputForSelOutput.Tables[0];
                    var       result    = from inputFields in dtInput.AsEnumerable()
                                          where inputFields.Field <String>("IM_Abbrevation") == strAbb
                                          select inputFields;

                    foreach (var input in result)
                    {
                        sType     = input["IOM_FieldType"].ToString();
                        sInstType = input["IM_InputType"].ToString();
                        break;
                    }
                    sValue = en.Value.ToString();
                    if (sType.Length > 0 && sType != "NULL" && sInstType != "k" && sInstType != "l")
                    {
                        if (sValue.Length < 1)
                        {
                            sErrorMsg = string.Format("{0} : value can not be empty.", sInstType);
                            alErrorMsg.Add(sErrorMsg);
                            returnVal = -1;
                        }
                        else
                        {
                            if (sType == "Date")
                            {
                                DateTime tempDateTime;
                                string   sDateTime = sValue;

                                if (!DateTime.TryParse(sDateTime, out tempDateTime))
                                {
                                    sErrorMsg = string.Format("{0}: value is not valid date format. date format should be dd/mm/yyyy", sInstType);
                                    alErrorMsg.Add(sErrorMsg);
                                    returnVal = -1;
                                }
                            }
                            else if (sType == "DDL")
                            {
                                continue;
                            }
                            else if (en.Key.ToString() == "DAMT" || en.Key.ToString() == "DAMT" ||
                                     en.Key.ToString() == "ABAL" || en.Key.ToString() == "ADEP" ||
                                     en.Key.ToString() == "WAMT" || en.Key.ToString() == "AMTLFY" ||
                                     en.Key.ToString() == "ECFCY" || en.Key.ToString() == "ERCFY" ||
                                     en.Key.ToString() == "LDS" || en.Key.ToString() == "YCFCFY" ||
                                     en.Key.ToString() == "AAB" || en.Key.ToString() == "PP")
                            {
                                bool isNumeric = IsNumeric(sValue, ref sErrorMsg, sInstType);

                                if (!isNumeric)
                                {
                                    alErrorMsg.Add(sErrorMsg);
                                    returnVal = -1;
                                }
                            }
                            else
                            {
                                bool isNumeric = IsNumeric(sValue, ref sErrorMsg, sInstType);

                                if (!isNumeric)
                                {
                                    alErrorMsg.Add(sErrorMsg);
                                    returnVal = -1;
                                }
                            }
                        }
                    }
                }
                if (returnVal != -1)
                {
                    string sDDAT = Convert.ToString(hInputValues["DDAT"]);
                    string sMDAT = Convert.ToString(hInputValues["MDAT"]);

                    if (sDDAT.Length > 0 && sMDAT.Length > 0)
                    {
                        DateTime dDepDate = Convert.ToDateTime(hInputValues["DDAT"]);
                        DateTime dMatDate = Convert.ToDateTime(hInputValues["MDAT"]);
                        if (dMatDate < dDepDate)
                        {
                            sErrorMsg = string.Format("Maturity Date should be greater than Deposit Date.");
                            alErrorMsg.Add(sErrorMsg);
                            returnVal = -1;
                        }
                    }
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                object[] objects = new object[5];
                objects[0] = hInputValues;
                objects[1] = iInstrType;
                objects[2] = iInstrOPType;
                objects[3] = sErrorMsg;
                objects[4] = alErrorMsg;

                FunctionInfo.Add("Method", "CalculatorBo.cs:ValidateFields()");
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(returnVal);
        }
Ejemplo n.º 51
0
        public virtual object rewind(ScriptContext context)
        {
            if (iterator != null)
            {
                // we can make use of standard foreach enumerator
                enumerator = iterator.GetForeachEnumerator(true, false, null);

                isValid = enumerator.MoveNext();
            }

            return null;
        }
Ejemplo n.º 52
0
 public CacheEnumerator(IDictionaryEnumerator enumerator)
 {
     _enumerator = enumerator;
     Cache.Instance._rwl.AcquireReaderLock(Cache.LOCK_TIMEOUT_MSECS);
 }
Ejemplo n.º 53
0
        public void rewind()
        {
            if (enumerator is PhpObject.PhpIteratorEnumerator)
                ((PhpObject.PhpIteratorEnumerator)enumerator).Reset();    // we can rewind() existing PhpIteratorEnumerator
            else
                enumerator = obj.GetForeachEnumerator(true, false, null); // we have to reinitialize (null or not PhpIteratorEnumerator)

            isValid = false;// enumerator.MoveNext();
        }
Ejemplo n.º 54
0
 public void Reset()
 {
     this.index = null;
 }
 public WeakEnumerator(IDictionaryEnumerator innerEnumerator)
 {
     this.innerEnumerator = innerEnumerator;
 }
Ejemplo n.º 56
0
    void _Create()
    {
        ptokens tks = new ptokens(erh);

        m_outname     = "syntax";
        tks.m_sgen    = this;
        m_lexer       = tks;
        m_symbols.erh = erh;
        m_symbols.ClassInit(this);
        m_outname = "syntax";
        m_outFile.WriteLine("using System;using Tools;");
        Production special = new Production(this, m_symbols.Special);

        m_lexer.yytext = "error";
        CSymbol e = (new CSymbol(this)).Resolve();

        e.m_symtype = CSymbol.SymType.nonterminal;
        e.m_defined = true;
        e.m_yynum   = 0;
        // 1: INPUT
        // top-down parsing of script
        m_lexer.Start(m_inFile);
        m_tok = (TOKEN)m_lexer.Next();
        //Console.WriteLine("Token <{0}> {1}",m_tok.yytext,m_tok.GetType().Name);
        while (m_tok != null)
        {
            ParseProduction();
        }
        // that's the end of the script
        if (!m_parserseen)
        {
            Error(30, 0, "no parser directive detected - possibly incorrect text encoding?");
        }
        m_outFile.WriteLine(m_actions);         // output the action function
        m_outFile.WriteLine("}  return null; }");
        special.AddToRhs(m_symbols.m_startSymbol);
        special.AddToRhs(m_symbols.EOFSymbol);
        // 2: PROCESSING
        Console.WriteLine("First");
        DoFirst();
        Console.WriteLine("Follow");
        DoFollow();
        Console.WriteLine("Parse Table");
        ParseState start = new ParseState(this, null);

        m_symbols.m_states[0] = start;
        start.MaybeAdd(new ProdItem(special, 0));
        start.Closure();
        start.AddEntries();
        Transition  tfinal = (Transition)start.m_transitions[m_symbols.m_startSymbol.yytext];
        ParserShift pe     = tfinal.m_next;

        m_symbols.m_accept = pe.m_next;
        if (m_symbols.m_accept == null)
        {
            m_symbols.erh.Error(new CSToolsFatalException(43, "No accept state. ParserGenerator cannot continue."));
        }
        // 2A: Reduce States for the LR(0) parser
        foreach (ParseState ps in m_symbols.m_states.Values)
        {
            ps.ReduceStates();
        }

        /*	if (m_showParser)
         *      {
         *              foreach (ParseState ps in m_symbols.m_states.Values)
         *              {
         *                      ps.Print0();
         *                      if (ps==m_symbols.m_accept)
         *                              Console.WriteLine("    EOF  accept");
         *              }
         *      } */
        // 3: Compute Look-ahead sets
        if (m_lalrParser)
        {
            m_symbols.Transitions(new Builder(Transition.BuildDR));

            /*	if (m_showParser)
             *              m_symbols.PrintTransitions(new Func(Transition.DR),"DR"); */
            m_symbols.Transitions(new Builder(Transition.BuildReads));
            new Digraph(this,
                        new Relation(Transition.reads),
                        new Func(Transition.DR),
                        new Func(Transition.Read),
                        new AddToFunc(Transition.AddToRead)).Compute();
            // detect cycles in Read TBD

            /*	if (m_showParser)
             *              m_symbols.PrintTransitions(new Func(Transition.Read),"Read"); */
            m_symbols.Transitions(new Builder(Transition.BuildIncludes));
            m_symbols.Transitions(new Builder(Transition.BuildLookback));
            new Digraph(this,
                        new Relation(Transition.includes),
                        new Func(Transition.Read),
                        new Func(Transition.Follow),
                        new AddToFunc(Transition.AddToFollow)).Compute();
            // detect cycles for which Read is non empty TBD

            /*	if (m_showParser)
             *              m_symbols.PrintTransitions(new Func(Transition.Follow),"Follow"); */
            m_symbols.Transitions(new Builder(Transition.BuildLA));
        }
        // 5: OUTPUT
        // output the run-time ParsingInfo table
        Console.WriteLine("Building parse table");
        m_symbols.Transitions(new Builder(Transition.BuildParseTable));
        foreach (CSymbol v in m_symbols.symbols.Values)
        {
            if (v.m_symtype != CSymbol.SymType.nodesymbol)
            {
                continue;
            }
            ParsingInfo pi = new ParsingInfo(v.yytext, v.m_yynum);
            CSymbol     r  = v;
            while (r.m_symtype == CSymbol.SymType.nodesymbol)
            {
                r = r.m_refSymbol;
            }
            if (m_symbols.symbolInfo[v.m_yynum] != null)
            {
                m_symbols.erh.Error(new CSToolsException(45, "Bad %node/%symbol hierarchy on " + v.yytext + "(" + v.m_yynum + ")"));
            }
            pi.m_parsetable = m_symbols.GetSymbolInfo(r.yytext, r.m_yynum).m_parsetable;
            m_symbols.symbolInfo[v.m_yynum] = pi;
        }
        Console.WriteLine("Writing the output file");
        m_outFile.WriteLine("public yy" + m_outname + "():base() { arr = new int[] { ");
        m_symbols.Emit(m_outFile);
        // output the class factories
        CSymbol s;

        Console.WriteLine("Class factories");
        IDictionaryEnumerator de = m_symbols.symbols.GetEnumerator();

        for (int pos = 0; pos < m_symbols.symbols.Count; pos++)
        {
            de.MoveNext();
            string str = (string)de.Key;
            s = (CSymbol)de.Value;
            if ((s == null) ||        // might happen because of error recovery
                (s.m_symtype != CSymbol.SymType.nonterminal && s.m_symtype != CSymbol.SymType.nodesymbol))
            {
                continue;
            }
            //Console.WriteLine("{0} {1}",s.yytext,s.m_symtype);
            m_outFile.WriteLine("new Sfactory(this,\"{0}\",new SCreator({0}_factory));", str);
        }
        m_outFile.WriteLine("}");
        de.Reset();
        for (int pos = 0; pos < m_symbols.symbols.Count; pos++)
        {
            de.MoveNext();
            string str = (string)de.Key;
            s = (CSymbol)de.Value;
            if ((s == null) ||        // might happen because of error recovery
                (s.m_symtype != CSymbol.SymType.nonterminal && s.m_symtype != CSymbol.SymType.nodesymbol))
            {
                continue;
            }
            //Console.WriteLine("{0} {1}",s.yytext,s.m_symtype);
            m_outFile.WriteLine("public static object " + str + "_factory(Parser yyp) { return new " + str + "(yyp); }");
        }
        m_outFile.WriteLine("}");
        m_outFile.WriteLine("public class " + m_outname + ": Parser {");
        m_outFile.WriteLine("public " + m_outname + "():base(new yy" + m_outname + "(),new " + m_lexerClass + "()) {}");
        m_outFile.WriteLine("public " + m_outname + "(YyParser syms):base(syms,new " + m_lexerClass + "()) {}");
        m_outFile.WriteLine("public " + m_outname + "(YyParser syms,ErrorHandler erh):base(syms,new " + m_lexerClass + "(erh)) {}");
        m_outFile.WriteLine(m_actvars);
        m_outFile.WriteLine(" }");
        if (m_namespace)
        {
            m_outFile.WriteLine("}");
        }
        Console.WriteLine("Done");
        if (m_showParser)
        {
            foreach (ParseState ps in m_symbols.m_states.Values)
            {
                ps.Print();
                if (ps == m_symbols.m_accept)
                {
                    Console.WriteLine("    EOF  accept");
                }
            }
        }
    }
Ejemplo n.º 57
0
 internal EXIFextractorEnumerator(Hashtable exif)
 {
     this.exifTable = exif;
     this.Reset();
     index = exif.GetEnumerator();
 }
Ejemplo n.º 58
0
 public dictEnumerator(IDictionaryEnumerator enumerator)
 {
     Enumerator = enumerator;
 }
Ejemplo n.º 59
0
        private void PopulateConfiugrationObject(Object config, XmlNode node)
        {
            if (node == null || config == null)
            {
                return;
            }

            XmlAttributeCollection attribColl = node.Attributes;

            foreach (XmlAttribute xmlAttrib in attribColl)
            {
                FillConfigWithAttribValue(config, xmlAttrib);
            }

            XmlNodeList nodeList     = node.ChildNodes;
            Hashtable   sameSections = new Hashtable();

            for (int i = 0; i < nodeList.Count; i++)
            {
                XmlNode sectionNode = nodeList[i];
                Type    sectionType = null;

                if (sectionNode.Name.ToLower() == DYNAMIC_CONFIG_SECTION && sectionNode.HasChildNodes)
                {
                    ExtractDyanamicConfigSectionObjectType(sectionNode);
                }
            }
            for (int i = 0; i < nodeList.Count; i++)
            {
                XmlNode sectionNode = nodeList[i];
                Type    sectionType = null;
                if (sectionNode.Name.ToLower() == DYNAMIC_CONFIG_SECTION)
                {
                    continue;
                }

                sectionType = GetConfigSectionObjectType(config, sectionNode.Name);

                if (sectionType != null)
                {
                    if (sectionType.IsArray)
                    {
                        string    nonArrayType    = sectionType.FullName.Replace("[]", "");
                        ArrayList sameSessionList = null;
                        Hashtable tmp             = null;
                        if (!sameSections.Contains(sectionType))
                        {
                            tmp = new Hashtable();
                            tmp.Add("section-name", sectionNode.Name);

                            sameSessionList = new ArrayList();
                            tmp.Add("section-list", sameSessionList);
                            sameSections.Add(sectionType, tmp);
                        }
                        else
                        {
                            tmp             = sameSections[sectionType] as Hashtable;
                            sameSessionList = tmp["section-list"] as ArrayList;
                        }

                        ObjectHandle objHandle           = Activator.CreateInstance(sectionType.Assembly.FullName, nonArrayType);
                        object       singleSessionObject = objHandle.Unwrap();
                        PopulateConfiugrationObject(singleSessionObject, sectionNode);
                        sameSessionList.Add(singleSessionObject);
                    }
                    else
                    {
                        ObjectHandle objHandle     = Activator.CreateInstance(sectionType.Assembly.FullName, sectionType.FullName);
                        object       sectionConfig = objHandle.Unwrap();
                        PopulateConfiugrationObject(sectionConfig, sectionNode);
                        SetConfigSectionObject(config, sectionConfig, sectionNode.Name);
                    }
                }
            }
            if (sameSections.Count > 0)
            {
                Hashtable             tmp;
                IDictionaryEnumerator ide = sameSections.GetEnumerator();
                while (ide.MoveNext())
                {
                    Type arrType = ide.Key as Type;
                    tmp = ide.Value as Hashtable;
                    ArrayList sameSessionList = tmp["section-list"] as ArrayList;
                    string    sectionName     = tmp["section-name"] as string;
                    object[]  sessionArrayObj = Activator.CreateInstance(arrType, new object[] { sameSessionList.Count }) as object[];
                    if (sessionArrayObj != null)
                    {
                        for (int i = 0; i < sameSessionList.Count; i++)
                        {
                            sessionArrayObj[i] = sameSessionList[i];
                        }
                        SetConfigSectionObject(config, sessionArrayObj, sectionName);
                    }
                }
            }
        }
Ejemplo n.º 60
0
 internal ConfigurationMapEnumerator(ConfigurationMap enumerable)
 {
     _innerEnumerator = enumerable.InnerHash.GetEnumerator();
 }