public ObjectTypeDiscriminator(ObjectTypeProperty property, string serializedName, ObjectTypeDiscriminatorImplementation[] implementations, string?value)
 {
     Property        = property;
     Implementations = implementations;
     Value           = value;
     SerializedName  = serializedName;
 }
Ejemplo n.º 2
0
        private ReferenceOrConstant?GetPropertyDefaultValue(ObjectTypeProperty property)
        {
            if (property == Discriminator?.Property)
            {
                if (Discriminator.Value != null)
                {
                    return(BuilderHelpers.StringConstant(Discriminator.Value));
                }
            }
            else
            {
                var initializeWithType = property.InitializeWithType;
                return(initializeWithType != null?Constant.NewInstanceOf(initializeWithType) : (ReferenceOrConstant?)null);
            }

            return(null);
        }
Ejemplo n.º 3
0
        public Parameter?FindParameterByInitializedProperty(ObjectTypeProperty property)
        {
            foreach (var propertyInitializer in Initializers)
            {
                if (propertyInitializer.Property == property)
                {
                    if (propertyInitializer.Value.IsConstant)
                    {
                        continue;
                    }

                    var parameterName = propertyInitializer.Value.Reference.Name;
                    return(Parameters.Single(p => p.Name == parameterName));
                }
            }

            return(BaseConstructor?.FindParameterByInitializedProperty(property));
        }
 public ObjectPropertyInitializer(ObjectTypeProperty property, ReferenceOrConstant value, ReferenceOrConstant?defaultValue = null)
 {
     Property     = property;
     Value        = value;
     DefaultValue = defaultValue;
 }