Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MultiSelectPickList #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions CrmCodeGenerator.VSPackage/CrmCodeGenerator.VSPackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
<Reference Include="envdte90, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="microsoft.crm.sdk.proxy, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Crm.Sdk.Proxy, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\microsoft.crm.sdk.proxy.dll</HintPath>
<HintPath>..\lib\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.Designer.Interfaces, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Expand All @@ -109,9 +109,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\microsoft.xrm.client.dll</HintPath>
</Reference>
<Reference Include="microsoft.xrm.sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\microsoft.xrm.sdk.dll</HintPath>
<HintPath>..\lib\Microsoft.Xrm.Sdk.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
Expand Down Expand Up @@ -325,5 +325,4 @@
<Target Name="AfterBuild">
</Target>
-->

</Project>
5 changes: 3 additions & 2 deletions CrmCodeGenerator.VSPackage/Model/MappingEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public static MappingEntity Parse(EntityMetadata entityMetadata)
if (entityMetadata.Description != null)
if (entityMetadata.Description.UserLocalizedLabel != null)
entity.Description = entityMetadata.Description.UserLocalizedLabel.Label;

//var d = entityMetadata.Attributes.Where(p=>p.LogicalName.Contains("sii_")).ToList();
//var d2 = entityMetadata.Attributes.Where(p=>p.LogicalName.Contains("sii_")).Select(p=>p.LogicalName).ToList();
var fields = entityMetadata.Attributes
.Where(a => a.AttributeOf == null)
.Select(a => MappingField.Parse(a, entity)).ToList();
Expand All @@ -91,7 +92,7 @@ public static MappingEntity Parse(EntityMetadata entityMetadata)
entity.States = entityMetadata.Attributes.Where(a => a is StateAttributeMetadata).Select(a => MappingEnum.Parse(a as EnumAttributeMetadata)).FirstOrDefault();

entity.Enums = entityMetadata.Attributes
.Where(a => a is PicklistAttributeMetadata || a is StateAttributeMetadata || a is StatusAttributeMetadata || a is BooleanAttributeMetadata)
.Where(a => a is PicklistAttributeMetadata || a is StateAttributeMetadata || a is StatusAttributeMetadata || a is BooleanAttributeMetadata || a is MultiSelectPicklistAttributeMetadata)
.Select(a => MappingEnum.Parse(a)).ToArray();

entity.PrimaryKey = entity.Fields.First(f => f.Attribute.LogicalName == entity.Attribute.PrimaryKey);
Expand Down
1 change: 1 addition & 0 deletions CrmCodeGenerator.VSPackage/Model/MappingEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static MappingEnum Parse(EnumAttributeMetadata picklist)

return enm;
}

public static MappingEnum Parse(BooleanAttributeMetadata twoOption)
{
var enm = new MappingEnum();
Expand Down
33 changes: 28 additions & 5 deletions CrmCodeGenerator.VSPackage/Model/MappingField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MappingField
public bool IsDeprecated { get; set; }
public bool IsOptionSet { get; private set; }
public bool IsTwoOption { get; private set; }
public string DeprecatedVersion {get ; set; }
public string DeprecatedVersion { get; set; }
public string LookupSingleType { get; set; }
bool IsPrimaryKey { get; set; }
public bool IsRequired { get; set; }
Expand Down Expand Up @@ -68,12 +68,16 @@ public static MappingField Parse(AttributeMetadata attribute, MappingEntity enti
result.IsOptionSet = attribute.AttributeType == AttributeTypeCode.Picklist;
result.IsTwoOption = attribute.AttributeType == AttributeTypeCode.Boolean;
result.DeprecatedVersion = attribute.DeprecatedVersion;
result.IsDeprecated = !string.IsNullOrWhiteSpace(attribute.DeprecatedVersion);
result.IsDeprecated = !string.IsNullOrWhiteSpace(attribute.DeprecatedVersion);

if (attribute is PicklistAttributeMetadata)
result.EnumData =
MappingEnum.Parse(attribute as PicklistAttributeMetadata);

if (attribute is MultiSelectPicklistAttributeMetadata)
result.EnumData =
MappingEnum.Parse(attribute as MultiSelectPicklistAttributeMetadata);

if (attribute is LookupAttributeMetadata)
{
var lookup = attribute as LookupAttributeMetadata;
Expand All @@ -86,6 +90,10 @@ public static MappingField Parse(AttributeMetadata attribute, MappingEntity enti

if (attribute.AttributeType != null)
result.FieldType = attribute.AttributeType.Value;
if (attribute.AttributeTypeName != null)
{
result.AttributeTypeName = attribute.AttributeTypeName.Value;
}

result.IsPrimaryKey = attribute.IsPrimaryId == true;

Expand All @@ -94,8 +102,8 @@ public static MappingField Parse(AttributeMetadata attribute, MappingEntity enti
result.PrivatePropertyName = Naming.GetEntityPropertyPrivateName(attribute.SchemaName);
result.HybridName = Naming.GetProperHybridFieldName(result.DisplayName, result.Attribute);

if(attribute.Description != null)
if(attribute.Description.UserLocalizedLabel != null)
if (attribute.Description != null)
if (attribute.Description.UserLocalizedLabel != null)
result.Description = attribute.Description.UserLocalizedLabel.Label;

if (attribute.DisplayName != null)
Expand Down Expand Up @@ -195,11 +203,16 @@ private static string GetTargetType(MappingField field)
case AttributeTypeCode.Virtual:
case AttributeTypeCode.EntityName:
case AttributeTypeCode.String:
if (field.AttributeTypeName == "MultiSelectPicklistType")
{
return "Microsoft.Xrm.Sdk.OptionSetValueCollection";
}
return "string";
case AttributeTypeCode.PartyList:
return "System.Collections.Generic.IEnumerable<ActivityParty>";
case AttributeTypeCode.ManagedProperty:
return "Microsoft.Xrm.Sdk.BooleanManagedProperty";

default:
return "object";
}
Expand Down Expand Up @@ -249,6 +262,10 @@ public string TargetType
case AttributeTypeCode.Virtual:
case AttributeTypeCode.EntityName:
case AttributeTypeCode.String:
if (AttributeTypeName == "MultiSelectPicklistType")
{
return "Microsoft.Xrm.Sdk.OptionSetValueCollection";
}
return "string";

default:
Expand Down Expand Up @@ -291,6 +308,10 @@ public string SetMethodCall
methodName = "SetLookup"; break;
//methodName = "SetLookup"; break;
case AttributeTypeCode.Virtual:
if (AttributeTypeName == "MultiSelectPicklistType")
{
return "SetValue<Microsoft.Xrm.Sdk.OptionSetValueCollection>";
}
methodName = "SetValue<string>"; break;
case AttributeTypeCode.Customer:
methodName = "SetCustomer"; break;
Expand Down Expand Up @@ -319,5 +340,7 @@ public string SetMethodCall
return string.Format("{0}(\"{1}\", value);", methodName, this.Attribute.LogicalName);
}
}

public string AttributeTypeName { get; private set; }
}
}
2 changes: 1 addition & 1 deletion CrmCodeGenerator.VSPackage/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: ProvideBindingRedirection(AssemblyName = "Microsoft.Xrm.Sdk", NewVersion = "8.0.0.0", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "7.0.0.0")]
[assembly: ProvideBindingRedirection(AssemblyName = "Microsoft.Xrm.Sdk", NewVersion = "9.0.0.0", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "7.0.0.0")]

Binary file modified CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator.vsix
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions CrmCodeGenerator.VSPackage/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="d57cc223-384b-41cc-b5d0-814a71ce8d61" Version="1.15.0.4" Language="en-US" Publisher="Eric Labashosky" />
<Identity Id="d57cc223-384b-41cc-b5d0-814a71ce8d61" Version="1.15.0.5" Language="en-US" Publisher="Eric Labashosky" />
<DisplayName>CrmCodeGenerator.VSPackage</DisplayName>
<Description xml:space="preserve">Allows you to generate CRM 2011/2013/2015/ schema files. Much like CrmSrvUtil.exe but with a lot more features; select entities (smaller code/assembly), runs in VisualStudio, T4 templates for control of how code is generated (also allows other languages), Template is saved to project, connection info save to SUO &amp; so that you can modify it as needed.
<Description xml:space="preserve">Allows you to generate CRM 2011/2013/2015/2016/ schema files. Much like CrmSrvUtil.exe but with a lot more features; select entities (smaller code/assembly), runs in VisualStudio, T4 templates for control of how code is generated (also allows other languages), Template is saved to project, connection info save to SUO &amp; so that you can modify it as needed.
</Description>
<MoreInfo>https://crmcodegenerator.codeplex.com/</MoreInfo>
<License>license.txt</License>
Expand Down
Binary file modified lib/microsoft.crm.sdk.proxy.dll
Binary file not shown.
Binary file modified lib/microsoft.xrm.sdk.dll
Binary file not shown.