Example #1
0
        public static Identifier GetConcreteTypeName(OdcmType odcmType)
        {
            if (odcmType is OdcmPrimitiveType)
                return GetPrimitiveTypeName(odcmType);

            return ResolveIdentifier(odcmType);
        }
Example #2
0
        public static Identifier GetPublicTypeName(OdcmType odcmType, bool isCollection)
        {
            if (odcmType == null)
            {
                return new Identifier(string.Empty, "void");
            }

            if (odcmType.Namespace == OdcmNamespace.Edm)
            {
                return GetPrimitiveTypeName(odcmType);
            }

            if (odcmType is OdcmClass && ((OdcmClass)odcmType).Kind == OdcmClassKind.Entity)
            {
                return GetConcreteInterfaceName(odcmType);
            }

            if (odcmType is OdcmClass && ((OdcmClass)odcmType).Kind == OdcmClassKind.MediaEntity)
            {
                return GetConcreteInterfaceName(odcmType);
            }

            var resolvedName = ResolveIdentifier(odcmType);

            return new Identifier(resolvedName.Namespace, resolvedName.Name + (isCollection ? "[]" : string.Empty));
        }
Example #3
0
        public static bool IsValueType(OdcmType type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            return
                type is OdcmEnum ||
                (
                    type is OdcmPrimitiveType &&
                    type.Namespace.Name.Equals("Edm", StringComparison.OrdinalIgnoreCase) &&
                    (
                        type.Name.Equals("Boolean", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Byte", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Date", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("DateTimeOffset", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Decimal", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Double", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Duration", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Int16", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Int32", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Int64", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("SByte", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Single", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("Guid", StringComparison.OrdinalIgnoreCase) ||
                        type.Name.Equals("TimeOfDay", StringComparison.OrdinalIgnoreCase)
                    )
                );
        }
 private ConcreteNavigationCollectionProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     FieldName = NamesService.GetConcreteFieldName(odcmProperty);
     OdcmType = odcmProperty.Type;
     PrivateSet = true;
     Type = new Type(NamesService.GetExtensionTypeName("IPagedCollection"),
         new Type(NamesService.GetConcreteInterfaceName(odcmProperty.Type)));
 }
 public ConcreteExecuteAsyncMethod(OdcmType odcmType)
 {
     EntityIdentifier = NamesService.GetConcreteInterfaceName(odcmType);
     DefiningInterface = NamesService.GetFetcherInterfaceName(odcmType);
     Name = "ExecuteAsync";
     Parameters = Parameter.Empty;
     ReturnType = new Type(new Identifier("global::System.Threading.Tasks", "Task"),
          new Type(NamesService.GetConcreteInterfaceName(odcmType)));
 }
Example #6
0
        public void AddType(OdcmType type)
        {
            string @namespace = type.Namespace.Name;

            OdcmNamespace odcmNamespace = Namespaces.FirstOrDefault(x => x.Name == @namespace);

            if (odcmNamespace == null)
            {
                odcmNamespace = new OdcmNamespace(@namespace);
                Namespaces.Add(odcmNamespace);
            }

            _Types.Add(type);

            odcmNamespace.Types.Add(type);
        }
Example #7
0
        public void AddType(OdcmType type)
        {
            string        @namespace    = type.Namespace;
            OdcmNamespace odcmNamespace = null;

            foreach (OdcmNamespace candidate in Namespaces)
            {
                if (string.Equals(candidate.Name, @namespace))
                {
                    odcmNamespace = candidate;
                    break;
                }
            }
            if (odcmNamespace == null)
            {
                odcmNamespace = new OdcmNamespace(@namespace);
                Namespaces.Add(odcmNamespace);
            }

            _Types.Add(type);
            odcmNamespace.Types.Add(type);
        }
Example #8
0
 public static Identifier GetPublicTypeName(OdcmType odcmType)
 {
     return GetPublicTypeName(odcmType, false);
 }
Example #9
0
 public ConcreteUpcastMethod(OdcmType baseType, OdcmType derivedType) : base(baseType, derivedType)
 {
     DefiningInterface = NamesService.GetFetcherInterfaceName(baseType);
 }
Example #10
0
 public UpcastMethodBase(OdcmType baseType, OdcmType derivedType)
 {
     BaseType = baseType;
     DerivedType = derivedType;
     Visibility = Visibility.Public;
 }
Example #11
0
 public FetcherUpcastMethod(OdcmType baseType, OdcmType derivedType) : base(baseType, derivedType)
 {
     Name = "To" + derivedType.Name;
     Parameters = global::Vipr.Writer.CSharp.Parameters.Empty;
     ReturnType = new Type(NamesService.GetFetcherInterfaceName(derivedType));
 }
Example #12
0
 public static Identifier GetPrimitiveTypeName(OdcmType odcmType)
 {
     return GetPrimitiveTypeName(odcmType.Name);
 }
Example #13
0
        public static Identifier GetConcreteInterfaceName(OdcmType odcmType)
        {
            var resolvedName = ResolveIdentifier(odcmType);

            return new Identifier(resolvedName.Namespace, "I" + resolvedName.Name);
        }
Example #14
0
 private static Identifier ResolveIdentifier(OdcmType odcmType)
 {
     return ResolveIdentifier(odcmType.Namespace.Name, odcmType.Name);
 }
Example #15
0
 public static Type GetNullableType(OdcmType type)
 {
     return new Type(new Identifier("System", "Nullable"), new Type(NamesService.GetPublicTypeName(type)));
 }
Example #16
0
 public static Identifier GetFetcherInterfaceName(OdcmType odcmType)
 {
     var fetcherTypeName = GetFetcherTypeName(odcmType);
     return GetConcreteInterfaceName(fetcherTypeName);
 }
Example #17
0
        public static Identifier GetFetcherTypeName(OdcmType odcmType)
        {
            var resolvedName = ResolveIdentifier(odcmType);

            return new Identifier(resolvedName.Namespace, resolvedName.Name + "Fetcher");
        }