示例#1
0
        public void InvokingComplexOperation_Expected_OperationInvoked()
        {
            var             channelFactory = new AsyncChannelFactory <ITestServiceOut>();
            var             channel        = channelFactory.CreateChannel();
            ComplexDataType data           = new ComplexDataType
            {
                Description = "in",
                Name        = "in name",
                Id          = 0,
            };

            var result =
                channel.ExecuteAsync(
                    ws => ws.ComplexMethod(ref data),
                    res =>
            {
                Assert.AreEqual("ref", data.Description);
                Assert.AreEqual("ref name", data.Name);
                Assert.AreEqual(1, data.Id);

                Assert.AreEqual("out", res.Description);
                Assert.AreEqual("out name", res.Name);
                Assert.AreEqual(2, res.Id);
                TestComplete();
            });
        }
示例#2
0
        public void Task_InvokingComplexOperation_Expected_OperationInvoked()
        {
            var             channelFactory = new AsyncChannelFactory <ITestServiceOut>();
            var             channel        = channelFactory.CreateChannel();
            ComplexDataType data           = new ComplexDataType
            {
                Description = "in",
                Name        = "in name",
                Id          = 0,
            };

            var result =
                channel.ExecuteTask(ws => ws.ComplexMethod(ref data))
                .ContinueWith(
                    t =>
            {
                var res = t.Result;
                Assert.AreEqual("ref", data.Description);
                Assert.AreEqual("ref name", data.Name);
                Assert.AreEqual(1, data.Id);

                Assert.AreEqual("out", res.Description);
                Assert.AreEqual("out name", res.Name);
                Assert.AreEqual(2, res.Id);
                TestComplete();
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
示例#3
0
        void WritePIMDefaultValues(StreamWriter writer, PimInstance pim)
        {
            String FieldValue = "            " + TestArtefactsVariable + "." + RteFunctionsGenerator.GenerateShortPimFunctionName(pim.Defenition) + ".data";

            IGUID datatype = pim.Defenition.DataType;

            if ((datatype is BaseDataType) || (datatype is SimpleDataType) || (datatype is EnumDataType))
            {
                String defValue = GetDefaultValueForUnComplexDataType(pim);
                writer.WriteLine(FieldValue + " = " + defValue + ";");
            }
            else if (datatype is ComplexDataType)
            {
                for (int defValueIndex = 0; defValueIndex < pim.DefaultValues.Count; defValueIndex++)
                {
                    ComplexDataType complexDataType = (ComplexDataType)datatype;
                    PimDefaultValue defaultValue    = pim.DefaultValues[defValueIndex];

                    ComplexDataTypeField dataTypefield = complexDataType.Fields.FindObject(defaultValue.FieldGuid);
                    if (dataTypefield != null)
                    {
                        String dataToWrite = FieldValue + "." + dataTypefield.Name + " = " + defaultValue.DefaultValue + ";";
                        writer.WriteLine(dataToWrite);
                    }
                }
            }
        }
        public static bool SortDependenciedCDT(ComplexDataTypesList datatypes)
        {
            /* Select dependencies */
            int IterationCount = 0;

            bool hasDependencyLower = true;
            while (hasDependencyLower && (IterationCount < 100))
            {
                IterationCount++;
                hasDependencyLower = false;
                for (int i = 0; i < datatypes.Count - 1; i++)
                {
                    /* Find max dependency index */
                    int maxDependency = findMaxDependency(datatypes, datatypes[i], i);

                    /* if there is dependency then move the datatype after dependency and start cycle again */
                    if (maxDependency != -1)
                    {
                        ComplexDataType cdt = datatypes[i];
                        datatypes.RemoveAt(i);
                        datatypes.Insert(maxDependency, cdt);
                        hasDependencyLower = true;
                        break;
                    }
                }
            }

            return IterationCount < 100;
        }
示例#5
0
        protected void TestComplexDataType(ComplexDataType elem)
        {
            bool withoutErrors = true;

            /* Check if fields have similar names */
            for (int i = 0; i < elem.Fields.Count - 1; i++)
            {
                for (int j = i + 1; j < elem.Fields.Count; j++)
                {
                    if (elem.Fields[i].Name == elem.Fields[j].Name)
                    {
                        withoutErrors = false;
                        AppendText(elem.Name + " has similar field names (" + elem.Fields[i].Name + ") of fields for " + i.ToString() + " and " + j.ToString() + " indexes", Error: true);
                    }
                }
            }

            /* CheckDatatype */
            foreach (ComplexDataTypeField field in elem.Fields)
            {
                if (field.DataTypeName.Equals(AutosarApplication.ErrorDataType))
                {
                    AppendText(elem.Name + " : " + field.Name + " doesn't have specified datatype ", Error: true);
                    withoutErrors = false;
                }
            }

            if (withoutErrors)
            {
                AppendText(elem.Name);
            }
        }
示例#6
0
        /// <summary>
        /// Creates a new instance of <see cref="ComplexDataType"/> which has the same properties as
        /// <paramref name="complexDataType"/>, except it references given complex type.
        /// </summary>
        /// <param name="complexDataType">The complex data type instance to start with.</param>
        /// <param name="fullTypeName">The full type name (including namespace).</param>
        /// <returns>
        /// New instance of <see cref="ComplexDataType"/>.
        /// </returns>
        public static ComplexDataType WithFullTypeName(this ComplexDataType complexDataType, string fullTypeName)
        {
            string localName, namespaceName;

            ParseFullTypeName(fullTypeName, out localName, out namespaceName);
            return(complexDataType.WithName(namespaceName, localName));
        }
示例#7
0
        String GenerateComplexDatatypeDefaultValue(ComplexDataType datatype, int indent)
        {
            String strIndent = RteFunctionsGenerator.FillStringForCount("", ' ', indent);
            String str       = "{" + Environment.NewLine;

            for (int i = 0; i < datatype.Fields.Count; i++)
            {
                ComplexDataTypeField field = datatype.Fields[i];
                if (IsDatatypeSimple(field.DataTypeGUID))
                {
                    str += RteFunctionsGenerator.GenerateDefaultValueForSimpleDataTypeField(field.Name, indent + 4);
                }
                else
                {
                    ComplexDataType complexDt = AutosarApplication.GetInstance().ComplexDataTypes.FindObject(field.DataTypeGUID);
                    str += RteFunctionsGenerator.FillStringForCount("", ' ', indent + 4) + "." + field.Name + " = " + Environment.NewLine;
                    str += RteFunctionsGenerator.FillStringForCount("", ' ', indent + 4) + GenerateComplexDatatypeDefaultValue(complexDt, indent + 4);
                }
                if (i != datatype.Fields.Count - 1)
                {
                    str += "," + Environment.NewLine;
                }
            }
            str += Environment.NewLine + strIndent + "}";
            return(str);
        }
            private static void Fixup(NamedStructuralType structuralType, List <NamedStructuralType> visited)
            {
                if (visited.Contains(structuralType))
                {
                    return;
                }

                visited.Add(structuralType);

                foreach (MemberProperty property in structuralType.Properties)
                {
                    PrimitiveDataType primitiveDataType = property.PropertyType as PrimitiveDataType;
                    ComplexDataType   complexDataType   = property.PropertyType as ComplexDataType;

                    if (complexDataType != null)
                    {
                        Fixup(complexDataType.Definition, visited);
                    }
                    else if (primitiveDataType != null)
                    {
                        Type clrType = primitiveDataType.GetFacetValue <PrimitiveClrTypeFacet, Type>(null);
                        ExceptionUtilities.CheckObjectNotNull(clrType, "PrimitiveClrTypeFacet has not been defined for the property: '{0}.{1}'.", structuralType.Name, property.Name);

                        AddDataGenerationHints(property, clrType);

                        property.PropertyType = FixupType(primitiveDataType, clrType);
                    }
                }
            }
示例#9
0
        public static string BuildMultiValueTypeName(this DataType elementType)
        {
            ExceptionUtilities.CheckArgumentNotNull(elementType, "elementType");

            PrimitiveDataType primitiveDataType = elementType as PrimitiveDataType;
            ComplexDataType   complexDataType   = elementType as ComplexDataType;

            if (primitiveDataType != null)
            {
                string edmTypeName  = primitiveDataType.GetFacetValue <EdmTypeNameFacet, string>(null);
                string edmNamespace = primitiveDataType.GetFacetValue <EdmNamespaceFacet, string>(null);

                if (!string.IsNullOrEmpty(edmTypeName) && !string.IsNullOrEmpty(edmNamespace))
                {
                    edmTypeName = edmNamespace + '.' + edmTypeName;
                }

                if (!string.IsNullOrEmpty(edmTypeName))
                {
                    edmTypeName = "Collection(" + edmTypeName + ")";
                }

                return(edmTypeName);
            }
            else
            {
                ExceptionUtilities.Assert(complexDataType != null, "Unexpected TypeName to create for a Collection '{0}'", elementType);
                return("Collection(" + complexDataType.Definition.FullName + ")");
            }
        }
        public bool IsDataTypeComlex(Guid GUID)
        {
            //BaseDataType baseDatatype = BaseDataTypes.FindObject(GUID);
            //if (baseDatatype != null)
            //{
            //    return false;
            //}

            //SimpleDataType simpleDataType = SimpleDataTypes.FindObject(GUID);
            //if (simpleDataType != null)
            //{
            //    return false;
            //}

            ComplexDataType complexDataType = ComplexDataTypes.FindObject(GUID);

            if (complexDataType != null)
            {
                return(true);
            }

            //EnumDataType enumDataType = Enums.FindObject(GUID);
            //if (enumDataType != null)
            //{
            //    return false;
            //}

            return(false);
        }
示例#11
0
        IEdmTypeReference IDataTypeVisitor <IEdmTypeReference> .Visit(ComplexDataType dataType)
        {
            var complexTypeDefinition = (IEdmComplexType)this.currentEdmModel.FindType(dataType.Definition.FullName);

            return(complexTypeDefinition.ToTypeReference()
                   .Nullable(dataType.IsNullable));
        }
示例#12
0
            /// <summary>
            /// Visits the specified complex type.
            /// </summary>
            /// <param name="dataType">Data type.</param>
            /// <returns>the data type with all references resolved</returns>
            public DataType Visit(ComplexDataType dataType)
            {
                ComplexType resolved = this.parent.ResolveComplexTypeReference(this.model, dataType.Definition);

                return(DataTypes.ComplexType
                       .Nullable(dataType.IsNullable)
                       .WithDefinition(resolved));
            }
示例#13
0
        private IDataGenerator ResolveNonCollectionDataGenerator(DataType dataType, bool isUnique, IList <DataGenerationHint> dataGenHints)
        {
            ComplexDataType complexDataType = dataType as ComplexDataType;

            if (complexDataType != null)
            {
                var complexGenerator = this.GetOrCreateAndRegisterStructuralDataGeneratorForComplexType(complexDataType.Definition);
                if (dataType.IsNullable)
                {
                    return(new NullableNamedValuesGeneratorProxy(complexGenerator, this.Random, dataGenHints));
                }

                return(complexGenerator);
            }

            EnumDataType enumDataType = dataType as EnumDataType;

            if (enumDataType != null)
            {
                return(this.GetOrCreateAndRegisterNonCollectionDataGeneratorForEnumType(enumDataType, isUnique, dataGenHints));
            }

            PrimitiveDataType primitiveDataType = dataType as PrimitiveDataType;
            SpatialDataType   spatialType       = dataType as SpatialDataType;

            if (primitiveDataType == null)
            {
                throw new TaupoNotSupportedException(
                          string.Format(CultureInfo.InvariantCulture, "Data generator creation is not supported for this data type: '{0}'.", dataType.ToString()));
            }
            else if (spatialType != null)
            {
                ExceptionUtilities.CheckObjectNotNull(
                    this.SpatialDataGeneratorResolver,
                    "Cannot generate value for spatial data type '{0}' without SpatialDataGeneratorResolver being set",
                    dataType);

                var isUniqueHint = dataGenHints.OfType <AllUniqueHint>().SingleOrDefault();

                if (isUniqueHint != null)
                {
                    isUnique = true;
                }

                return(this.SpatialDataGeneratorResolver.GetDataGenerator(spatialType, isUnique, this.Random, dataGenHints.ToArray()));
            }
            else
            {
                Type clrType    = null;
                bool isNullable = true;

                clrType = primitiveDataType.GetFacetValue <PrimitiveClrTypeFacet, Type>(null);
                ExceptionUtilities.CheckObjectNotNull(clrType, "Facet of type '{0}' not defined on a property type '{1}'.", typeof(PrimitiveClrTypeFacet).Name, dataType);
                isNullable = primitiveDataType.IsNullable;

                return(this.ResolvePrimitiveDataGeneratorBasedOnClrType(clrType, isUnique, isNullable, dataGenHints));
            }
        }
示例#14
0
        /// <summary>
        /// Builds a complex property instance for the given metadata property with the given flattened values
        /// </summary>
        /// <param name="property">The metadata for the property</param>
        /// <param name="propertyPath">Property Path to start on for the memberProperty</param>
        /// <param name="namedValues">The flattened values</param>
        /// <returns>A complex property instance</returns>
        private ComplexProperty ComplexProperty(MemberProperty property, string propertyPath, IEnumerable <NamedValue> namedValues)
        {
            ExceptionUtilities.CheckArgumentNotNull(property, "property");

            ComplexDataType complexType = property.PropertyType as ComplexDataType;

            ExceptionUtilities.CheckObjectNotNull(complexType, "Property '{0}' was not complex", property.Name);

            return(new ComplexProperty(property.Name, this.ComplexInstance(complexType.Definition, propertyPath, namedValues)));
        }
示例#15
0
        /// <summary>
        /// Builds a complex property instance for the given metadata property with the given anonymous type value
        /// </summary>
        /// <param name="memberProperty">The metadata for the property</param>
        /// <param name="anonymous">An anonymous type describing the property values of the complex instance</param>
        /// <returns>A complex property instance</returns>
        public ComplexProperty ComplexProperty(MemberProperty memberProperty, object anonymous)
        {
            ExceptionUtilities.CheckArgumentNotNull(memberProperty, "memberProperty");

            ComplexDataType complexType = memberProperty.PropertyType as ComplexDataType;

            ExceptionUtilities.CheckObjectNotNull(complexType, "Property '{0}' was not complex", memberProperty.Name);

            return(new ComplexProperty(memberProperty.Name, this.ComplexInstance(complexType.Definition, anonymous)));
        }
示例#16
0
        private static void CachePropertiesValues(List <NamedValue> list, string path, string structuralTypeFullName, IEnumerable <MemberProperty> properties, object obj, IEntityModelObjectServices objectServices)
        {
            var adapter = objectServices.GetObjectAdapter(structuralTypeFullName);

            foreach (MemberProperty property in properties.Where(p => !(p.PropertyType is StreamDataType)))
            {
                object value = adapter.GetMemberValue <object>(obj, property.Name);

                ComplexDataType    complexDataType    = property.PropertyType as ComplexDataType;
                CollectionDataType collectionDataType = property.PropertyType as CollectionDataType;

                if (collectionDataType != null && value != null)
                {
                    var complexElementDataType = collectionDataType.ElementDataType as ComplexDataType;

                    IEnumerable enumerable = value as IEnumerable;
                    ExceptionUtilities.CheckObjectNotNull(enumerable, "Property type is a collection but does not implement IEnumerable. Property path: '{0}'.", path + property.Name);

                    int count = 0;
                    foreach (var collectionElement in enumerable)
                    {
                        string currentPath = path + property.Name + "." + count;
                        if (complexElementDataType == null || collectionElement == null)
                        {
                            list.Add(new NamedValue(currentPath, collectionElement));
                        }
                        else
                        {
                            CachePropertiesValues(
                                list,
                                currentPath + ".",
                                complexElementDataType.Definition.FullName,
                                complexElementDataType.Definition.Properties,
                                collectionElement,
                                objectServices);
                        }

                        count++;
                    }

                    if (count == 0)
                    {
                        list.Add(new NamedValue(path + property.Name, EmptyData.Value));
                    }
                }
                else if (value == null || complexDataType == null)
                {
                    list.Add(new NamedValue(path + property.Name, value));
                }
                else
                {
                    CachePropertiesValues(list, path + property.Name + ".", complexDataType.Definition.FullName, complexDataType.Definition.Properties, value, objectServices);
                }
            }
        }
 private ComplexDataType ResolveComplexType(ComplexDataType dataTypeSpecification)
 {
     if (dataTypeSpecification.IsNullable)
     {
         return(dataTypeSpecification);
     }
     else
     {
         return(dataTypeSpecification.Nullable());
     }
 }
 private ComplexDataType ResolveComplexType(ComplexDataType dataTypeSpecification)
 {
     if (dataTypeSpecification.IsNullable)
     {
         return dataTypeSpecification;
     }
     else
     {
         return dataTypeSpecification.Nullable();
     }
 }
示例#19
0
        public void UpdateDefaultValues()
        {
            this.Name = Defenition.Name;

            PimDefaultValuesList newDefValuesList = new PimDefaultValuesList();

            /* Create new list */
            object datatype = AutosarApplication.GetInstance().GetDataType(Defenition.DatatypeGuid);

            if (datatype != null)
            {
                if ((datatype is BaseDataType) || (datatype is SimpleDataType) || (datatype is EnumDataType) || (datatype is ArrayDataType))
                {
                    AddSimpleDataTypeDefaultValue(newDefValuesList, "", false, Name, 0);
                }
                else if (datatype is ComplexDataType)
                {
                    ComplexDataType compDataType = (ComplexDataType)datatype;
                    foreach (ComplexDataTypeField field in compDataType.Fields)
                    {
                        if (AutosarApplication.GetInstance().IsDataTypeComlex(field.DataTypeGUID))
                        {
                            AddComplexDataTypeFields(newDefValuesList, Name + "." + field.Name, field);
                        }
                        else
                        {
                            AddComplexDataTypeFieldDefaultValue(newDefValuesList, Name, field);
                        }
                    }
                }
            }

            /* Remove unexists */
            for (int i = DefaultValues.Count - 1; i >= 0; i--)
            {
                if (FindName(newDefValuesList, DefaultValues[i].Name) == false)
                {
                    DefaultValues.RemoveAt(i);
                }
            }

            /* Add new */
            {
                foreach (PimDefaultValue pimDefValue in newDefValuesList)
                {
                    if (FindName(DefaultValues, pimDefValue.Name) == false)
                    {
                        DefaultValues.Add(pimDefValue);
                    }
                }
            }
        }
 public bool Delete(ComplexDataType complexDataType)
 {
     if (isComplexDataTypeUsed(complexDataType) == false)
     {
         ComplexDataTypes.Remove(complexDataType);
         return(true);
     }
     else
     {
         /* datatype is used and we cannot delete it */
         return(false);
     }
 }
示例#21
0
        void WriteZeroDefaultValuesForComplexDataType(StreamWriter writer, ComplexDataType datatype)
        {
            writer.Write("{ ");
            for (int i = 0; i < datatype.Fields.Count; i++)
            {
                WriteZeroDefaultValue(writer, datatype.Fields[i].DataType);
                if (i < datatype.Fields.Count - 1)
                {
                    writer.Write(", ");
                }
            }

            writer.Write(" }");
        }
示例#22
0
            /// <summary>
            /// Visits the specified complex type.
            /// </summary>
            /// <param name="dataType">Entity data type.</param>
            /// <returns>Implementation-specific value.</returns>
            public IList <string> Visit(ComplexDataType dataType)
            {
                ComplexType    complexType = dataType.Definition;
                IList <string> paths;

                if (!this.entityContainerData.nonKeyPropertyPathsPerStructuralType.TryGetValue(complexType, out paths))
                {
                    paths = this.BuildPropertyPaths(complexType.Properties, complexType.FullName);

                    this.entityContainerData.nonKeyPropertyPathsPerStructuralType[complexType] = paths;
                }

                return(paths);
            }
        static bool isComplexDataTypeWithoutDependenciesToOtherCDT(ComplexDataType cdt)
        {
            ComplexDataTypesList allCDT = AutosarApplication.GetInstance().ComplexDataTypes;
            foreach(ComplexDataTypeField field in cdt.Fields)
            {
                ComplexDataType findedCDT = allCDT.FindObject(field.DataTypeGUID);
                if (findedCDT != null)
                {
                    return false;
                }
            }

            return true;
        }
示例#24
0
 public ComplexDataType ComplexMethod(ref ComplexDataType param)
 {
     param = new ComplexDataType
     {
         Description = "ref",
         Name        = "ref name",
         Id          = 1
     };
     return(new ComplexDataType
     {
         Description = "out",
         Name = "out name",
         Id = 2
     });
 }
示例#25
0
        private void PopulateMultiValuePropertyFromPaths(ComplexInstance instance, MemberProperty memberProperty, DataType elementType, string propertyPath, IEnumerable <NamedValue> namedValues)
        {
            PrimitiveDataType primitiveElementDataType   = elementType as PrimitiveDataType;
            ComplexDataType   complexTypeElementDataType = elementType as ComplexDataType;

            if (primitiveElementDataType != null)
            {
                this.PopulatePrimitiveBagPropertyFromPaths(instance, memberProperty, propertyPath, namedValues, primitiveElementDataType);
            }
            else
            {
                ExceptionUtilities.CheckObjectNotNull(complexTypeElementDataType, "PropertyPath '{0}' is an invalid type '{1}'", propertyPath, memberProperty.PropertyType);

                this.PopulateComplexMultiValuePropertyFromPaths(instance, memberProperty, propertyPath, namedValues, complexTypeElementDataType);
            }
        }
示例#26
0
        private static void GetPropertyPaths(IList <string> list, string path, IEnumerable <MemberProperty> properties, Func <string, MemberProperty, bool> filter)
        {
            foreach (MemberProperty property in properties.Where(p => filter == null || filter(path + p.Name, p)))
            {
                ComplexDataType complexDataType = property.PropertyType as ComplexDataType;

                if (complexDataType == null)
                {
                    list.Add(path + property.Name);
                }
                else
                {
                    GetPropertyPaths(list, path + property.Name + ".", complexDataType.Definition.Properties, filter);
                }
            }
        }
 static int findMaxDependency(ComplexDataTypesList datatypes, ComplexDataType currentDataType, int startIndex)
 {
     int maxDependency = -1;
      foreach (ComplexDataTypeField field in currentDataType.Fields)
      {
          for (int i = startIndex; i < datatypes.Count; i++)
          {
              if (field.DataTypeGUID.Equals(datatypes[i].GUID))
              {
                  if (maxDependency < i)
                  {
                      maxDependency = i;
                  }
              }
          }
      }
      return maxDependency;
 }
示例#28
0
        private void AddComplexDataTypeFields(PimDefaultValuesList newDefValuesList, String baseName, ComplexDataTypeField field)
        {
            object datatype = AutosarApplication.GetInstance().GetDataType(field.DataTypeGUID);

            ComplexDataType compDataType = (ComplexDataType)datatype;

            foreach (ComplexDataTypeField cmplfield in compDataType.Fields)
            {
                if (AutosarApplication.GetInstance().IsDataTypeComlex(cmplfield.DataTypeGUID))
                {
                    AddComplexDataTypeFields(newDefValuesList, baseName + "." + cmplfield.Name, cmplfield);
                }
                else
                {
                    AddComplexDataTypeFieldDefaultValue(newDefValuesList, baseName, cmplfield);
                }
            }
        }
示例#29
0
        /// <summary>
        /// Converts a complex data type to a complex type.
        /// </summary>
        /// <param name="complexType">The complex data type to convert.</param>
        /// <returns>The corresponding complex type.</returns>
        private static IEdmComplexTypeReference GetComplexType(IEdmModel model, ComplexDataType complexDataType)
        {
            Debug.Assert(complexDataType != null, "complexDataType != null");

            IEdmSchemaType edmType = model.FindType(complexDataType.Definition.FullName);

            ExceptionUtilities.Assert(
                edmType != null,
                "The expected complex type '{0}' was not found in the entity model for this test.",
                complexDataType.Definition.FullName);

            IEdmComplexType complexType = edmType as IEdmComplexType;

            ExceptionUtilities.Assert(
                complexType != null,
                "The expected complex type '{0}' is not defined as complex type in the test's metadata.",
                complexDataType.Definition.FullName);
            return((IEdmComplexTypeReference)complexType.ToTypeReference(complexDataType.IsNullable));
        }
示例#30
0
 /// <summary>
 /// Initializes static members of the DataTypes class.
 /// </summary>
 static DataTypes()
 {
     Integer = new IntegerDataType();
     Stream = new StreamDataType();
     String = new StringDataType();
     Boolean = new BooleanDataType();
     FixedPoint = new FixedPointDataType();
     FloatingPoint = new FloatingPointDataType();
     DateTime = new DateTimeDataType();
     Binary = new BinaryDataType();
     Guid = new GuidDataType();
     TimeOfDay = new TimeOfDayDataType();
     ComplexType = new ComplexDataType();
     EntityType = new EntityDataType();
     CollectionType = new CollectionDataType();
     ReferenceType = new ReferenceDataType();
     RowType = new RowDataType();
     EnumType = new EnumDataType();
     Spatial = new SpatialDataType();
 }
示例#31
0
        private void AddComplexDataTypeMenu_Click(object sender, RoutedEventArgs e)
        {
            string ComplexDataTypeTemplateName = "New_ComplexDataType";

            if (autosarApp.ComplexDataTypes.FindObject(ComplexDataTypeTemplateName) != null)
            {
                int index = 0;
                while (autosarApp.ComplexDataTypes.FindObject(ComplexDataTypeTemplateName) != null)
                {
                    index++;
                    ComplexDataTypeTemplateName = "New_ComplexDataType" + index.ToString();
                }
            }

            ComplexDataType datatype = DataTypeFabric.Instance().CreateComplexDataType(ComplexDataTypeTemplateName);

            autosarApp.ComplexDataTypes.Add(datatype);
            AutosarTree.UpdateAutosarTreeView(datatype);
            AutosarTree.Focus();
        }
        private void CompareMemberPropertyDatatype(string memberName, DataType expectedDataType, DataType actualDataType)
        {
            PrimitiveDataType  expectedPrimitiveDataType  = expectedDataType as PrimitiveDataType;
            ComplexDataType    expectedComplexDataType    = expectedDataType as ComplexDataType;
            CollectionDataType expectedCollectionDataType = expectedDataType as CollectionDataType;
            SpatialDataType    expectedSpatialDataType    = expectedDataType as SpatialDataType;

            if (expectedPrimitiveDataType != null)
            {
                PrimitiveDataType actualPrimitiveDataType = actualDataType as PrimitiveDataType;
                this.WriteErrorIfFalse(actualPrimitiveDataType != null, "Expected member '{0}' with primitiveDataType '{1}' instead of '{2}'", memberName, expectedPrimitiveDataType, actualDataType);

                if (expectedSpatialDataType != null)
                {
                    SpatialDataType actualSpatialDataType = actualDataType as SpatialDataType;
                    this.CompareSpatialDataType(memberName, expectedSpatialDataType, actualSpatialDataType);
                }
            }
            else if (expectedComplexDataType != null)
            {
                ComplexDataType actualComplexDataType = actualDataType as ComplexDataType;
                if (!this.WriteErrorIfFalse(expectedComplexDataType != null, "Expected member '{0}' with complexDataType '{1}' instead of '{2}'", memberName, expectedComplexDataType, actualDataType))
                {
                    this.WriteErrorIfFalse(expectedComplexDataType.Definition.Name == actualComplexDataType.Definition.Name, "Expected member '{0}' with complexType Name '{1}' not '{2}'", memberName, expectedComplexDataType.Definition.Name, actualComplexDataType.Definition.Name);
                }
            }
            else
            {
                CollectionDataType actualCollectionDataType = actualDataType as CollectionDataType;
                if (!this.WriteErrorIfFalse(expectedCollectionDataType != null, "Expected member '{0}' with collectionType '{1}' instead of '{2}'", memberName, expectedCollectionDataType, actualDataType))
                {
                    this.CompareMemberPropertyDatatype(memberName, expectedCollectionDataType.ElementDataType, actualCollectionDataType.ElementDataType);
                }
            }

            // Complex properties need not be handled specially as they can also have IsNullable = true. The scenario for complex property is given below:
            // For reflection and custom: If the DSV <= 2 then it should always contain Nullable=’false’. For DSV >= 3, it should always contain Nullable=’true’
            // For EF: For all DSV values it should always contain Nullable=’false’ since complex types are always non-nullable in EF.
            this.WriteErrorIfFalse(expectedDataType.IsNullable == actualDataType.IsNullable, "Expected member '{0}' to have an IsNullable of '{1}' instead of '{2}'", memberName, expectedDataType.IsNullable, actualDataType.IsNullable);
        }
示例#33
0
        private void PopulateComplexMultiValuePropertyFromPaths(ComplexInstance instance, MemberProperty memberProperty, string propertyPath, IEnumerable<NamedValue> namedValues, ComplexDataType complexTypeElementDataType)
        {
            int i = 0;
            bool completed = false;

            var complexCollection = new ComplexMultiValueProperty(memberProperty.Name, new ComplexMultiValue(complexTypeElementDataType.BuildMultiValueTypeName(), false));
            while (!completed)
            {
                IEnumerable<NamedValue> complexInstanceNamedValues = namedValues.Where(pp => pp.Name.StartsWith(propertyPath + "." + i + ".", StringComparison.Ordinal)).ToList();
                if (complexInstanceNamedValues.Count() == 0)
                {
                    completed = true;
                }
                else
                {
                    ComplexInstance complexInstance = this.ComplexInstance(complexTypeElementDataType.Definition, propertyPath + "." + i, complexInstanceNamedValues);
                    complexCollection.Value.Add(complexInstance);
                }

                i++;
            }

            if (i > 1)
            {
                instance.Add(complexCollection);
            }
        }
示例#34
0
        /// <summary>
        /// Converts a complex data type to a complex type.
        /// </summary>
        /// <param name="complexType">The complex data type to convert.</param>
        /// <returns>The corresponding complex type.</returns>
        private static IEdmComplexTypeReference GetComplexType(IEdmModel model, ComplexDataType complexDataType)
        {
            Debug.Assert(complexDataType != null, "complexDataType != null");

            IEdmSchemaType edmType = model.FindType(complexDataType.Definition.FullName);
            ExceptionUtilities.Assert(
                edmType != null,
                "The expected complex type '{0}' was not found in the entity model for this test.",
                complexDataType.Definition.FullName);

            IEdmComplexType complexType = edmType as IEdmComplexType;
            ExceptionUtilities.Assert(
                complexType != null,
                "The expected complex type '{0}' is not defined as complex type in the test's metadata.",
                complexDataType.Definition.FullName);
            return (IEdmComplexTypeReference)complexType.ToTypeReference(complexDataType.IsNullable);
        }