/// <summary>
 /// Registers math functions with specified rule activity manager.
 /// </summary>
 /// <param name="activityManager">A object of RuleActivityManager used for registration of math functions.</param>
 public static void RegisterFunctions(RuleActivityManager activityManager)
 {
     RegisterFunction <Sinh>(activityManager);
     RegisterFunction <Cosh>(activityManager);
     RegisterFunction <Abs>(activityManager);
     RegisterFunction <Acos>(activityManager);
     RegisterFunction <Asin>(activityManager);
     RegisterFunction <Atan>(activityManager);
     RegisterFunction <Ceil>(activityManager);
     RegisterFunction <Cos>(activityManager);
     RegisterFunction <Exp>(activityManager);
     RegisterFunction <Floor>(activityManager);
     RegisterFunction <Ln>(activityManager);
     RegisterFunction <Sign>(activityManager);
     RegisterFunction <Sin>(activityManager);
     RegisterFunction <Sqrt>(activityManager);
     RegisterFunction <Tan>(activityManager);
     RegisterFunction <Atan2>(activityManager);
     RegisterFunction <Log>(activityManager);
     RegisterFunction <Mod>(activityManager);
     RegisterFunction <Power>(activityManager);
     RegisterFunction <Remainder>(activityManager);
     RegisterFunction <Round>(activityManager);
     RegisterFunction <Trunc>(activityManager);
 }
        private static void RegisterFunction <T>(RuleActivityManager activityManager) where T : CodeActivity <DynamicValue>, new()
        {
            Type   functionType = typeof(T);
            string functionName = functionType.Name;

            object[] attrs = functionType.GetCustomAttributes(typeof(ActivityCaptionResourceAttribute), false);
            string   functionDisplayName = null;

            if (attrs.Length > 0)
            {
                ActivityCaptionResourceAttribute attr = (ActivityCaptionResourceAttribute)(attrs[0]);
                functionDisplayName = Properties.Resources.ResourceManager.GetString(attr.ResourceKey);
            }

            if (functionDisplayName == null)
            {
                functionDisplayName = functionName;
            }

            activityManager.RegisterFunction(
                functionName,
                functionDisplayName,
                () => new T(),
                FunctionSignature,
                typeof(T),
                typeof(DynamicValue));
        }
        /// <summary>
        /// Gets the entry of registration of activity according specified ModelItem object.
        /// </summary>
        /// <param name="item">The specified ModelItem object.</param>
        /// <returns>The entry of registration of activity represented by the specified ModelItem object.</returns>
        public static ActivityEntry GetActivityEntry(this ModelItem item)
        {
            RuleEditingContext  context         = item.GetRuleEditingContext();
            RuleManager         ruleManager     = context.GetRuleSignature().Owner;
            RuleActivityManager activityManager = ruleManager.ActivityManager;
            ActivityEntry       entry           = activityManager.GetEntry(item.ItemType);

            return(entry);
        }
        private static void RegisterOperator <T>(
            RuleActivityManager activityManager, OperatorEntry.OperatorCategory category, string displayName)
            where T : CodeActivity <DynamicValue>, new()
        {
            string functionName = typeof(T).Name;

            activityManager.RegisterOperator(
                functionName,
                displayName,
                () => new T(),
                OperatorSignature,
                typeof(T),
                typeof(DynamicValue),
                category);
        }
        private static void RegisterActivities()
        {
            RuleActivityManager ruleActivityManager = RuleManagerInstance.ActivityManager;
            ActivitySignature   generalSignature    = new ActivitySignature();
            PipeRuleSignature   pipeRuleSignature   = new PipeRuleSignature(RuleManagerInstance);

            ruleActivityManager.RegisterActivity(
                "If",   // NOXLATE
                "If",
                () => new If(),
                generalSignature,
                typeof(If));
            ruleActivityManager.RegisterActivity(
                "Report",
                "Report",
                AddValidationItem.Create,
                pipeRuleSignature,
                typeof(AddValidationItem));
        }
        /// <summary>
        /// Registers operators to the specified rule activity manager.
        /// </summary>
        /// <param name="activityManager">The RuleActivityManager object used for registration of operators.</param>
        public static void RegisterOperators(RuleActivityManager activityManager)
        {
            RegisterOperator <Add>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.AddOperator);
            RegisterOperator <Subtract>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.SubtractOperator);
            RegisterOperator <Multiply>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.MultiplyOperator);
            RegisterOperator <Divide>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.DivideOperator);

            RegisterOperator <Equal>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.Equal);
            RegisterOperator <NotEqual>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.NotEqual);
            RegisterOperator <GreaterThan>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.GreaterThan);
            RegisterOperator <LessThan>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.LessThan);
            RegisterOperator <GreaterThanOrEqual>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.GreaterThanOrEqual);
            RegisterOperator <LessThanOrEqual>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.LessThanOrEqual);

            RegisterOperator <AndAlso>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.And);
            RegisterOperator <OrElse>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.Or);
            RegisterOperator <Not>(activityManager, OperatorEntry.OperatorCategory.Unary, Properties.Resources.Not);
            RegisterOperator <Xor>(activityManager, OperatorEntry.OperatorCategory.Binary, Properties.Resources.Xor);
        }
        private static void RegisterDesigners()
        {
            RuleDesignerManager ruleDesignerManager = RuleDesignerManagerInst;

            // Register designer for activities
            ruleDesignerManager.RegisterDesigner(typeof(If), typeof(CompositeIfDesigner));
            ruleDesignerManager.RegisterDesigner(typeof(sas.If), typeof(CompositeIfDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(Match), typeof(MatchDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(MatchWithResult), typeof(MatchWithResultDesigner));
            ruleDesignerManager.RegisterDesigner(typeof(sas.Sequence), typeof(SequenceDesigner));
            ruleDesignerManager.RegisterDesigner(typeof(StringExpression), typeof(StringExpressionDesigner));
            ruleDesignerManager.RegisterDesigner(typeof(PipePropertyActivity), typeof(PipePropertyDesigner));
            ruleDesignerManager.RegisterDesigner(typeof(AddValidationItem), typeof(ValidationActivityDesigner));

            //ruleDesignerManager.RegisterDesigner(typeof(AddValidationItem), typeof(ValidationActivityDesigner));

            //ruleDesignerManager.RegisterDesigner(typeof(AddContainedFeature), typeof(AddFeatureActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(UpdateProperty), typeof(UpdatePropertyDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(UpdateMultipleProperties), typeof(UpdateMultiplePropertiesDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(BuildResolution), typeof(ResolutionBuildActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(PromptResolve), typeof(PromptResolveActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(PromptSetModelName), typeof(SetModelResolveActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(PromptSetProperty), typeof(SetAttributeResolveActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(EnsurePropertySet), typeof(EnsureAttributeSetDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(InvokeNamedRule), typeof(InvokeNamedRuleDesigner));

            //ruleDesignerManager.RegisterDesigner(typeof(AddMaterial), typeof(MaterialAddActivityDesigner));

            // Register designer for operators
            RuleManager         ruleManager     = RuleManagerInstance;
            RuleActivityManager activityManager = ruleManager.ActivityManager;

            foreach (var item in activityManager.GetOperatorRegistries())
            {
                if (item.Category == OperatorEntry.OperatorCategory.Binary)
                {
                    ruleDesignerManager.RegisterDesigner(item.ActivityType, typeof(HorizontalBinaryDesigner));
                }
                else
                {
                    ruleDesignerManager.RegisterDesigner(item.ActivityType, typeof(UnaryOperatorDesigner));
                }
            }

            // Register designer for functions
            //ruleDesignerManager.RegisterDesigner(typeof(FeaturePropertyIsSet), typeof(FeaturePropertyExistDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(FeaturePropertyNotSet), typeof(FeaturePropertyNotExistDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ListToTextActivity), typeof(ListToTextDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(TableLookup), typeof(TableLookupDesigner));

            //ruleDesignerManager.RegisterDesigner(typeof(ConnectedCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ConnectedAtStartCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ConnectedAtEndCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ContainedCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ContainedSiblingCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ContainedConnectedCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ContainerExist), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(DownstreamCount), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(UpstreamExists), typeof(ConnectTracingFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ConditionalValue<DynamicValue>), typeof(ConditionalValueDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ConditionalValue<string>), typeof(ConditionalValueDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(FeatureClassName), typeof(FunctionNoParameterDesigner));

            //ruleDesignerManager.RegisterDesigner(typeof(MathFunctionWithOneArg), typeof(FunctionOneParameterDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(MathFunctionWithTwoArgs), typeof(FunctionTwoParametersDesigner));

            // Register designer for expression items
            //ruleDesignerManager.RegisterDesigner(typeof(FeatureItemProperty), typeof(PipePropertyDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(Expression<>), typeof(ExpressionActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(ExpressionWithUnit), typeof(ExpressionWithUnitActivityDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(CatalogMaterialProperty), typeof(CatalogMaterialAttributeDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(aura.AudVariable), typeof(AudVariableDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(DomainValue), typeof(FunctionNoParameterDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(NamedRuleFunction), typeof(NamedRuleFunctionDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(DocumentProperty), typeof(DocumentPropertyDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(CatalogItemValue), typeof(CatalogItemValueDesigner));

            // Register designer for sizing rules
            //ruleDesignerManager.RegisterDesigner(typeof(AddQueryMatch), typeof(AddQueryMatchDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(TableQueryMatch), typeof(TableQueryMatchDesigner));
            //ruleDesignerManager.RegisterDesigner(typeof(AddSortAttribute), typeof(AddSortAttributeDesigner));

            //ruleDesignerManager.RegisterDesigner(typeof(ChooseStyle), typeof(ChooseStyleActivityDesigner));
        }
        private static void RegisterOperators()
        {
            RuleActivityManager ruleActivityManager = RuleManagerInstance.ActivityManager;

            DynamicOperators.RegisterOperators(ruleActivityManager);
        }