internal ClassInfo GetAndAddClassInfo(IFieldContainer rootClass, List <IFieldContainer> result)
        {
            IFieldContainer leftClass;

            if (Left == null)
            {
                leftClass = rootClass;
                if (!result.Contains(rootClass))
                {
                    result.Add(rootClass);
                }
            }
            else
            {
                leftClass = Left.GetAndAddClassInfo(rootClass, result);
            }

            FieldInfo field = leftClass.FindFieldByName(PropertyName);

            if (field == null)
            {
                throw new Exception("Field " + PropertyName + " not found in " + leftClass.Name);
            }

            if (field.ReferencedClass != null)
            {
                if (!result.Contains(field.ReferencedClass))
                {
                    result.Add(field.ReferencedClass);
                }
            }
            return(field.ReferencedClass);
        }
 /// <summary>
 /// Checks whether a field with the specified Id has already been defined.
 /// </summary>
 /// <param name="container">The field container to search.</param>
 /// <param name="fieldId">The field Id to check for.</param>
 /// <param name="node">The field being defined.</param>
 /// <returns>
 /// true if the field Id has already been defined, false otherwise.
 /// </returns>
 public static bool IsFieldIdAlreadyDefined(
     this IFieldContainer container,
     int fieldId,
     FieldContext node)
 {
     return(container.Fields
            .Where(item => item.FieldId == fieldId)
            .FirstOrDefault().Node != node);
 }
 /// <summary>
 /// Checks whether the field has already been defined.
 /// </summary>
 /// <param name="container">The field container to search.</param>
 /// <param name="name">The name of the field.</param>
 /// <param name="node">The field being defined.</param>
 /// <returns>
 /// true if the field name has already been defined, false otherwise.
 /// </returns>
 public static bool IsFieldNameAlreadyDefined(
     this IFieldContainer container,
     string name,
     FieldContext node)
 {
     return(container.Fields
            .Where(item => item.Name == name)
            .FirstOrDefault().Node != node);
 }
 public void Inject(Db db,
                    IBuildingAcquirer acquirer,
                    IBuildingService service,
                    IFieldContainer fieldContainer,
                    BuildingAssets buildingAssets)
 {
     this.db             = db;
     this.acquirer       = acquirer;
     this.service        = service;
     this.fieldContainer = fieldContainer;
     this.buildingAssets = buildingAssets;
 }
Esempio n. 5
0
        public async Task ValidateAsync(IFieldContainer fieldContainer)
        {
            if (fieldContainer == null)
            {
                throw new ArgumentNullException(nameof(fieldContainer));
            }

            var field = await this.GetBy(fieldContainer);

            if (fieldContainer.FieldId.HasValue && field == null)
            {
                throw new InvalidOperationException($"Field not found by id {fieldContainer.FieldId}");
            }
        }
Esempio n. 6
0
        public IFieldContainer FindContainerByName(string name)
        {
            IFieldContainer result = FindClassByName(name);

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

            result = FindRelationByName(name);
            if (result != null)
            {
                return(result);
            }

            throw new Exception(string.Format("'{0}' is neither a class nor a relation", name));
        }
        void Sooda.QL.ISoqlVisitor.Visit(SoqlQueryExpression v)
        {
            if (v.From.Count != 1)
            {
                throw new NotImplementedException();
            }
            IFieldContainer outerClass = _rootClass;

            _rootClass = _rootClass.Schema.FindContainerByName(v.From[0]);
            try
            {
                GetInvolvedClasses(v);
            }
            finally
            {
                _rootClass = outerClass;
            }
        }
 void Sooda.QL.ISoqlVisitor.Visit(SoqlQueryExpression v)
 {
     if (v.From.Count != 1)
         throw new NotImplementedException();
     IFieldContainer outerClass = _rootClass;
     _rootClass = _rootClass.Schema.FindContainerByName(v.From[0]);
     try
     {
         GetInvolvedClasses(v);
     }
     finally
     {
         _rootClass = outerClass;
     }
 }
Esempio n. 9
0
 public ImportColumns(IFieldContainer entity, Microsoft.VisualStudio.Modeling.Store store)
     : this()
 {
     _store  = store;
     _entity = entity;
 }
Esempio n. 10
0
 public async Task <Field> GetByAsync(IFieldContainer field)
 {
     return(field.FieldId.HasValue
         ? this.Mapper.Map <Field>(await this.Context.Field.FirstOrDefaultAsync(x => x.Id == field.FieldId))
         : null);
 }
 public void Inject(IBuildingSelector selector, IFieldContainer fieldContainer, BuildingAssets buildingAssets)
 {
     this.selector       = selector;
     this.fieldContainer = fieldContainer;
     this.buildingAssets = buildingAssets;
 }
Esempio n. 12
0
 public void Push(IFieldContainer value)
 {
     InnerStack.Push(value);
 }
Esempio n. 13
0
 public void AddFieldContainer(IFieldContainer container)
 {
     this.Controls.Add(container as Control);
 }
Esempio n. 14
0
        public static void ParseObjectFieldLine(PdlFile pdlFile, LfdReader reader, NamedObjectDefinition containingNamedObject,
                                                IFieldContainer containingObject, LfdLine fieldLine, out LfdLine nextLine)
        {
            //
            // Check if it is only a definition (enum or flag)
            //
            if (fieldLine.id.Equals("enum", StringComparison.OrdinalIgnoreCase))
            {
                ParseEnumOrFlagsDefinition(pdlFile, reader, containingNamedObject, fieldLine, out nextLine, false);
                return;
            }
            if (fieldLine.id.Equals("flags", StringComparison.OrdinalIgnoreCase))
            {
                ParseEnumOrFlagsDefinition(pdlFile, reader, containingNamedObject, fieldLine, out nextLine, true);
                return;
            }

            String typeString = fieldLine.id;

            //
            // The rest of the fields can have arrayParse the Array Size Type
            //
            PdlArrayType arrayType;

            int indexOfOpenBracket = typeString.IndexOf('[');

            if (indexOfOpenBracket < 0)
            {
                arrayType = null;
            }
            else
            {
                String arraySizeTypeString = typeString.Substring(indexOfOpenBracket + 1);

                typeString = typeString.Remove(indexOfOpenBracket);

                int indexOfCloseBracket = arraySizeTypeString.IndexOf(']');
                if (indexOfCloseBracket < 0)
                {
                    throw new ParseException(fieldLine, "Found an opening bracket '[' without a closing bracket");
                }
                if (indexOfCloseBracket != arraySizeTypeString.Length - 1)
                {
                    throw new ParseException(fieldLine, "The array size type '{0}' had a closing bracket, but the closing bracket was not the last character", arraySizeTypeString);
                }

                arraySizeTypeString = arraySizeTypeString.Remove(indexOfCloseBracket);
                arrayType           = PdlArrayType.Parse(fieldLine, arraySizeTypeString);
            }

            //
            // Parse object inline definition
            //
            if (typeString.Equals("object", StringComparison.OrdinalIgnoreCase))
            {
                VerifyFieldCount(fieldLine, 1);

                String objectDefinitionAndFieldName = fieldLine.fields[0];

                NamedObjectDefinition fieldObjectDefinition = ParseObjectDefinition(pdlFile, reader, fieldLine,
                                                                                    containingNamedObject, objectDefinitionAndFieldName, out nextLine);

                containingObject.AddField(new ObjectDefinitionField(
                                              new ObjectTypeReference(objectDefinitionAndFieldName, fieldObjectDefinition, arrayType),
                                              objectDefinitionAndFieldName));
                return;
            }

            //
            // Check if it is a serializer
            //
            if (fieldLine.id.Equals("serializer", StringComparison.OrdinalIgnoreCase))
            {
                VerifyFieldCount(fieldLine, 2);
                String       serializerLengthTypeString = fieldLine.fields[0];
                String       serializerFieldName        = fieldLine.fields[1];
                PdlArrayType serializerLengthType       = PdlArrayType.Parse(fieldLine, serializerLengthTypeString);

                containingObject.AddField(new ObjectDefinitionField(new SerializerTypeReference(serializerLengthType, arrayType), serializerFieldName));

                nextLine = reader.ReadLineIgnoreComments();
                return;
            }

            //
            // Check if it is an 'if' type
            //
            if (typeString.Equals("if", StringComparison.OrdinalIgnoreCase))
            {
                VerifyFieldCount(fieldLine, 1);

                IfTypeReference ifType = ParseIf(pdlFile, reader, fieldLine,
                                                 containingNamedObject, out nextLine);

                containingObject.AddField(new ObjectDefinitionField(ifType, null));
                return;
            }

            //
            // Check if it is a switch type
            //
            if (typeString.Equals("switch", StringComparison.OrdinalIgnoreCase))
            {
                VerifyFieldCount(fieldLine, 1);

                SwitchTypeReference switchType = ParseSwitch(pdlFile, reader, fieldLine,
                                                             containingNamedObject, out nextLine);

                containingObject.AddField(new ObjectDefinitionField(switchType, null));
                return;
            }

            //
            // The field is only one line, so read the next line now for the caller
            //
            nextLine = reader.ReadLineIgnoreComments();



            EnumOrFlagsDefinition enumDefinition = pdlFile.TryGetEnumOrFlagsDefinition(containingNamedObject, typeString);

            if (enumDefinition != null)
            {
                VerifyFieldCount(fieldLine, 1);
                containingObject.AddField(new ObjectDefinitionField(new EnumOrFlagsTypeReference(typeString, enumDefinition, arrayType),
                                                                    fieldLine.fields[0]));
                return;
            }

            // Check if it is an object type
            NamedObjectDefinition objectDefinition = pdlFile.TryGetObjectDefinition(containingNamedObject, typeString);

            if (objectDefinition != null)
            {
                if (fieldLine.fields == null || fieldLine.fields.Length <= 0)
                {
                    //
                    // Add each field from the object definition to the current object definition
                    //
                    List <ObjectDefinitionField> objectDefinitionFields = objectDefinition.Fields;
                    for (int i = 0; i < objectDefinitionFields.Count; i++)
                    {
                        ObjectDefinitionField fieldDefinition = objectDefinitionFields[i];
                        containingObject.AddField(fieldDefinition);
                    }
                }
                else if (fieldLine.fields.Length == 1)
                {
                    containingObject.AddField(new ObjectDefinitionField(
                                                  new ObjectTypeReference(typeString, objectDefinition, arrayType), fieldLine.fields[0]));
                }
                else
                {
                    throw new ParseException(fieldLine, "Expected line to have 0 or 1 fields but had {0}", fieldLine.fields.Length);
                }
                return;
            }

            //
            // Check if it a string type
            //
            if (typeString.Equals("ascii", StringComparison.OrdinalIgnoreCase))
            {
                VerifyFieldCount(fieldLine, 1);
                containingObject.AddField(new ObjectDefinitionField(
                                              new AsciiTypeReference(typeString, arrayType), fieldLine.fields[0]));
                return;
            }


            //
            // It must be an integer type
            //
            VerifyFieldCount(fieldLine, 1);

            PdlType type;

            try { type = (PdlType)Enum.Parse(typeof(PdlType), typeString, true); }
            catch (ArgumentException) { throw new FormatException(String.Format("Unknown Pdl Type '{0}'", typeString)); }
            if (!type.IsIntegerType())
            {
                throw new InvalidOperationException(String.Format("Unhandled PDL type '{0}'", type));
            }

            containingObject.AddField(new ObjectDefinitionField(new IntegerTypeReference(type, arrayType), fieldLine.fields[0]));
        }
Esempio n. 15
0
		public ImportColumns(IFieldContainer entity, Microsoft.VisualStudio.Modeling.Store store)
			: this()
		{
			_store = store;
			_entity = entity;
		}
 public GetInvolvedClassesVisitor(ClassInfo rootClass)
 {
     _rootClass = rootClass;
 }
        internal ClassInfo GetAndAddClassInfo(IFieldContainer rootClass, List<IFieldContainer> result)
        {
            IFieldContainer leftClass;

            if (Left == null)
            {
                leftClass = rootClass;
                if (!result.Contains(rootClass))
                    result.Add(rootClass);
            }
            else
            {
                leftClass = Left.GetAndAddClassInfo(rootClass, result);
            }

            FieldInfo field = leftClass.FindFieldByName(PropertyName);
            if (field == null)
                throw new Exception("Field " + PropertyName + " not found in " + leftClass.Name);

            if (field.ReferencedClass != null)
            {
                if (!result.Contains(field.ReferencedClass))
                    result.Add(field.ReferencedClass);
            }
            return field.ReferencedClass;
        }
Esempio n. 18
0
 private async Task <Field> GetBy(IFieldContainer fieldContainer)
 {
     return(await this.FieldDataAccess.GetByAsync(fieldContainer));
 }
 public GetInvolvedClassesVisitor(ClassInfo rootClass)
 {
     _rootClass = rootClass;
 }