private void GeneratorLateBound(string entity, int i, int count)
        {
            var lateBound       = new CSharpLateBound();
            var rootNameSpace   = json.rootnamespace;
            var sharedNameSpace = GetSharedNameSpace(json.rootnamespace);
            var crmVersionName  = (CrmVersionName)int.Parse(json.crmversion);
            var generated       = lateBound.Go(XrmHelper.GetIOrganizationService(crmServiceClient), crmVersionName, entity, rootNameSpace, sharedNameSpace);
            var file            = $"{currentDirectory}\\{json.rootfolder}\\{entity}.generated.cs";
            var old             = string.Empty;

            if (File.Exists(file))
            {
                old = File.ReadAllText(file).Replace("\r\n", string.Empty).Replace("\t", string.Empty);
            }
            var @new = generated.Replace(" ", string.Empty).Replace("\r\n", string.Empty).Replace("\t", string.Empty);

            if (old != @new)
            {
                File.WriteAllText(file, generated, System.Text.Encoding.UTF8);
                CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorGreen, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Processing ", CliLog.ColorGreen, entity, ".generated.cs");
            }
            else
            {
                CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorGreen, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "No change ", CliLog.ColorGreen, entity, ".generated.cs");
            }
        }
        private void GeneratorLateBound(string entity, int i, int count)
        {
            var lateBound       = new CSharpLateBound();
            var rootNameSpace   = json.rootnamespace;
            var sharedNameSpace = GetSharedNameSpace(json.rootnamespace);
            var crmVersionName  = (CrmVersionName)int.Parse(json.crmversion);
            var generated       = lateBound.Go(XrmHelper.GetIOrganizationService(crmServiceClient), crmVersionName, entity, rootNameSpace, sharedNameSpace);
            var file            = $"{currentDirectory}\\{json.rootfolder}\\{entity}.generated.cs";
            var old             = string.Empty;

            if (File.Exists(file))
            {
                old = File.ReadAllText(file);
            }
            var @new = generated;

            if (RemoveForCompare(old) != RemoveForCompare(@new))
            {
                if (File.Exists(file))
                {
                    File.WriteAllText(file, generated, System.Text.Encoding.UTF8);
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Updated ", CliLog.ColorGreen, entity, ".generated.cs");
                }
                else
                {
                    var latebound = Utility.ReadEmbeddedResource("DynamicsCrm.DevKit.Resources.Generator.LateBound.cs");
                    latebound = latebound.Replace("$NameSpace$", json.rootnamespace).Replace("$class$", entity);
                    var fileLateBound = $"{currentDirectory}\\{json.rootfolder}\\{entity}.cs";

                    File.WriteAllText(fileLateBound, latebound, System.Text.Encoding.UTF8);
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Created ", CliLog.ColorGreen, entity, ".cs");

                    File.WriteAllText(file, generated, System.Text.Encoding.UTF8);
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Created ", CliLog.ColorGreen, entity, ".generated.cs");
                }
            }
            else
            {
                CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorGreen, entity, ".generated.cs");
            }
        }
Exemple #3
0
        public static string GeneratedLateBoundClass(OrganizationServiceProxy service, string crmName, string entitySchemaName, string nameSpace, string sharedNameSpace)
        {
            var lateBound = new CSharpLateBound();

            return(lateBound.Go(service, Utility.ConvertCrmNameToCrmVersionName(crmName), entitySchemaName, nameSpace, sharedNameSpace));
        }