protected override void ExecuteCmdlet() { base.ExecuteCmdlet(); BigIntAttributeMetadata attribute = new BigIntAttributeMetadata(); WriteAttribute(attribute); }
public EntityAttributeMetadataBuilder BigIntAttribute(string schemaName, string displayName, string description, AttributeRequiredLevel requiredLevel) { // Define the primary attribute for the entity var newAtt = new BigIntAttributeMetadata() { SchemaName = schemaName, RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel), DisplayName = new Label(displayName, 1033), Description = new Label(description, 1033) }; this.Attributes.Add(newAtt); return(this); }
private RetrieveAttributeResponse ExecuteInternal(RetrieveAttributeRequest request) { var response = new RetrieveAttributeResponse(); var entityType = CrmServiceUtility.GetEarlyBoundProxyAssembly().GetTypes().FirstOrDefault(t => t.GetCustomAttribute <EntityLogicalNameAttribute>(true)?.LogicalName == request.EntityLogicalName); var propertyTypes = entityType?.GetProperties() .Where(p => p.GetCustomAttribute <AttributeLogicalNameAttribute>()?.LogicalName == request.LogicalName ).Select(p => p.PropertyType.IsGenericType ? p.PropertyType.GenericTypeArguments.First() : p.PropertyType).ToList(); var propertyType = propertyTypes?.Count == 1 ? propertyTypes[0] : propertyTypes?.FirstOrDefault(p => p != typeof(OptionSetValue) && p != typeof(EntityReference)); // Handle OptionSets/EntityReferences that may have multiple properties if (propertyType == null) { throw new Exception($"Unable to find a property for Entity {request.EntityLogicalName} and property {request.LogicalName} in {CrmServiceUtility.GetEarlyBoundProxyAssembly().FullName}"); } AttributeMetadata metadata; if (propertyType.IsEnum || propertyTypes.Any(p => p == typeof(OptionSetValue))) { metadata = CreateOptionSetAttributeMetadata(request, propertyType); } else if (propertyType == typeof(string)) { metadata = new StringAttributeMetadata(request.LogicalName); } else if (propertyTypes.Any(p => p == typeof(EntityReference))) { metadata = new LookupAttributeMetadata { LogicalName = request.LogicalName }; } #if !XRM_2013 else if (propertyType == typeof(Guid)) { metadata = new UniqueIdentifierAttributeMetadata { LogicalName = request.LogicalName }; } #endif else if (propertyType == typeof(bool)) { metadata = new BooleanAttributeMetadata { LogicalName = request.LogicalName }; } else if (propertyType == typeof(Money)) { metadata = new MoneyAttributeMetadata { LogicalName = request.LogicalName }; } else if (propertyType == typeof(int)) { metadata = new IntegerAttributeMetadata { LogicalName = request.LogicalName }; } else if (propertyType == typeof(long)) { metadata = new BigIntAttributeMetadata { LogicalName = request.LogicalName }; } else if (propertyType == typeof(DateTime)) { metadata = new DateTimeAttributeMetadata { LogicalName = request.LogicalName }; } else if (propertyType == typeof(double)) { metadata = new DoubleAttributeMetadata { LogicalName = request.LogicalName }; } else if (propertyType == typeof(decimal)) { metadata = new DecimalAttributeMetadata { LogicalName = request.LogicalName }; } else { throw new NotImplementedException($"Attribute Type of {propertyType.FullName} is not implemented."); } response.Results["AttributeMetadata"] = metadata; return(response); }
// ReSharper disable once UnusedParameter.Local private AttributeMetadata CloneAttributes(BigIntAttributeMetadata att) { return(new BigIntAttributeMetadata()); }
public BigIntAttributeMetadataInfo(BigIntAttributeMetadata amd) : base(amd) { this.amd = amd; }
// ReSharper disable once UnusedParameter.Local private AttributeMetadata CloneAttributes(BigIntAttributeMetadata att) { return new BigIntAttributeMetadata(); }