Exemplo n.º 1
0
 public ResolveToActionWizard(ResolveToAction fixedResolveToAction)
 {
     InitializeComponent();
     if (fixedResolveToAction != null)
     {
         m_fixedResolveToAction = fixedResolveToAction;
     }
 }
Exemplo n.º 2
0
        private bool RuleEngineResolveRedirection(RuleSet ruleSet, TypeInfo typeInfo,
                                                  out Type convertedType)
        {
            convertedType = null;
            if (ruleSet != null)
            {
                ICategory category = TypeCategory.GetInstance();
                TypeLibTypes.Interop.TYPEKIND typeKind;
                using (TypeAttr attr = typeInfo.GetTypeAttr())
                {
                    typeKind = attr.typekind;
                }
                TypeInfoMatchTarget target = new TypeInfoMatchTarget(typeInfo.GetContainingTypeLib(),
                                                                     typeInfo, typeKind);
                AbstractActionManager actionManager  = RuleEngine.GetActionManager();
                List <Rule>           resolveToRules = ruleSet.GetRule(
                    category, ResolveToActionDef.GetInstance(), target);
                if (resolveToRules.Count != 0)
                {
                    if (resolveToRules.Count > 1)
                    {
                        Output.WriteWarning(Resource.FormatString("Wrn_RuleMultipleMatch",
                                                                  ResolveToActionDef.GetInstance().GetActionName()),
                                            WarningCode.Wrn_RuleMultipleMatch);
                    }
                    Rule resolveToRule =
                        resolveToRules[resolveToRules.Count - 1];

                    ResolveToAction action =
                        resolveToRule.Action as ResolveToAction;
                    try
                    {
                        Assembly assembly = Assembly.ReflectionOnlyLoad(action.AssemblyName);
                        convertedType = assembly.GetType(action.ManagedTypeFullName);
                        return(true);
                    }
                    catch (Exception)
                    {
                        Output.WriteWarning(Resource.FormatString("Wrn_CannotLoadResolveToType",
                                                                  action.ManagedTypeFullName, action.AssemblyName),
                                            WarningCode.Wrn_CannotLoadResolveToType);
                    }
                }
            }
            return(false);
        }