private void MapStructuralType(StructuralTypeConfiguration structuralType) { IEnumerable <PropertyInfo> properties = ConventionsHelpers.GetProperties(structuralType, includeReadOnly: _isQueryCompositionMode); foreach (PropertyInfo property in properties) { bool isCollection; IEdmTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Enum) { MapStructuralProperty(structuralType, property, propertyKind, isCollection); } else if (propertyKind == PropertyKind.Dynamic) { structuralType.AddDynamicPropertyDictionary(property); } else if (propertyKind == PropertyKind.InstanceAnnotations) { structuralType.AddInstanceAnnotationContainer(property); } else { // don't add this property if the user has already added it. if (structuralType.NavigationProperties.All(p => p.Name != property.Name)) { NavigationPropertyConfiguration addedNavigationProperty; if (!isCollection) { addedNavigationProperty = structuralType.AddNavigationProperty(property, EdmMultiplicity.ZeroOrOne); } else { addedNavigationProperty = structuralType.AddNavigationProperty(property, EdmMultiplicity.Many); } ContainedAttribute containedAttribute = property.GetCustomAttribute <ContainedAttribute>(); if (containedAttribute != null) { addedNavigationProperty.Contained(); } addedNavigationProperty.AddedExplicitly = false; } } } MapDerivedTypes(structuralType); }
public MethodDefinition( Expression key, bool computed, FunctionExpression value, PropertyKind kind, bool isStatic) : base(Nodes.MethodDefinition) { Static = isStatic; Key = key; Computed = computed; Value = value; Kind = kind; }
private static IPropertyAccessorStrategy GetStrategy(PropertyKind kind) { switch (kind) { case PropertyKind.PropertyValue: return(ValuePropertyAccessorStrategy.Instance); case PropertyKind.RelatedObject: return(RelatedObjectPropertyAccessorStrategy.Instance); default: Assertion.IsTrue(kind == PropertyKind.RelatedObjectCollection); return(RelatedObjectCollectionPropertyAccessorStrategy.Instance); } }
private void MapComplexType(ComplexTypeConfiguration complexType) { IEnumerable <PropertyInfo> properties = ConventionsHelpers.GetAllProperties(complexType, includeReadOnly: _isQueryCompositionMode); foreach (PropertyInfo property in properties) { bool isCollection; IEdmTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Enum) { MapStructuralProperty(complexType, property, propertyKind, isCollection); } else if (propertyKind == PropertyKind.Dynamic) { complexType.AddDynamicPropertyDictionary(property); } else { // navigation property in a complex type ? if (mappedType == null) { // the user told nothing about this type and this is the first time we are seeing this type. // complex types cannot contain entities. So, treat it as complex property. MapStructuralProperty(complexType, property, PropertyKind.Complex, isCollection); } else if (_explicitlyAddedTypes.Contains(mappedType)) { // user told us that this is an entity type. throw Error.InvalidOperation(SRResources.ComplexTypeRefersToEntityType, complexType.ClrType.FullName, mappedType.ClrType.FullName, property.Name); } else { // we tried to be over-smart earlier and made the bad choice. so patch up now. EntityTypeConfiguration mappedTypeAsEntity = mappedType as EntityTypeConfiguration; Contract.Assert(mappedTypeAsEntity != null); ReconfigureEntityTypesAsComplexType(new EntityTypeConfiguration[] { mappedTypeAsEntity }); MapStructuralProperty(complexType, property, PropertyKind.Complex, isCollection); } } } MapDerivedTypes(complexType); }
/// <summary> /// Creates a new Property. /// </summary> /// <param name="name">Unique name for the new Property.</param> /// <param name="value">Object guiding the type of the property.</param> /// <param name="kind">Property kind.</param> /// <returns>a Property.</returns> internal PropertyType NewProperty(string name, object value, PropertyKind kind) { PropertyType aType; if (stringToPropertyType.TryGetValue(name, out aType) == false) { int pos = graph.propertyType.Length; graph.Update(); Array.Resize(ref graph.propertyType, pos + 1); switch (Type.GetTypeCode(value.GetType())) { case TypeCode.Boolean: aType = new PropertyTypeT <bool>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.Int32: aType = new PropertyTypeT <int>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.Int64: aType = new PropertyTypeT <long>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.Single: aType = new PropertyTypeT <Single>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.Double: aType = new PropertyTypeT <double>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.DateTime: aType = new PropertyTypeT <DateTime>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.String: aType = new PropertyTypeT <string>(false, this.TypeId, pos, name, kind, graph); break; case TypeCode.Object: aType = new PropertyTypeT <IComparable>(false, this.TypeId, pos, name, kind, graph); break; } graph.propertyType[pos] = aType; stringToPropertyType.AddFast(name, aType); } return(aType); }
public Property( PropertyKind kind, Expression key, bool computed, Expression value, bool method, bool shorthand) : base(Nodes.Property) { Key = key; Computed = computed; Value = value; Kind = kind; Method = method; Shorthand = shorthand; }
private void MapEntityType(EntityTypeConfiguration entity) { IEnumerable <PropertyInfo> properties = ConventionsHelpers.GetProperties(entity, includeReadOnly: _isQueryCompositionMode); foreach (PropertyInfo property in properties) { bool isCollection; IEdmTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Enum) { MapStructuralProperty(entity, property, propertyKind, isCollection); } else if (propertyKind == PropertyKind.Dynamic) { // Skip the dynamic property for entity type because open entity type is not supported. } else { // don't add this property if the user has already added it. if (!entity.NavigationProperties.Any(p => p.Name == property.Name)) { NavigationPropertyConfiguration addedNavigationProperty; if (!isCollection) { addedNavigationProperty = entity.AddNavigationProperty(property, EdmMultiplicity.ZeroOrOne); } else { addedNavigationProperty = entity.AddNavigationProperty(property, EdmMultiplicity.Many); } ContainedAttribute containedAttribute = property.GetCustomAttribute <ContainedAttribute>(); if (containedAttribute != null) { addedNavigationProperty.Contained(); } addedNavigationProperty.AddedExplicitly = false; } } } MapDerivedTypes(entity); }
private void MapComplexType(IComplexTypeConfiguration complexType) { PropertyInfo[] properties = ConventionsHelpers.GetProperties(complexType); foreach (PropertyInfo property in properties) { bool isCollection; IStructuralTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex) { MapStructuralProperty(complexType, property, propertyKind, isCollection); } else { // navigation property in a complex type ? if (!isCollection) { if (mappedType == null) { // the user told nothing about this type and this is the first time we are seeing this type. // complex types cannot contain entities. So, treat it as complex property. complexType.AddComplexProperty(property); } else { if (_explicitlyAddedTypes.Contains(mappedType)) { // user told us that this an entity type. throw Error.InvalidOperation(SRResources.ComplexTypeRefersToEntityType, complexType.ClrType.FullName, mappedType.ClrType.FullName, property.Name); } else { // we tried to be over-smart earlier and made the bad choice. so patch up now. ReconfigureEntityTypesAsComplexType(new IEntityTypeConfiguration[] { mappedType as IEntityTypeConfiguration }); complexType.AddComplexProperty(property); } } } else { throw Error.NotSupported(SRResources.CollectionPropertiesNotSupported, property.Name, property.ReflectedType.FullName); } } } }
/// <summary> /// Creates a new Property. /// </summary> /// <param name="name">Unique name for the new Property.</param> /// <param name="value">Object guiding the type of the property.</param> /// <param name="kind">Property kind.</param> /// <returns>a Property.</returns> internal PropertyType NewProperty(string name, object value, PropertyKind kind) { PropertyType aType; if (m_stringToPropertyType.TryGetValue(name, out aType) == false) { int pos = MyGraph.PropertyTypes.Count; switch (Type.GetTypeCode(value.GetType())) { case TypeCode.Boolean: aType = new PropertyTypeT <bool>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.Int32: aType = new PropertyTypeT <int>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.Int64: aType = new PropertyTypeT <long>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.Single: aType = new PropertyTypeT <Single>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.Double: aType = new PropertyTypeT <double>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.DateTime: aType = new PropertyTypeT <DateTime>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.String: aType = new PropertyTypeNoDuplicateValues <string>(false, this.TypeId, pos, name, kind, MyGraph); break; case TypeCode.Object: aType = new PropertyTypeT <IComparable>(false, this.TypeId, pos, name, kind, MyGraph); break; } MyGraph.PropertyTypes[pos] = aType; m_stringToPropertyType.AddFast(name, aType); } return(aType); }
/// <summary> /// Gets the method kind of a property's accessor method. /// </summary> /// <param name="kind">Kind of the property.</param> /// <returns>Kind of the property's accessor methods.</returns> public static MethodKind ToMethodKind(this PropertyKind kind) { switch (kind) { case PropertyKind.Static: return(MethodKind.Static); case PropertyKind.Normal: return(MethodKind.Normal); case PropertyKind.Virtual: return(MethodKind.Virtual); case PropertyKind.Abstract: return(MethodKind.Abstract); case PropertyKind.Override: return(MethodKind.Override); default: throw new NotImplementedException(); } }
public PropertyAccessorData(ClassDefinition classDefinition, string propertyIdentifier) { ArgumentUtility.CheckNotNull("classDefinition", classDefinition); ArgumentUtility.CheckNotNullOrEmpty("propertyIdentifier", propertyIdentifier); _propertyIdentifier = propertyIdentifier; _classDefinition = classDefinition; Tuple <PropertyDefinition, IRelationEndPointDefinition> propertyObjects = GetPropertyDefinitionObjects(_classDefinition, propertyIdentifier); _propertyDefinition = propertyObjects.Item1; _relationEndPointDefinition = propertyObjects.Item2; _kind = GetPropertyKind(_relationEndPointDefinition); _strategy = GetStrategy(_kind); _propertyType = _strategy.GetPropertyType(_propertyDefinition, _relationEndPointDefinition); }
public Property(PropertyKind kind, IPropertyKeyExpression key, Expression value, Location location = null) : base(SyntaxNodeType.Property, location) { if (!FastEnumValidator <PropertyKind> .IsDefined((int)kind)) { throw new ArgumentOutOfRangeException("kind"); } if (key == null) { throw new ArgumentNullException("key"); } if (value == null) { throw new ArgumentNullException("value"); } Value = value; Key = key; Kind = kind; }
public CustomPropertyEmitter(CustomClassEmitter declaringType, string name, PropertyKind propertyKind, Type propertyType, Type[] indexParameters, PropertyAttributes attributes) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("propertyType", propertyType); ArgumentUtility.CheckNotNull("indexParameters", indexParameters); _declaringType = declaringType; _name = name; _propertyKind = propertyKind; _propertyType = propertyType; _indexParameters = indexParameters; CallingConventions callingConvention = propertyKind == PropertyKind.Instance ? CallingConventions.HasThis : CallingConventions.Standard; _propertyBuilder = _declaringType.TypeBuilder.DefineProperty( name, attributes, callingConvention, propertyType, null, null, indexParameters, null, null); }
/// <summary> /// Intializes a new instance of the <see cref="GeneratedProperty"/> class. /// </summary> /// <param name="engine">The code generation engine.</param> /// <param name="kind">Kind of property to generate.</param> /// <param name="type">Type of the property.</param> /// <param name="name">Name of the property (may be null).</param> /// <param name="implementation">Implementation strategy to use (may be null).</param> internal GeneratedProperty( CodeGenEngine engine, PropertyKind kind, Type type, string name, IPropertyImplementation implementation) : base(engine) { // check parameters if (type == null) { throw new ArgumentNullException("type"); } // ensure that the specified type is public and all nested types are public, too // => otherwise the dynamically created assembly is not able to access it CodeGenHelpers.CheckTypeIsTotallyPublic(type); mName = name; mKind = kind; mType = type; if (mName == null || mName.Trim().Length == 0) { mName = "X" + Guid.NewGuid().ToString("N"); } // declare the 'get' accessor method mGetAccessorMethod = engine.AddMethod(kind.ToMethodKind(), "get_" + name, type, Type.EmptyTypes, Visibility.Public); mGetAccessorMethod.AdditionalMethodAttributes = MethodAttributes.SpecialName | MethodAttributes.HideBySig; // declare the 'set' accessor method mSetAccessorMethod = engine.AddMethod(kind.ToMethodKind(), "set_" + name, typeof(void), new Type[] { type }, Visibility.Public); mSetAccessorMethod.AdditionalMethodAttributes = MethodAttributes.SpecialName | MethodAttributes.HideBySig; mImplementation = implementation; if (mImplementation != null) { mImplementation.Declare(engine, this); } }
public NotifyingObjectProperty(PropertyInfo property, object obj) { _type = property.PropertyType.GetGenericArguments()[0]; _notifyingObject = property.GetValue(obj, null); _getter = _notifyingObject.GetType().GetMethod(GetValueMethodName); _setter = _notifyingObject.GetType().GetMethod(SetValueMethodName); var displayNameAttribute = property.GetCustomAttributes(typeof(DisplayNameAttribute), false) .Cast <DisplayNameAttribute>() .SingleOrDefault(); _displayName = displayNameAttribute != null ? displayNameAttribute.DisplayName : property.Name; var descriptionAttribute = property.GetCustomAttributes(typeof(DescriptionAttribute), false) .Cast <DescriptionAttribute>() .SingleOrDefault(); _description = descriptionAttribute != null ? descriptionAttribute.Description : string.Empty; var categoryAttribute = property.GetCustomAttributes(typeof(CategoryAttribute), false) .Cast <CategoryAttribute>() .SingleOrDefault(); _category = categoryAttribute != null ? categoryAttribute.Category : DefaultCategory; _propertyName = property.Name; var propertyKindAttribut = property.GetCustomAttributes(typeof(PropertyKindAttribute), false) .Cast <PropertyKindAttribute>() .SingleOrDefault(); _propertyKind = propertyKindAttribut != null ? propertyKindAttribut.PropertyKind : PropertyKind.Undefined; }
private static void CheckCaptionsTooltips( Action <Diagnostic> reportDiagnostic, PropertyValueSyntax propValue, PropertyKind propKind, string name) { if (propValue == null) { return; } switch (propValue.Kind) { case SyntaxKind.MultilanguagePropertyValue: EmailAndPhoneNoMustNotBePresentInTheSource.CheckPropertyML(reportDiagnostic, propValue, name, propKind.ToString()); break; case SyntaxKind.LabelPropertyValue: EmailAndPhoneNoMustNotBePresentInTheSource.CheckProperty(reportDiagnostic, propValue, name, propKind.ToString()); break; } }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="SchemaProperty" /> class. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="propertyName"> /// Name of the property. /// </param> /// <param name="propertyMetaclass"> /// The property metaclass. /// </param> /// <param name="kind"> /// (Optional) the kind. /// </param> /// <param name="defaultValue"> /// (Optional) /// </param> /// <param name="implementedType"> /// (Optional) Type of the implemented. /// </param> ///------------------------------------------------------------------------------------------------- public SchemaProperty(ISchemaInfo owner, string propertyName, ISchemaValueObject propertyMetaclass, PropertyKind kind = PropertyKind.Normal, object defaultValue = null, Type implementedType = null) { Contract.Requires(owner, "owner"); Contract.RequiresNotEmpty(propertyName, "propertyName"); _owner = owner; //if (InvalidPropertyNames.Any(p => String.Compare(p, propertyName, StringComparison.OrdinalIgnoreCase) == 0)) // throw new Exception(ExceptionMessages.InvalidPropertyNameCantBeAPropertyOfIModelElement); ConstructInternal(owner.Schema, implementedType ?? typeof(SchemaProperty), owner.Id.CreateMetaPropertyIdentity(propertyName), propertyName, null, owner.Schema.Store.PrimitivesSchema.SchemaPropertySchema, (dm, melId, m) => new AddSchemaPropertyCommand(dm as ISchema, melId, (ISchemaEntity)m)); // Attention ici toutes les propriétés doivent avoir été déclarées sous peine de rentrer dans une bouble infini // au niveau GetOrCreateProperty de ModelElement PropertySchema = propertyMetaclass; if (defaultValue != null) { DefaultValue = defaultValue; } Kind = kind; }
internal void AddPropertyInternal(EntityTypeConfiguration entity, PropertyInfo property) { bool isCollection; IEdmTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Enum) { MapStructuralProperty(entity, property, propertyKind, isCollection); } else if (propertyKind == PropertyKind.Dynamic) { entity.AddDynamicPropertyDictionary(property); } else { // don't add this property if the user has already added it. if (entity.NavigationProperties.All(p => p.Name != property.Name)) { NavigationPropertyConfiguration addedNavigationProperty; if (!isCollection) { addedNavigationProperty = entity.AddNavigationProperty(property, EdmMultiplicity.ZeroOrOne); } else { addedNavigationProperty = entity.AddNavigationProperty(property, EdmMultiplicity.Many); } ContainedAttribute containedAttribute = property.GetCustomAttribute <ContainedAttribute>(); if (containedAttribute != null) { addedNavigationProperty.Contained(); } addedNavigationProperty.AddedExplicitly = false; } } }
private ClassKind ToClassKind(PropertyKind kind) { switch (kind) { case PropertyKind.Immutable: return(ClassKind.Immutable); case PropertyKind.Builder: return(ClassKind.Builder); case PropertyKind.Descriptor: return(ClassKind.Descriptor); case PropertyKind.ImmutableInstance: return(ClassKind.ImmutableInstance); case PropertyKind.BuilderInstance: return(ClassKind.BuilderInstance); default: return(ClassKind.None); } }
private void MapEntityType(EntityTypeConfiguration entity) { IEnumerable <PropertyInfo> properties = ConventionsHelpers.GetProperties(entity, includeReadOnly: _isQueryCompositionMode); foreach (PropertyInfo property in properties) { bool isCollection; StructuralTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex) { MapStructuralProperty(entity, property, propertyKind, isCollection); } else { // don't add this property if the user has already added it. if (!entity.NavigationProperties.Where(p => p.Name == property.Name).Any()) { NavigationPropertyConfiguration addedNavigationProperty; if (!isCollection) { addedNavigationProperty = entity.AddNavigationProperty(property, EdmMultiplicity.ZeroOrOne); } else { addedNavigationProperty = entity.AddNavigationProperty(property, EdmMultiplicity.Many); } addedNavigationProperty.AddedExplicitly = false; } } } MapDerivedTypes(entity); }
void SetArgumentDirection(PropertyKind direction) { using (ModelEditingScope scope = this.ReflectedObject.BeginEdit((string)this.Editor.FindResource("changeArgumentDirectionDescription"))) { Type currentType = this.GetArgumentType(); Type propertyType = GetTypeReference(direction, currentType); this.ReflectedObject.Properties["Type"].SetValue(propertyType); this.TryUpdateArgumentType(currentType, direction); if (direction == PropertyKind.Property) { this.SetIsRequired(false); } scope.Complete(); } }
Type GetTypeReference(PropertyKind direction, Type type) { Type targetType = null; switch (direction) { case PropertyKind.InArgument: targetType = typeof(InArgument<>).MakeGenericType(type); break; case PropertyKind.OutArgument: targetType = typeof(OutArgument<>).MakeGenericType(type); break; case PropertyKind.InOutArgument: targetType = typeof(InOutArgument<>).MakeGenericType(type); break; case PropertyKind.Property: targetType = type; break; default: throw FxTrace.Exception.AsError(new NotSupportedException(direction.ToString())); } return targetType; }
public PropertyDefinitionCollection(PropertyKind defaultPropertyKind) { this.defaultPropertyKind = defaultPropertyKind; }
internal PropertyTypeNoDuplicateValues(bool isVertexProp, TypeId typeId, PropertyId propertyId, string name, PropertyKind kind, Graph graph) : base(isVertexProp, typeId, propertyId, name, kind, graph) { m_valueToId = new BTreeMap <T, UInt64>(null, graph.Session); m_IdToValue = new BTreeMap <UInt64, T>(null, graph.Session); m_nextId = 0; }
public PropertyDefinition(FieldInfo fieldInfo) { this.propertyKind = PropertyKind.Foaoip; this.propertyName = IOCCommon.FieldNameToPropertyName(fieldInfo.Name); this.fieldInfo = fieldInfo; }
public bool ContainsProperty(PropertyKind propertyKind, string propertyName) { throw new NotImplementedException(); }
ISchemaProperty ISchemaElement.DefineProperty(string name, ISchemaValueObject property, object defaultValue, PropertyKind kind) { return(DefineProperty(name, property, kind, defaultValue)); }
public MethodDefinition(PropertyKey key, bool computed, FunctionExpression value, PropertyKind kind, bool isStatic) { Type = Nodes.MethodDefinition; Static = isStatic; Key = key; Computed = computed; Value = value; Kind = kind; }
internal bool InferEdmTypeFromDerivedTypes(Type propertyType, ref PropertyKind propertyKind) { HashSet <Type> visitedTypes = new HashSet <Type>(); Queue <Type> typeToBeVisited = new Queue <Type>(); typeToBeVisited.Enqueue(propertyType); IList <StructuralTypeConfiguration> foundMappedTypes = new List <StructuralTypeConfiguration>(); while (typeToBeVisited.Count != 0) { Type currentType = typeToBeVisited.Dequeue(); visitedTypes.Add(currentType); List <Type> derivedTypes; if (_allTypesWithDerivedTypeMapping.Value.TryGetValue(currentType, out derivedTypes)) { foreach (Type derivedType in derivedTypes) { if (!visitedTypes.Contains(derivedType)) { StructuralTypeConfiguration structuralType = _explicitlyAddedTypes.FirstOrDefault(c => c.ClrType == derivedType); if (structuralType != null) { foundMappedTypes.Add(structuralType); } typeToBeVisited.Enqueue(derivedType); } } } } if (!foundMappedTypes.Any()) { return(false); } IEnumerable <EntityTypeConfiguration> foundMappedEntityType = foundMappedTypes.OfType <EntityTypeConfiguration>().ToList(); IEnumerable <ComplexTypeConfiguration> foundMappedComplexType = foundMappedTypes.OfType <ComplexTypeConfiguration>().ToList(); if (!foundMappedEntityType.Any()) { propertyKind = PropertyKind.Complex; return(true); } else if (!foundMappedComplexType.Any()) { propertyKind = PropertyKind.Navigation; return(true); } else { throw Error.InvalidOperation(SRResources.CannotInferEdmType, propertyType.FullName, String.Join(",", foundMappedEntityType.Select(e => e.ClrType.FullName)), String.Join(",", foundMappedComplexType.Select(e => e.ClrType.FullName))); } }
public PropertyKindAttribute(PropertyKind propertyKind) { _propertyKind = propertyKind; }
private void MapStructuralProperty(StructuralTypeConfiguration type, PropertyInfo property, PropertyKind propertyKind, bool isCollection) { Contract.Assert(type != null); Contract.Assert(property != null); Contract.Assert(propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Enum); bool addedExplicitly = type.Properties.Any(p => p.PropertyInfo.Name == property.Name); PropertyConfiguration addedEdmProperty; if (!isCollection) { if (propertyKind == PropertyKind.Primitive) { addedEdmProperty = type.AddProperty(property); } else if (propertyKind == PropertyKind.Enum) { AddEnumType(TypeHelper.GetUnderlyingTypeOrSelf(property.PropertyType)); addedEdmProperty = type.AddEnumProperty(property); } else { addedEdmProperty = type.AddComplexProperty(property); } } else { if (_isQueryCompositionMode) { Contract.Assert(propertyKind != PropertyKind.Complex, "we don't create complex types in query composition mode."); } if (TypeHelper.IsGenericType(property.PropertyType)) { Type elementType = property.PropertyType.GetGenericArguments().First(); Type elementUnderlyingTypeOrSelf = TypeHelper.GetUnderlyingTypeOrSelf(elementType); if (TypeHelper.IsEnum(elementUnderlyingTypeOrSelf)) { AddEnumType(elementUnderlyingTypeOrSelf); } } else { Type elementType; if (TypeHelper.IsCollection(property.PropertyType, out elementType)) { Type elementUnderlyingTypeOrSelf = TypeHelper.GetUnderlyingTypeOrSelf(elementType); if (TypeHelper.IsEnum(elementUnderlyingTypeOrSelf)) { AddEnumType(elementUnderlyingTypeOrSelf); } } } addedEdmProperty = type.AddCollectionProperty(property); } addedEdmProperty.AddedExplicitly = addedExplicitly; }
/// <summary> /// Creates a new Property. /// </summary> /// <param name="name">Unique name for the new Property.</param> /// <param name="dt">Data type for the new Property.</param> /// <param name="kind">Property kind.</param> /// <returns>Unique Property identifier.</returns> public PropertyType NewProperty(string name, DataType dt, PropertyKind kind) { PropertyType aType; if (stringToPropertyType.TryGetValue(name, out aType) == false) { graph.Update(); int pos = -1; int i = 0; foreach (PropertyType pt in graph.propertyType) if (pt == null) { pos = i; break; } else ++i; if (pos < 0) { pos = graph.propertyType.Length; Array.Resize(ref graph.propertyType, pos + 1); } aType = graph.PropertyTypeFromDataType(true, dt, typeId, pos, name, kind); graph.propertyType[pos] = aType; stringToPropertyType.AddFast(name, aType); } return aType; }
/// <summary> /// Creates a new Property. /// </summary> /// <param name="name">Unique name for the new Property.</param> /// <param name="dt">Data type for the new Property.</param> /// <param name="kind">Property kind.</param> /// <returns>Unique Property identifier.</returns> public PropertyType NewProperty(string name, DataType dt, PropertyKind kind) { PropertyType aType; if (m_stringToPropertyType.TryGetValue(name, out aType) == false) { var propertyTypes = MyGraph.PropertyTypes; int pos = -1; int i = 0; foreach (PropertyType pt in propertyTypes) if (pt == null) { pos = i; break; } else ++i; if (pos < 0) pos = propertyTypes.Count; aType = MyGraph.PropertyTypeFromDataType(true, dt, m_typeId, pos, name, kind); Session.Persist(aType); propertyTypes[pos] = aType; m_stringToPropertyType.AddFast(name, aType); } return aType; }
void TryUpdateArgumentType(Type newType, PropertyKind newDirection) { if (newDirection == PropertyKind.Property) { string currentExpressionText = this.GetArgumentValueExpressionText(); if (null != currentExpressionText) { TypeConverter converter = TypeDescriptor.GetConverter(newType); if (converter.CanConvertFrom(typeof(string))) { try { object value = converter.ConvertFrom(currentExpressionText); this.ReflectedObject.Properties[ArgumentDefaultValueProperty].SetValue(value); } catch (Exception err) { System.Diagnostics.Debug.WriteLine(err.ToString()); this.ReflectedObject.Properties[ArgumentDefaultValueProperty].ClearValue(); } } else { this.ReflectedObject.Properties[ArgumentDefaultValueProperty].ClearValue(); } } else { this.ReflectedObject.Properties[ArgumentDefaultValueProperty].ClearValue(); } } else if (newDirection == PropertyKind.InArgument) { Argument currentArgument = this.ReflectedObject.Properties[ArgumentDefaultValueProperty].ComputedValue as Argument; ActivityWithResult newExpression = null; bool succeeded = false; if (currentArgument != null) { succeeded = ExpressionHelper.TryMorphExpression(currentArgument.Expression, false, newType, this.Context, out newExpression); } else { ////If the old direction is property, we'll try to convert the default value object to the expression object specified by global editor setting string currentExpressionText = this.GetArgumentValueExpressionText(); if (!string.IsNullOrEmpty(currentExpressionText)) { string rootEditorSetting = ExpressionHelper.GetRootEditorSetting(this.ModelTreeManager, WorkflowDesigner.GetTargetFramework(this.Context)); if (!string.IsNullOrEmpty(rootEditorSetting)) { succeeded = ExpressionTextBox.TryConvertFromString(rootEditorSetting, currentExpressionText, false, newType, out newExpression); } } } if (succeeded) { Argument newArgument = Argument.Create(newType, ArgumentDirection.In); newArgument.Expression = newExpression; this.ReflectedObject.Properties[ArgumentDefaultValueProperty].SetValue(newArgument); } else { //currently if the value cannot be morphed, it's cleared. this.ReflectedObject.Properties[ArgumentDefaultValueProperty].ClearValue(); } } else { this.ReflectedObject.Properties[ArgumentDefaultValueProperty].ClearValue(); } }
ISchemaProperty ISchemaElement.DefineProperty <T>(string name, object defaultValue, PropertyKind kind) { return(DefineProperty <T>(name, defaultValue, kind)); }
public PropertyDefinition(PropertyInfo propertyInfo) { this.propertyKind = PropertyKind.Poaoip; this.propertyName = IOCCommon.FieldNameToPropertyName(propertyInfo.Name); this.propertyInfo = propertyInfo; }
internal PropertyTypeT(bool isVertexProp, TypeId typeId, PropertyId propertyId, string name, PropertyKind kind, Graph graph) : base(isVertexProp, typeId, propertyId, name, graph) { m_propertyValue = new BTreeMap <ElementId, T>(null, graph.Session); switch (kind) { case PropertyKind.Indexed: m_valueIndex = new BTreeMap <T, BTreeSet <ElementId> >(null, graph.Session); break; case PropertyKind.Unique: m_valueIndexUnique = new BTreeMap <T, ElementId>(null, graph.Session); break; } }
private bool TryGetPropertyTypeKind(Type propertyType, out IEdmTypeConfiguration mappedType, out PropertyKind propertyKind) { Contract.Assert(propertyType != null); if (EdmLibHelpers.GetEdmPrimitiveTypeOrNull(propertyType) != null) { mappedType = null; propertyKind = PropertyKind.Primitive; return(true); } mappedType = GetStructuralTypeOrNull(propertyType); if (mappedType != null) { if (mappedType is ComplexTypeConfiguration) { propertyKind = PropertyKind.Complex; } else if (mappedType is EnumTypeConfiguration) { propertyKind = PropertyKind.Enum; } else { propertyKind = PropertyKind.Navigation; } return(true); } if (TypeHelper.IsEnum(propertyType)) { propertyKind = PropertyKind.Enum; return(true); } propertyKind = PropertyKind.Navigation; return(false); }
internal ExposedProperty(Type hostType, PropertyInfo propInfo) { if (hostScriptObjectName == null) { hostScriptObjectName = SpinnakerConfiguration.CurrentConfig.HostScriptObjectName; hostScriptFunctionSuffix = SpinnakerConfiguration.CurrentConfig.HostScriptFunctionSuffix; } this.propInfo = propInfo; setterScriptFunctionName = "set" + hostType.Name + "_" + propInfo.Name; setValidationErrorScriptFunctionName = "set" + hostType.Name + "ValidationError_" + propInfo.Name; clearValidationErrorScriptFunctionName = "clear" + hostType.Name + "ValidationError_" + propInfo.Name; if (ViewModelDefinition.IsTypeEnumerable(propInfo.PropertyType)) kind = PropertyKind.Enumerable; else if (intScriptTypes.Contains(propInfo.PropertyType)) kind = PropertyKind.IntScriptType; else if (floatScriptTypes.Contains(propInfo.PropertyType)) kind = PropertyKind.FloatScriptType; else if (propInfo.PropertyType == typeof(bool)) kind = PropertyKind.BoolScriptType; else if (propInfo.PropertyType.IsEnum) kind = PropertyKind.Enum; else if (typeof(INotifyPropertyChanged).IsAssignableFrom(propInfo.PropertyType)) kind = PropertyKind.ViewModel; else kind = PropertyKind.StringableType; }
private bool TryGetPropertyTypeKind(Type propertyType, out IEdmTypeConfiguration mappedType, out PropertyKind propertyKind) { Contract.Assert(propertyType != null); if (EdmLibHelpers.GetEdmPrimitiveTypeOrNull(propertyType) != null) { mappedType = null; propertyKind = PropertyKind.Primitive; return(true); } mappedType = GetStructuralTypeOrNull(propertyType); if (mappedType != null) { if (mappedType is ComplexTypeConfiguration) { propertyKind = PropertyKind.Complex; } else if (mappedType is EnumTypeConfiguration) { propertyKind = PropertyKind.Enum; } else { propertyKind = PropertyKind.Navigation; } return(true); } // If one of the base types is configured as complex type, the type of this property // should be configured as complex type too. Type baseType = TypeHelper.GetBaseType(propertyType); while (baseType != null && baseType != typeof(object)) { IEdmTypeConfiguration baseMappedType = GetStructuralTypeOrNull(baseType); if (baseMappedType != null) { if (baseMappedType is ComplexTypeConfiguration) { propertyKind = PropertyKind.Complex; return(true); } } baseType = TypeHelper.GetBaseType(baseType); } // refer the Edm type from the derived types PropertyKind referedPropertyKind = PropertyKind.Navigation; if (InferEdmTypeFromDerivedTypes(propertyType, ref referedPropertyKind)) { if (referedPropertyKind == PropertyKind.Complex) { ReconfigInferedEntityTypeAsComplexType(propertyType); } propertyKind = referedPropertyKind; return(true); } if (TypeHelper.IsEnum(propertyType)) { propertyKind = PropertyKind.Enum; return(true); } propertyKind = PropertyKind.Navigation; return(false); }
private void MapStructuralProperty(IStructuralTypeConfiguration type, PropertyInfo property, PropertyKind propertyKind, bool isCollection) { Contract.Assert(type != null); Contract.Assert(property != null); Contract.Assert(propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Collection); if (!isCollection) { if (propertyKind == PropertyKind.Primitive) { type.AddProperty(property); } else { type.AddComplexProperty(property); } } else { if (_isQueryCompositionMode) { Contract.Assert(propertyKind != PropertyKind.Complex, "we don't create complex types in query composition mode."); } type.AddCollectionProperty(property); } }
public PropertyDefinition(string propertyName, int parameterCount, PropertyKind propertyKind) { this.propertyName = propertyName; this.parameterCount = parameterCount; this.propertyKind = propertyKind; }
public SeparatorInfo(PropertyKind propKind, string beginSeparator, string endSeparator) { ThePropertyKind = propKind; BeginSeparator = beginSeparator; EndSepartor = endSeparator; }