Ejemplo n.º 1
0
 public static FetcherNavigationProperty ForConcrete(OdcmProperty odcmProperty)
 {
     return new FetcherNavigationProperty(odcmProperty)
     {
         DefiningInterface = NamesService.GetFetcherInterfaceName(odcmProperty.Class)
     };
 }
Ejemplo n.º 2
0
 public static MockService SetupGetEntityProperty(this MockService mockService, EntityArtifacts targetEntity, IEnumerable<Tuple<string, object>> keyValues, OdcmProperty property)
 {
     return mockService
         .OnGetEntityPropertyRequest(targetEntity.Class.GetDefaultEntityPath(keyValues), property.Name)
         .RespondWithGetEntity(targetEntity.Class.GetDefaultEntitySetName(),
             targetEntity.Class.GetSampleJObject());
 }
Ejemplo n.º 3
0
 protected FetcherNavigationProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     FieldName = NamesService.GetFetcherFieldName(odcmProperty);
     InstanceType = NamesService.GetFetcherTypeName(odcmProperty.Type);
     PrivateSet = true;
     Type = new Type(NamesService.GetFetcherInterfaceName(odcmProperty.Type));
 }
Ejemplo n.º 4
0
 public ObsoletedNavigationProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     Type = odcmProperty.IsCollection
         ? new Type(new Identifier("global::System.Collections.Generic", "IList"),
             new Type(NamesService.GetConcreteTypeName(odcmProperty.Type)))
         : new Type(NamesService.GetConcreteTypeName(odcmProperty.Type));
 }
 public new static ConcreteNavigationProperty ForConcrete(OdcmProperty odcmProperty)
 {
     return new ConcreteNavigationCollectionProperty(odcmProperty)
     {
         DefiningInterface = NamesService.GetConcreteInterfaceName(odcmProperty.Class),
     };
 }
 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)));
 }
 private ConcreteNavigationCollectionAccessorProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     CollectionType = new Type(NamesService.GetCollectionTypeName((OdcmClass)odcmProperty.Type));
     FieldName = NamesService.GetConcreteFieldName(odcmProperty);
     InstanceType = NamesService.GetConcreteTypeName(odcmProperty.Type);
     Type = new Type(new Identifier("global::System.Collections.Generic", "IList"),
         new Type(NamesService.GetConcreteTypeName(odcmProperty.Type)));
 }
Ejemplo n.º 8
0
 public static Parameter FromProperty(OdcmProperty arg)
 {
     return new Parameter
     {
         Name = arg.Name.ToLowerCamelCase(),
         Type = new Type(NamesService.GetConcreteTypeName(arg.Type))
     };
 }
Ejemplo n.º 9
0
 public static Field ForConcreteNavigationCollectionProperty(OdcmProperty property)
 {
     return new Field
     {
         Name = NamesService.GetConcreteFieldName(property),
         Type = new Type(NamesService.GetExtensionTypeName("EntityCollectionImpl"), new Type(NamesService.GetConcreteTypeName((OdcmClass)property.Type)))
     };
 }
Ejemplo n.º 10
0
 public static Field ForFetcherNavigationCollectionProperty(OdcmProperty property)
 {
     return new Field
     {
         Name = NamesService.GetFetcherCollectionFieldName(property),
         Type = new Type(NamesService.GetCollectionTypeName((OdcmClass)property.Type))
     };
 }
Ejemplo n.º 11
0
 public static Field ForNavigationProperty(OdcmProperty property)
 {
     return new Field
     {
         Name = NamesService.GetPropertyFieldName(property),
         Type = new Type(NamesService.GetConcreteTypeName(property.Type))
     };
 }
 protected FetcherNavigationCollectionProperty(OdcmProperty odcmProperty)
     : base(odcmProperty)
 {
     CollectionType = new Type(NamesService.GetCollectionTypeName((OdcmClass)odcmProperty.Type));
     FieldName = NamesService.GetFetcherCollectionFieldName(odcmProperty);
     InstanceType = NamesService.GetConcreteTypeName(odcmProperty.Type);
     Type = new Type(NamesService.GetCollectionInterfaceName((OdcmClass)odcmProperty.Type));
 }
Ejemplo n.º 13
0
 public ObsoletedProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     Type = odcmProperty.IsCollection
         ? new Type(new Identifier("global::System.Collections.Generic", "IList"),
             TypeService.GetPropertyType(odcmProperty))
         : TypeService.GetPropertyType(odcmProperty);
     UpdatedName = Name;
     Name = NamesService.GetModelPropertyName(odcmProperty);
 }
Ejemplo n.º 14
0
 public static Field ForStructuralProperty(OdcmProperty property)
 {
     return new Field
     {
         Name = NamesService.GetPropertyFieldName(property),
         Type = property.IsCollection
             ? new Type(NamesService.GetExtensionTypeName("NonEntityTypeCollectionImpl"), new Type(NamesService.GetConcreteTypeName(property.Type)))
             : TypeService.GetPropertyType(property)
     };
 }
        public Given_an_OdcmClass_Entity_Complex_Structural_Property()
        {
            base.Init(m =>
            {
                _structuralProperty = Any.ComplexOdcmProperty(m.Namespaces[0]);
                _structuralProperty.Class = Class;
                Class.Properties.Add(_structuralProperty);
                m.AddType(_structuralProperty.Type);
            });

            _structuralPropertyType = Proxy.GetClass(_structuralProperty.Type.Namespace, _structuralProperty.Type.Name);
        }
Ejemplo n.º 16
0
        public ContainerAddToCollectionMethod(OdcmProperty odcmProperty)
        {
            Name = "AddTo" + odcmProperty.Name;

            ModelCollectionName = odcmProperty.Name;

            Parameters = new[]
            {
                new Parameter(new Type(NamesService.GetConcreteInterfaceName(odcmProperty.Type)), odcmProperty.Name.ToLowerCamelCase()),
            };

            ReturnType = Type.Void;
        }
        public Given_an_OdcmClass_Service_Property_forced_to_pascal_case()
        {
            SetConfiguration(new CSharpWriterSettings
            {
                ForcePropertyPascalCasing = true
            });

            base.Init(m =>
            {
                _property = Model.EntityContainer.Properties.RandomElement();

                _property = _property.Rename(Any.Char('a', 'z') + _property.Name);
            });
        }
        public Given_an_OdcmClass_Entity_Primitive_Structural_Property()
        {
            base.Init(m =>
            {
                _structuralInstanceProperty = Any.PrimitiveOdcmProperty(p => p.Class = Class);

                _structuralCollectionProperty = Any.PrimitiveOdcmProperty(p =>
                {
                    p.Class = Class;
                    p.IsCollection = true;
                });

                Class.Properties.Add(_structuralInstanceProperty);

                Class.Properties.Add(_structuralCollectionProperty);
            });
        }
        public Given_an_OdcmClass_Entity_Navigation_Property_Instance_forced_to_pascal_case()
        {
            SetConfiguration(new CSharpWriterSettings
            {
                ForcePropertyPascalCasing = true
            });

            Init(m =>
            {
                _camelCasedProperty = Class.NavigationProperties().Where(p => !p.IsCollection).RandomElement();

                _camelCasedName = Any.Char('a', 'z') + _camelCasedProperty.Name;

                _camelCasedProperty = _camelCasedProperty.Rename(_camelCasedName);
            });

            _pascalCasedName = _camelCasedName.ToPascalCase();
        }
        public Given_an_OdcmClass_Complex_Property_forced_to_pascal_case()
        {
            SetConfiguration(new CSharpWriterSettings
            {
                ForcePropertyPascalCasing = true
            });

            base.Init(m =>
            {
                _targetClass = Any.ComplexOdcmClass(Namespace);

                m.AddType(_targetClass);

                _property = _targetClass.Properties.RandomElement();

                _property = _property.Rename(Any.Char('a', 'z') + _property.Name);
            });

            _targetType = Proxy.GetClass(_targetClass.Namespace, _targetClass.Name);
        }
        public Given_an_OdcmClass_Entity_Property_forced_to_pascal_case()
        {
            SetConfiguration(new CSharpWriterSettings
            {
                ForcePropertyPascalCasing = true
            });

            Init(m =>
            {
                var originalProperty = Class.Properties.RandomElement();

                var camelCasedName = Any.Char('a', 'z') + originalProperty.Name;

                _property = originalProperty.Rename(camelCasedName);
            });

            _propertyType = Proxy.GetClass(_property.Type.Namespace, _property.Type.Name);
            if (_property.IsCollection)
                _propertyType = typeof (IList<>).MakeGenericType(_propertyType);
        }
        public Given_a_nullable_Primitive_OdcmProperty()
        {
            _model = new OdcmModel(Any.ServiceMetadata());

            _namespace = Any.EmptyOdcmNamespace();

            _model.Namespaces.Add(_namespace);

            _class = Any.OdcmEntityClass(_namespace);

            _property = Any.PrimitiveOdcmProperty(p =>
            {
                p.IsNullable = true;
                p.Class = _class;
            });

            _class.Properties.Add(_property);

            _model.AddType(_class);
        }
 private static string GetPascalCaseName(OdcmProperty property)
 {
     return property.Name.Substring(0, 1).ToUpper() + property.Name.Substring(1);
 }
Ejemplo n.º 24
0
 protected ContainerNavigationProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     PrivateSet = true;
 }
Ejemplo n.º 25
0
 public static ContainerNavigationProperty ForService(OdcmProperty odcmProperty)
 {
     return new ContainerNavigationProperty(odcmProperty);
 }
 protected ContainerNavigationCollectionProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
 }
Ejemplo n.º 27
0
        public static OdcmProperty ComplexOdcmProperty(OdcmNamespace odcmNamespace, Action<OdcmProperty> config = null)
        {
            var retVal = new OdcmProperty(Any.CSharpIdentifier()) { Type = Any.ComplexOdcmClass(odcmNamespace) };


            if (config != null) config(retVal);

            return retVal;
        }
Ejemplo n.º 28
0
        private static OdcmProperty OdcmEntityProperty(OdcmClass @class, Action<OdcmProperty> config)
        {
            var retVal = new OdcmProperty(Any.CSharpIdentifier()) { Type = @class };

            if (config != null) config(retVal);

            return retVal;
        }
Ejemplo n.º 29
0
        public static OdcmProperty PrimitiveOdcmProperty(Action<OdcmProperty> config = null)
        {
            var retVal = new OdcmProperty(Any.CSharpIdentifier()) { Type = Any.PrimitiveOdcmType() };

            if (config != null) config(retVal);

            return retVal;
        }
Ejemplo n.º 30
0
        public static OdcmProperty OdcmProperty(Action<OdcmProperty> config = null)
        {
            var retVal = new OdcmProperty(Any.CSharpIdentifier());

            if (config != null) config(retVal);

            return retVal;
        }