Exemple #1
0
 public Result <G, F> Bind <G>(BindFunc <G> bindF)
 {
     if (okFlag)
     {
         return(bindF(ok));
     }
     else
     {
         return(Result <G, F> .Err(err));
     }
 }
        private static DocItem DocumentFunction(BindFunc func, string prefix)
        {
            //Remove coroutine yield prefix
            string name          = func.IsYieldable ? func.Name.Remove(0, BindFunc.COROUTINE_YIELD_.Length) : func.Name;
            string fullName      = prefix + name;
            string documentation = func.Documentation ?? "";
            string example       = func.Example ?? "";


            var    mi            = func.Callback.Method;
            var    parameterInfo = mi.GetParameters();
            string paramTypes    = "";
            string paramTypesRT  = "";
            string fullParams    = "";
            string fullParamsRT  = "";

            //string parameterNames = "";
            if (parameterInfo.Length > 0)
            {
                paramTypes   = GetParamTypesOnlyString(parameterInfo, false);
                paramTypesRT = GetParamTypesOnlyString(parameterInfo, true);
                fullParams   = GetParamString(parameterInfo, false, true);
                fullParamsRT = GetParamString(parameterInfo, true, true);
                //parameterNames = GetParamNamesOnlyString(parameterInfo);
            }

            var returnType = mi.ReturnType;
            //string tooltip = $"Return Type:\n- {(returnType.IsGenericType ? GetGenericString(returnType, true) : returnType.FullName)}{(parameterFullNames != null ? $"\nParameter Types:\n{parameterFullNames}" : " ")}";
            string returnTypeName = returnType.IsGenericType ? GetGenericString(returnType) : returnType.Name;
            string definition     = $"{returnTypeName} {fullName}({fullParams})";
            string copy           = $"{fullName}()";

            string returnTypeRichText = $"<i><color=\"{ReturnTypeColor}\">{returnTypeName}</color></i>";
            string richTextDefinition = $"{returnTypeRichText} {fullName}({fullParamsRT})";
            string preview            = $"{returnTypeName} {name}({paramTypes})";
            string previewRT          = $"{returnTypeRichText} {name}({paramTypesRT})";

            return(new DocItem(DocItemType.Function, func.Callback.Method.DeclaringType, name, fullName, definition, copy, documentation, example, richTextDefinition, preview, previewRT)
            {
                DataType = typeof(Delegate),
                MethodInfoReference = mi
            });
        }