Exemple #1
0
        public void CsdlUnnamedTypeDefinitionToStringTest()
        {
            const string csdl =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<Schema Namespace=""Namespace"" Alias=""Alias"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
  <EntityType Name=""AstonishingEntity"">
    <Key>
      <PropertyRef Name=""Id"" />
    </Key>
    <Property Name=""Id"" Type=""Int32"" Nullable=""false"" />
  </EntityType>
  <Function Name=""Function1""><ReturnType Type=""Edm.Int32""/>
    <Parameter Name=""P1"" Type=""Collection(Edm.Int32)"" />
    <Parameter Name=""P2"" Type=""Ref(Namespace.AstonishingEntity)"" />
  </Function>
</Schema>";
            IEdmModel model;
            IEnumerable <EdmError> errors;
            bool parsed = CsdlReader.TryParse(new XmlReader[] { XmlReader.Create(new StringReader(csdl)) }, out model, out errors);

            Assert.IsTrue(parsed, "parsed");
            Assert.IsTrue(errors.Count() == 0, "No errors");

            IEdmOperation           operation  = (IEdmOperation)(model.FindOperations("Namespace.Function1")).First();
            IEdmCollectionType      collection = (IEdmCollectionType)operation.FindParameter("P1").Type.Definition;
            IEdmEntityReferenceType entityRef  = (IEdmEntityReferenceType)operation.FindParameter("P2").Type.Definition;

            Assert.AreEqual("Collection([Edm.Int32 Nullable=True])", collection.ToString(), "To string correct");
            Assert.AreEqual("EntityReference(Namespace.AstonishingEntity)", entityRef.ToString(), "To string correct");
        }
        private static string ToTraceString(this IEdmEntityReferenceType type)
        {
            object traceString;

            object[] str = new object[4];
            str[0] = EdmTypeKind.EntityReference.ToString();
            str[1] = (char)40;
            object[] objArray = str;
            int      num      = 2;

            if (type.EntityType != null)
            {
                traceString = type.EntityType.ToTraceString();
            }
            else
            {
                traceString = "";
            }
            objArray[num] = traceString;
            str[3]        = (char)41;
            return(string.Concat(str));
        }
Exemple #3
0
 private static string ToTraceString(this IEdmEntityReferenceType type)
 {
     return(EdmTypeKind.EntityReference.ToString() + '(' + (type.EntityType != null ? type.EntityType.ToTraceString() : "") + ')');
 }
Exemple #4
0
 private static bool IsEquivalentTo(this IEdmEntityReferenceType thisType, IEdmEntityReferenceType otherType)
 {
     return(thisType.EntityType.IsEquivalentTo(otherType.EntityType));
 }
Exemple #5
0
 protected virtual void ProcessEntityReferenceType(IEdmEntityReferenceType definition)
 {
     this.ProcessElement(definition);
     this.ProcessType(definition);
 }
Exemple #6
0
 public EdmEntityReferenceTypeReference(IEdmEntityReferenceType entityReferenceType, bool isNullable) : base(entityReferenceType, isNullable)
 {
 }
 /// <summary>
 /// Convert to TypeReference from definition
 /// </summary>
 /// <param name="definition">The type definition</param>
 /// <returns>The type reference</returns>
 public static IEdmEntityReferenceTypeReference ToTypeReference(this IEdmEntityReferenceType definition)
 {
     return(EntityReferenceTypeReference(definition));
 }
 /// <summary>
 /// Constructs a EntityReference type reference from definition
 /// </summary>
 /// <param name="definition">The EntityReference type definition</param>
 /// <returns>The EntityReference type reference</returns>
 public static IEdmEntityReferenceTypeReference EntityReferenceTypeReference(IEdmEntityReferenceType definition)
 {
     return(new EdmEntityReferenceTypeReference(definition, true));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EdmEntityReferenceTypeReference"/> class.
 /// </summary>
 /// <param name="entityReferenceType">The definition referred to by this reference.</param>
 /// <param name="isNullable">Denotes whether the type can be nullable.</param>
 public EdmEntityReferenceTypeReference(IEdmEntityReferenceType entityReferenceType, bool isNullable)
     : base(entityReferenceType, isNullable)
 {
 }
 private static bool IsEquivalentTo(this IEdmEntityReferenceType thisType, IEdmEntityReferenceType otherType)
 {
     return thisType.EntityType.IsEquivalentTo(otherType.EntityType);
 }
 /// <summary>
 /// Constructs a EntityReference type reference from definition
 /// </summary>
 /// <param name="definition">The EntityReference type definition</param>
 /// <returns>The EntityReference type reference</returns>
 public static IEdmEntityReferenceTypeReference EntityReferenceTypeReference(IEdmEntityReferenceType definition)
 {
     return new EdmEntityReferenceTypeReference(definition, true);
 }