public static Func <object, PropertyInfo, Func <object>, Action <object>, object> ChoicesWithHyperlinqs <T>( IEnumerable <T> choices, NullableOptionInclusionKind nullKind, Func <T, string> toString = null) => (o, p, gv, sv) => { var preceding = new object[] { gv(), "[" }; var trailing = new object[] { "]" }; var values = choices.Select(x => new Hyperlinq(() => sv(x), toString?.Invoke(x) ?? $"{x}")).ToList(); var nullOption = new Hyperlinq(() => sv(null), NullString); switch (nullKind) { case NullableOptionInclusionKind.IncludeAtStart: values.Insert(0, nullOption); break; case NullableOptionInclusionKind.IncludeAtEnd: values.Add(nullOption); break; } return(Util.HorizontalRun( true, Enumerable.Concat( new object[] { gv(), "[" }, choices.Select(x => new Hyperlinq(() => sv(x), toString?.Invoke(x) ?? $"{x}"))) .Concat(new[] { "]" }))); };
public Package(FileInfo projectFile, FileInfo assemblyInfoFile, string[] lines, string title, string version, string targetFramework) { ProjectFile = projectFile; AssemblyInfoFile = assemblyInfoFile; this.lines = lines; Title = title; PackageVersion = Version.Parse(version); TargetFramework = new Hyperlinq(() => ProcessHelper.Start(AssemblyInfoFile.Directory.Parent.FullName), targetFramework); ////TargetFramework = Version.Parse(targetFramework).ToString(); }
public static Func <object, PropertyInfo, Func <object>, Action <object>, object> Slider <T>( T min, T max, Func <T, object> toInt, Func <int, T> fromInt) => (o, p, gv, sv) => { var v = gv(); var vc = new DumpContainer { Content = v, Style = "min-width: 30px" }; var s = new RangeControl( Convert.ToInt32(toInt(min)), Convert.ToInt32(toInt(max)), Convert.ToInt32(toInt((T)v))) { IsMultithreaded = true }; s.ValueInput += delegate { var val = fromInt(s.Value); sv(val); vc.Content = val; }; var config = new { Min = min, Max = max }; var editor = EditableDumpContainer.For(config); editor.AddChangeHandler(x => x.Min, (_, m) => s.Min = Convert.ToInt32(toInt(m))); editor.AddChangeHandler(x => x.Max, (_, m) => s.Max = Convert.ToInt32(toInt(m))); var editorDc = new DumpContainer { Content = editor }; var display = true; var toggleEditor = new Hyperlinq(() => { display = !display; editorDc.Style = display ? "" : "display:none"; }, "[*]"); toggleEditor.Action(); return(Util.VerticalRun(vc, Util.HorizontalRun(false, s, toggleEditor), editorDc)); };
internal static void PreprocessObjectToWrite(ref object objectToWrite, ObjectGraphInfo info) { if (objectToWrite is DataServiceQuery) { objectToWrite = ((DataServiceQuery)objectToWrite).Execute(); } if (objectToWrite is QueryOperationResponse) { QueryOperationResponse qor = (QueryOperationResponse)objectToWrite; if (qor.GetType().IsGenericType&& (qor.GetType().GetGenericTypeDefinition() == typeof(QueryOperationResponse <>))) { objectToWrite = Util.VerticalRun(new object[] { new QueryOperationResponseWrapper(true, qor), new QueryOperationResponseWrapper(false, qor) }); } } else if (objectToWrite is QueryOperationResponseWrapper) { QueryOperationResponseWrapper wrapper = (QueryOperationResponseWrapper)objectToWrite; if (wrapper.Enumerate) { objectToWrite = wrapper.Qor; } else { DataServiceQueryContinuation continuation = wrapper.Qor.GetContinuation(); if (!((continuation == null) || wrapper.ElementType.Name.Contains <char>('<'))) { Uri nextLinkUri = continuation.NextLinkUri; objectToWrite = new Hyperlinq(QueryLanguage.Expression, "Execute<" + wrapper.ElementType.Name + "> (new Uri (\"" + nextLinkUri.ToString() + "\"))", "Next Page"); } else { objectToWrite = info.DisplayNothingToken; } } } else { DataServiceQueryException exception = objectToWrite as DataServiceQueryException; if ((exception != null) && (exception.InnerException is DataServiceClientException)) { DataServiceClientException innerException = (DataServiceClientException)exception.InnerException; try { XElement element = XElement.Parse(innerException.Message); if (element.Name.LocalName == "error") { XNamespace namespace2 = element.Name.Namespace; string str = (string)element.Element((XName)(namespace2 + "message")); if (!string.IsNullOrEmpty(str)) { str = str.Trim(); if (str.EndsWith("cannot be used in a query")) { str = str + " predicate"; } if (!str.EndsWith(".")) { str = str + "."; } Util.Highlight(str + " See exception below for more details.").Dump <object>(); } } } catch { } } } }