SenseNet.Packaging.CustomInstallStep.Invoke C# (CSharp) Метод

Invoke() статический приватный Метод

static private Invoke ( MethodInfo method, bool probing, int &warnings ) : bool
method System.Reflection.MethodInfo
probing bool
warnings int
Результат bool
        internal static bool Invoke(MethodInfo method, bool probing, out int warnings)
        {
            warnings = 0;
            try
            {
                bool ok = true;
                foreach (var customStep in _customSteps)
                {
                    var customResult = (StepResult)method.Invoke(customStep, new object[] { probing });

                    if (customResult.Kind == StepResultKind.Error)
                        ok = false;
                    if (customResult.Kind == StepResultKind.Warning)
                        warnings++;
                }
                return ok;
            }
            catch (Exception e)
            {
                Logger.LogException(e);
                return false;
            }
        }

Usage Example

Пример #1
0
        private static InstallResult ExecuteContentTypes(IEnumerable <IManifest> manifests, StepVisitor visitor, out int warnings, out int errors)
        {
            warnings = 0;
            errors   = 0;
            int warn;

            if (!CustomInstallStep.Invoke(GetMethod <CustomInstallStep>(x => x.OnBeforeInstallContentTypes(default(bool))), visitor.IsProbing, out warn))
            {
                return(ReturnWithErrorResult());
            }
            warnings += warn;

            var batchContentTypeInstallStep = AggregateContentTypeInstallSteps(manifests);

            if (batchContentTypeInstallStep != null)
            {
                //---- Initialize
                try
                {
                    batchContentTypeInstallStep.Initialize();
                }
                catch (Exception e)
                {
                    Logger.LogException(e, "INITIALIZING ERROR");
                    return(ReturnWithErrorResult());
                }

                //---- Install
                try
                {
                    StepResult result = visitor.DoIt(batchContentTypeInstallStep);
                    if (result.Kind == StepResultKind.Warning)
                    {
                        warnings++;
                    }
                    if (result.Kind == StepResultKind.Error)
                    {
                        return(ReturnWithErrorResult());
                    }
                }
                catch (Exception e)
                {
                    Logger.LogException(e);
                    return(ReturnWithErrorResult());
                }
            }

            if (!CustomInstallStep.Invoke(GetMethod <CustomInstallStep>(x => x.OnAfterInstallContentTypes(default(bool))), visitor.IsProbing, out warn))
            {
                return(ReturnWithErrorResult());
            }
            warnings += warn;

            return(new InstallResult {
                Successful = true, NeedRestart = false
            });
        }
All Usage Examples Of SenseNet.Packaging.CustomInstallStep::Invoke