public ICrmAttribute Create(string attributeName, object adaptee) { ICrmAttribute attribute = base.Create(adaptee); attribute.Name = attributeName; return(attribute); }
public ICrmAttribute Create(string name, CrmAttributeType type, string value, params string[] data) { object minValue; switch (type) { case CrmAttributeType.Boolean: minValue = false; break; case CrmAttributeType.Customer: case CrmAttributeType.Lookup: case CrmAttributeType.Owner: { EntityReference reference = new EntityReference { Name = name }; minValue = reference; break; } case CrmAttributeType.DateTime: minValue = DateTime.MinValue; break; case CrmAttributeType.Decimal: minValue = 0M; break; case CrmAttributeType.Double: minValue = 0.0; break; case CrmAttributeType.Integer: minValue = 0; break; case CrmAttributeType.Money: minValue = new Money(); break; case CrmAttributeType.Picklist: case CrmAttributeType.State: case CrmAttributeType.Status: minValue = new OptionSetValue(); break; case CrmAttributeType.UniqueIdentifier: minValue = Guid.Empty; break; case CrmAttributeType.BigInt: minValue = 0L; break; default: minValue = value; break; } this.Add(new KeyValuePair <string, object>(name, minValue)); ICrmAttribute attribute = this.crmAttributeAdapterFactory.Create(name, minValue); attribute.SetValue(value, data); return(attribute); }