Пример #1
0
        public void AddAttribute(CrmPluginRegistrationAttribute attribute, string className)
        {
            // Locate the start of the class and add the attribute above
            var classLocation = _pluginClasses.ContainsKey(className) ? _pluginClasses[className] : null;

            if (classLocation == null)
            {
                throw new Exception(String.Format("Cannot find class {0}", className));
            }

            var pos = _code.IndexOf(classLocation.Value);

            // Find previouse line break
            var lineBreak = _code.LastIndexOf("\n", pos - 1);

            // Indentation
            var indentation = _code.Substring(lineBreak, pos - lineBreak);

            // Add the attribute
            var attributeCode = attribute.GetAttributeCode(indentation);

            //var attributeCode = attribute.GetAttributeCode("");

            //attributeCode = attributeCode.Replace("\r\n", String.Empty).Replace("\n", String.Empty).Replace("\r", String.Empty);

            //TODO: see about getting everything on 1 line AND not getting inconsistent line ending warnings
            //TODO: see about making sure everything gets inserted into #region if in place

            // Insert
            _code = _code.Insert(lineBreak, attributeCode);
            //_code = _code.Insert(lineBreak, indentation + attributeCode);
        }
Пример #2
0
        public void CreateWorkflowAttributeCode()
        {
            var attribute = new CrmPluginRegistrationAttribute(
                "WorkflowActivity", "FriendlyName", "Description", "Group Name", IsolationModeEnum.Sandbox)
            {
            };

            var code = attribute.GetAttributeCode("");

            Debug.WriteLine(code);
            Assert.AreEqual(Normalise(@"[CrmPluginRegistration(
        ""WorkflowActivity"", ""FriendlyName"", ""Description"", ""Group Name"", IsolationModeEnum.Sandbox
            )]"), Normalise(code));
        }
Пример #3
0
        public void CreatePluginAttributeCode()
        {
            var attribute = new CrmPluginRegistrationAttribute(
                MessageNameEnum.Update, "account", StageEnum.PostOperation, ExecutionModeEnum.Synchronous,
                "name,address1_line1",
                "Delete of account", 1, IsolationModeEnum.Sandbox)
            {
                Image1Name       = "PreImage",
                Image1Attributes = "name,address1_line1",
                Image1Type       = ImageTypeEnum.PreImage,
                Image2Name       = "PostImage",
                Image2Attributes = "name,address1_line1",
                Image2Type       = ImageTypeEnum.PostImage
            };

            var code = attribute.GetAttributeCode("");

            Debug.WriteLine(code);
            Assert.AreEqual(Normalise("[CrmPluginRegistration(\"Update\",\"account\",StageEnum.PostOperation,ExecutionModeEnum.Synchronous,\"name, address1_line1\",\"Deleteofaccount\",1,IsolationModeEnum.Sandbox,Image1Type=ImageTypeEnum.PreImage,Image1Name=\"PreImage\",Image1Attributes=\"name, address1_line1\",Image2Type=ImageTypeEnum.PostImage,Image2Name=\"PostImage\",Image2Attributes=\"name, address1_line1\")]"), Normalise(code));
        }
Пример #4
0
        public void AddAttribute(CrmPluginRegistrationAttribute attribute, string className)
        {
            // Locate the start of the class and add the attribute above
            var classLocation = _pluginClasses.ContainsKey(className) ? _pluginClasses[className] : null;

            if (classLocation == null)
            {
                throw new Exception(String.Format("Cannot find class {0}", className));
            }
            var pos = _code.IndexOf(classLocation.Value);
            // Find previouse line break
            var lineBreak = _code.LastIndexOf("\r\n", pos - 1);

            // Indentation
            var indentation = _code.Substring(lineBreak, pos - lineBreak);

            // Add the attribute
            var attributeCode = attribute.GetAttributeCode(indentation);

            // Insert
            _code = _code.Insert(lineBreak, attributeCode);
        }