示例#1
0
        protected internal virtual string GetText(OperationSymbol operation, OperationSettings os)
        {
            if (os != null && os.Text != null)
            {
                return(os.Text);
            }

            return(operation.NiceToString());
        }
示例#2
0
        public static WikiLink LinkParser(string content)
        {
            Match m = HelpLogic.HelpLinkRegex.Match(content);

            if (m.Success)
            {
                string letter = m.Groups["letter"].ToString();
                string link   = m.Groups["link"].ToString();
                string text   = m.Groups["text"].ToString();

                switch (letter)
                {
                case WikiFormat.EntityLink:
                    Type t = TypeLogic.TryGetType(link);
                    return(new WikiLink(
                               HelpUrls.EntityUrl(t),
                               text.HasText() ? text : t.NiceName()));

                case WikiFormat.Hyperlink:
                    return(new WikiLink(link, text));

                case WikiFormat.OperationLink:
                    OperationSymbol operation = SymbolLogic <OperationSymbol> .TryToSymbol(link);

                    List <Type> types = OperationLogic.FindTypes(operation).Where(TypeLogic.TypeToEntity.ContainsKey).ToList();
                    if (types.Count == 1)
                    {
                        return(new WikiLink(
                                   HelpUrls.OperationUrl(types[0], operation),
                                   text.HasText() ? text : operation.NiceToString()));
                    }
                    else
                    {
                        return(new MultiWikiLink(operation.NiceToString())
                        {
                            Links = types.Select(currentType =>
                                                 new WikiLink(
                                                     HelpUrls.OperationUrl(currentType, operation),
                                                     currentType.NiceName(), operation.NiceToString())).ToList()
                        });
                    }

                case WikiFormat.PropertyLink:
                    PropertyRoute route = PropertyRoute.Parse(TypeLogic.TryGetType(link.Before('.')), link.After('.'));

                    while (route.PropertyRouteType == PropertyRouteType.LiteEntity ||
                           route.PropertyRouteType == PropertyRouteType.Mixin ||
                           route.PropertyRouteType == PropertyRouteType.MListItems)
                    {
                        route = route.Parent;
                    }

                    return(new WikiLink(HelpUrls.PropertyUrl(route), route.PropertyInfo.NiceName()));

                case WikiFormat.QueryLink:
                    object o = QueryLogic.TryToQueryName(link);
                    if (o as Enum != null)
                    {
                        Enum query = (Enum)o;
                        return(new WikiLink(
                                   HelpUrls.QueryUrl(query),
                                   text.HasText() ? text : QueryUtils.GetNiceName(query)));
                    }
                    else
                    {
                        Type query = (Type)o;
                        return(new WikiLink(
                                   HelpUrls.QueryUrl(query),
                                   text.HasText() ? text : QueryUtils.GetNiceName(query)));
                    }

                case WikiFormat.NamespaceLink:
                    NamespaceHelp nameSpace = HelpLogic.GetNamespaceHelp(link);
                    return(new WikiLink(
                               HelpUrls.NamespaceUrl(link),
                               text.HasText() ? text : link,
                               nameSpace != null ? "" : "unavailable"));

                case WikiFormat.AppendixLink:
                    AppendixHelp appendix = HelpLogic.GetAppendixHelp(link);
                    return(new WikiLink(
                               HelpUrls.AppendixUrl(link),
                               text.HasText() ? text : link,
                               appendix != null ? "" : "unavailable"));
                }
            }
            return(null);
        }
示例#3
0
 public static void AssertOperationAllowed(OperationSymbol operationSymbol, Type entityType, bool inUserInterface)
 {
     if (!OperationAllowed(operationSymbol, entityType, inUserInterface))
     {
         throw new UnauthorizedAccessException(OperationMessage.Operation01IsNotAuthorized.NiceToString().FormatWith(operationSymbol.NiceToString(), operationSymbol.Key) +
                                               (inUserInterface ? " " + OperationMessage.InUserInterface.NiceToString() : ""));
     }
 }