// basic checks (only for checking name conflicts)

        public void CheckCommonNamesConflicts(string name, int line, int column)
        {
            if (Classes.ContainsKey(name) || Routines.ContainsKey(name) || Fields.ContainsKey(name) || ImportedModules.Contains(name) || ModuleData.Name == name)
            {
                ThrowConflictNameException(ModuleData.File, line, column);
            }
        }
Exemple #2
0
        void ILoadMember.StaticField(bool hasNonPublic)
        {
            if (Loaded(3))
            {
                return;
            }
            if (Fields == null)
            {
                Fields = new ObjectPropertyCollection(Properties.IgnoreCase);
            }
            var bf = BindingFlags.Public | BindingFlags.Static;

            if (hasNonPublic)
            {
                bf |= BindingFlags.NonPublic;
            }
            foreach (var f in _Type.GetFields(bf))
            {
                if (f.Name.Contains("<") == false &&
                    Fields.ContainsKey(f.Name) == false)
                {
                    Fields.Add(new ObjectProperty(f));
                }
            }
            Monitor.Exit(this);
        }
 public void CheckRoutineConflicts(ModuleData module, MethodNameTableItem routineItem)
 {
     if (Fields.ContainsKey(routineItem.Name))
     {
         ThrowConflictNameException(module.File, routineItem.Line, routineItem.Column);
     }
 }
Exemple #4
0
        public override bool IsParse(Fields fields)
        {
            var express = fields.ContainsKey("express") ? fields["express"] : "";
            var m       = Regex.Match(express, ParsePattern);

            return(m.Success && m.Length > 0);
        }
Exemple #5
0
        public override string Parse(Fields fields)
        {
            var express = fields.ContainsKey("express") ? fields["express"] : "";
            var match   = Regex.Match(express, ParsePattern);

            if (match.Success == false || match.Length == 0)
            {
                return(express);
            }

            var result = match.Groups["result"].Value;
            var thired = match.Groups["thired"].Value;
            var r      = Regex.Match(result, RangePattern);

            result = Regex.Replace(result, RangePattern, new MatchEvaluator(delegate(Match m)
            {
                var min  = r.Groups["min"].Value;
                var max  = r.Groups["max"].Value;
                var math = r.Groups["math"].Value;

                return(string.Format("{0}>={1} and {0}<={2}", math, min, max));
            }));

            result = string.Format("({0})", result.Replace("与", ") and (").Replace("或", ") or ("));

            MathExpress     = result;
            HasThiredNumber = string.IsNullOrEmpty(thired) == false;

            express = Regex.Replace(express, ParsePattern, new MatchEvaluator(delegate(Match m)
            {
                return("");
            }));

            return(express);
        }
 //mxd
 public void UpdateFogColor()
 {
     if (General.Map.UDMF && Fields.ContainsKey("fadecolor"))
     {
         fogcolor = new Color4((int)Fields["fadecolor"].Value);
         fogmode  = SectorFogMode.FADE;
     }
     // Sector uses outisde fog when it's ceiling is sky or Sector_Outside effect (87) is set
     else if (General.Map.Data.MapInfo.HasOutsideFogColor &&
              (ceiltexname == General.Map.Config.SkyFlatName || (effect == 87 && General.Map.Config.SectorEffects.ContainsKey(effect))))
     {
         fogcolor = General.Map.Data.MapInfo.OutsideFogColor;
         fogmode  = SectorFogMode.OUTSIDEFOGDENSITY;
     }
     else if (General.Map.Data.MapInfo.HasFadeColor)
     {
         fogcolor = General.Map.Data.MapInfo.FadeColor;
         fogmode  = SectorFogMode.FOGDENSITY;
     }
     else
     {
         fogcolor = new Color4();
         fogmode  = (brightness < 248 ? SectorFogMode.CLASSIC : SectorFogMode.NONE);
     }
 }
Exemple #7
0
        void InitFromBase(SqlTable baseTable)
        {
            if (Alias == null)
            {
                Alias = baseTable.Alias;
            }
            if (Database == null)
            {
                Database = baseTable.Database;
            }
            if (Owner == null)
            {
                Owner = baseTable.Owner;
            }
            if (PhysicalName == null)
            {
                PhysicalName = baseTable.PhysicalName;
            }

            foreach (var field in baseTable.Fields.Values)
            {
                if (!Fields.ContainsKey(field.Name))
                {
                    Fields.Add(new SqlField(field));
                }
            }

            foreach (var join in baseTable.Joins)
            {
                if (Joins.FirstOrDefault(j => j.TableName == join.TableName) == null)
                {
                    Joins.Add(join);
                }
            }
        }
Exemple #8
0
 public void RegisterFieldMapping(SqlField field)
 {
     if (!Fields.ContainsKey(field.PhysicalName))
     {
         Fields.Add(field.PhysicalName, new SqlField(field));
     }
 }
Exemple #9
0
        void InitFromBase(SqlTable baseTable)
        {
            if (_alias == null)
            {
                _alias = baseTable._alias;
            }
            if (_database == null)
            {
                _database = baseTable._database;
            }
            if (_owner == null)
            {
                _owner = baseTable._owner;
            }
            if (_physicalName == null)
            {
                _physicalName = baseTable._physicalName;
            }

            foreach (var field in baseTable.Fields.Values)
            {
                if (!Fields.ContainsKey(field.Name))
                {
                    Fields.Add(new SqlField(field));
                }
            }

            foreach (var join in baseTable.Joins)
            {
                if (Joins.Find(j => j.TableName == join.TableName) == null)
                {
                    Joins.Add(join);
                }
            }
        }
 protected override void CreateTable(DbDataReader r)
 {
     eInfo.Run();
     FieldCount = r.FieldCount;
     range      = eInfo.R.Resize[EachCashRow, FieldCount];
     cash       = new object[EachCashRow, FieldCount];
     for (int i = 0; i < FieldCount; i++)
     {
         if (Fields.ContainsKey(r.GetName(i)))
         {
             throw new ActionException($"出现相同的标题\"{r.GetName(i)}\"");
         }
         else
         {
             Fields.Add(r.GetName(i), i);
         }
     }
     //标题
     if (withTitle)
     {
         foreach (var item in Fields)
         {
             SetValue(item.Key, item.Key);
         }
         UpdataRow();
     }
 }
Exemple #11
0
        public override bool Match(Fields fields)
        {
            var sample = fields.ContainsKey("sample") ? fields["sample"] : "";
            var match  = Regex.Match(sample, MatchPattern);

            while (match.Success && match.Length > 0)
            {
                var number = match.Groups["number"].Value;
                var sql    = string.Format("{0} >= {1} and {0} <= {2}", number, NumberRange.Min, NumberRange.Max);

                var result = Calculator.Compute(sql, "");

                if (result is bool)
                {
                    var b = bool.Parse(result.ToString());

                    if (b)
                    {
                        return(true);
                    }
                }

                match = match.NextMatch();
            }

            return(false);
        }
        public override object Get(Token name)
        {
            if (Fields.ContainsKey(name.Lexeme))
            {
                var foundField = Fields[name.Lexeme];
                if (foundField.IsPrivate)
                {
                    throw new RuntimeError(name, $"'{name.Lexeme}' is inaccessible due to it's protection level");
                }
                return(foundField.Value);
            }
            HlangFunction method = GetMethod(name);

            if (method != null)
            {
                return(method.Bind(this));
            }

            if (ParentClass != null)
            {
                return(ParentClass.Get(name));
            }

            throw new RuntimeError(name, $"Can't get undefined property '{name.Lexeme}'");
        }
Exemple #13
0
        public override bool Match(Fields fields)
        {
            var sample = fields.ContainsKey("sample") ? fields["sample"] : "";
            var match  = Regex.Match(sample, MatchPattern);

            return(match.Success && match.Length > 0);
        }
Exemple #14
0
        protected T GetField <T>(string key, string lazyFieldsKey = null) where T : IFieldWrapper
        {
            if (!Fields.ContainsKey(key))
            {
                object   lazyValue = null;
                var      typeOfT   = typeof(T);
                object[] constructorArgs;

                // Attempt to get lazy value
                if (lazyFieldsKey != null && _lazyFields != null && _lazyFields.ContainsKey(lazyFieldsKey))
                {
                    lazyValue = _lazyFields[lazyFieldsKey];
                }

                if (lazyValue == null)
                {
                    var scField = Item.Fields[key];

                    constructorArgs = new object[] { scField, _spawnProvider };
                }
                else
                {
                    constructorArgs = new object[] { key, this, _spawnProvider, lazyValue };
                }

                Fields[key] = (IFieldWrapper)Activator.CreateInstance(typeOfT, constructorArgs);
            }

            return((T)Fields[key]);
        }
Exemple #15
0
        protected override void CreateTable(DbDataReader r)
        {
            Directory.CreateDirectory(System.IO.Path.GetDirectoryName(Path));
            //writer = new StreamWriter(Path, false, new UTF8Encoding(false));
            writer = new StreamWriter(Path, false, Encoding.Default);

            int FieldCount = r.FieldCount;

            for (int i = 0; i < FieldCount; i++)
            {
                if (Fields.ContainsKey(r.GetName(i)))
                {
                    throw new ActionException($"出现相同的标题\"{r.GetName(i)}\"");
                }
                else
                {
                    Fields.Add(r.GetName(i), i);
                }
            }
            //标题
            if (WithTitle)
            {
                foreach (var item in Fields)
                {
                    SetValue(item.Key, item.Key);
                }
                UpdataRow();
            }
        }
Exemple #16
0
 /// <summary>
 /// If a single field was indexed with multiple values this will return those values, otherwise it will just return the single
 /// value stored for that field. If the field is not found it returns an empty collection.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public IEnumerable <string> GetValues(string key)
 {
     return(MultiValueFields.ContainsKey(key)
         ? MultiValueFields[key]
         : Fields.ContainsKey(key)
             ? new[] { Fields[key] }
             : Enumerable.Empty <string>());
 }
 public string Get(DE48_CustomerDataType type)
 {
     if (Fields.ContainsKey(type))
     {
         return(Fields[type]);
     }
     return(null);
 }
 /// <summary> Removes all occurrences of a tag </summary>
 /// <param name="Tag_Number"> Tag number of the MARC tags to remove </param>
 public void Remove_Tag(int Tag_Number)
 {
     // Remove from the list of Fields
     if (Fields.ContainsKey(Tag_Number))
     {
         Fields.Remove(Tag_Number);
     }
 }
 /// <summary> Gets data from a particular subfield within a singular data field  </summary>
 /// <param name="Tag">Tag for new data field</param>
 /// <param name="Subfield">Code for the subfield in question</param>
 /// <returns>The value of the subfield, or an empty string </returns>
 /// <remarks> If there are multiple instances of this subfield, then they are returned
 /// together with a '|' delimiter between them </remarks>
 public string Get_Data_Subfield(int Tag, char Subfield)
 {
     if ((Fields.ContainsKey(Tag)) && (Fields[Tag][0].has_Subfield(Subfield)))
     {
         return(Fields[Tag][0][Subfield]);
     }
     return(String.Empty);
 }
Exemple #20
0
 public string this[int uniqueId, string title]
 {
     set
     {
         Assert.IsTrue(Fields.ContainsKey(uniqueId));
         Fields[uniqueId][title] = value;
     }
 }
Exemple #21
0
 public override TypeExpression ExtractField(string fieldName)
 {
     if (Fields.ContainsKey(fieldName))
     {
         return(Fields[fieldName]);
     }
     return(new ErrorType(string.Format("There not be a field with name '{0}' in {1}", fieldName, Identifier)));
 }
Exemple #22
0
 public override void AddFieldDefinition(string name, Type type, int size)
 {
     if (!Fields.ContainsKey(name))
     {
         this.AddField(name + "_VarID", new FieldHeaderDefinition(name + "_VarID", this.VariableCount++));
         this.AddField(name, new VariableFieldDefinition(name, type, size));
     }
 }
Exemple #23
0
        protected void setField(string fieldName, IObject value)
        {
            if (fields.ContainsKey(fieldName))
            {
                fields.Remove(fieldName);
            }

            fields.New(fieldName, value);
        }
        /// <summary>
        ///     Safely the get value.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        /// <returns>System.Object.</returns>
        public object SafeGetValue(string fieldName)
        {
            if (!Fields.ContainsKey(fieldName))
            {
                return(null);
            }

            return(Fields[fieldName]);
        }
Exemple #25
0
        public DSTreeView GetField(string bizName)
        {
            if (Fields != null && bizName != null && Fields.ContainsKey(bizName))
            {
                return(Fields[bizName]);
            }

            return(null);
        }
Exemple #26
0
        EnumField GetConstant(string name)
        {
            if (Fields.ContainsKey(name))
            {
                return(Fields[name]);
            }

            return(EnumField.Invalid);
        }
Exemple #27
0
        public bool IsMatch(Fields fields)
        {
            if (fields.ContainsKey("sample"))
            {
                fields["sample"] = fields["sample"].TrunIntegerUseSample();
            }

            return(Match(fields));
        }
Exemple #28
0
        /// <summary>
        /// Add a new message error into the handler and attach it to a field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="message"></param>
        /// <param name="parameters">If a parameter contains {LANGUAGE_KEY}, it means that LANGUAGE_KEY must be replaced by the label of LANGUAGE_KEY for a given language</param>
        public void AddField(string field, string message, params object[] parameters)
        {
            if (!Fields.ContainsKey(field))
            {
                Fields[field] = new List <Error>();
            }

            Fields[field].Add(new Error(message, parameters));
        }
Exemple #29
0
 public bool AddField(string name, CbType type)
 {
     if (Fields.ContainsKey(name))
     {
         return(false); // error -- duplicate field name
     }
     Fields[name] = new CbField(name, type, this);
     return(true); // success
 }
 public void Add(string fieldName, IFieldInfoTypeDescriptor fieldDescriptor)
 {
     if (Fields.ContainsKey(fieldName))
     {
         Fields[fieldName] = fieldDescriptor;
         return;
     }
     Fields.Add(fieldName, fieldDescriptor);
 }